changeset 8048:d22432bdcba1

convert/cvs: delay CVS log parsing after initialization (issue1581/2) Source and destination constructors should be fast so configurations issues are hit quickly, including authentication and filemap/authormap/splicemap issues. Delaying might be a problem if the remove side disconnects idle connections while the log is being read. It did not happen when converting openafs repository, where log retrieval took at least 10mn.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 11 Apr 2009 21:17:11 +0200
parents 04c62275cbc7
children 718c8f01feb2
files hgext/convert/cvs.py tests/test-convert-cvs-branch.out tests/test-convert-cvs-builtincvsps.out tests/test-convert-cvs-synthetic.out
diffstat 4 files changed, 34 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/cvs.py	Sat Apr 11 21:15:27 2009 +0200
+++ b/hgext/convert/cvs.py	Sat Apr 11 21:17:11 2009 +0200
@@ -24,7 +24,7 @@
         if not self.builtin:
             checktool(cvspsexe)
 
-        self.changeset = {}
+        self.changeset = None
         self.files = {}
         self.tags = {}
         self.lastbranch = {}
@@ -34,12 +34,12 @@
         self.cvsrepo = file(os.path.join(cvs, "Repository")).read()[:-1]
         self.encoding = locale.getpreferredencoding()
 
-        self._parse(ui)
         self._connect()
 
-    def _parse(self, ui):
-        if self.changeset:
+    def _parse(self):
+        if self.changeset is not None:
             return
+        self.changeset = {}
 
         maxrev = 0
         cmd = self.cmd
@@ -65,13 +65,13 @@
 
             if self.builtin:
                 # builtin cvsps code
-                ui.status(_('using builtin cvsps\n'))
+                self.ui.status(_('using builtin cvsps\n'))
 
-                db = cvsps.createlog(ui, cache='update')
-                db = cvsps.createchangeset(ui, db,
-                      fuzz=int(ui.config('convert', 'cvsps.fuzz', 60)),
-                      mergeto=ui.config('convert', 'cvsps.mergeto', None),
-                      mergefrom=ui.config('convert', 'cvsps.mergefrom', None))
+                db = cvsps.createlog(self.ui, cache='update')
+                db = cvsps.createchangeset(self.ui, db,
+                      fuzz=int(self.ui.config('convert', 'cvsps.fuzz', 60)),
+                      mergeto=self.ui.config('convert', 'cvsps.mergeto', None),
+                      mergefrom=self.ui.config('convert', 'cvsps.mergefrom', None))
 
                 for cs in db:
                     if maxrev and cs.id>maxrev:
@@ -278,6 +278,7 @@
             r = self.readp.readline()
 
     def getheads(self):
+        self._parse()
         return self.heads
 
     def _getfile(self, name, rev):
@@ -332,6 +333,7 @@
                     raise util.Abort(_("unknown CVS response: %s") % line)
 
     def getfile(self, file, rev):
+        self._parse()
         data, mode = self._getfile(file, rev)
         self.modecache[(file, rev)] = mode
         return data
@@ -340,14 +342,18 @@
         return self.modecache[(file, rev)]
 
     def getchanges(self, rev):
+        self._parse()
         self.modecache = {}
         return util.sort(self.files[rev].items()), {}
 
     def getcommit(self, rev):
+        self._parse()
         return self.changeset[rev]
 
     def gettags(self):
+        self._parse()
         return self.tags
 
     def getchangedfiles(self, rev, i):
+        self._parse()
         return util.sort(self.files[rev].keys())
--- a/tests/test-convert-cvs-branch.out	Sat Apr 11 21:15:27 2009 +0200
+++ b/tests/test-convert-cvs-branch.out	Sat Apr 11 21:17:11 2009 +0200
@@ -23,13 +23,13 @@
 % Convert
 assuming destination src-hg
 initializing destination src-hg repository
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 7 log entries
 creating changesets
 5 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 4 Initial revision
--- a/tests/test-convert-cvs-builtincvsps.out	Sat Apr 11 21:15:27 2009 +0200
+++ b/tests/test-convert-cvs-builtincvsps.out	Sat Apr 11 21:17:11 2009 +0200
@@ -13,13 +13,13 @@
 checking in src/b/c,v
 % convert fresh repo
 initializing destination src-hg repository
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 5 log entries
 creating changesets
 3 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 2 Initial revision
@@ -31,13 +31,13 @@
 c
 % convert fresh repo with --filemap
 initializing destination src-filemap repository
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 5 log entries
 creating changesets
 3 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 2 Initial revision
@@ -54,13 +54,13 @@
 checking in src/a,v
 checking in src/b/c,v
 % convert again
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 7 log entries
 creating changesets
 4 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 0 ci1
@@ -70,13 +70,13 @@
 c
 c
 % convert again with --filemap
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 7 log entries
 creating changesets
 4 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 0 ci1
@@ -93,13 +93,13 @@
 T b/c
 checking in src/b/c,v
 % convert again
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 8 log entries
 creating changesets
 5 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 0 ci2
@@ -107,13 +107,13 @@
 c
 d
 % convert again with --filemap
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 8 log entries
 creating changesets
 5 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 0 ci2
@@ -127,13 +127,13 @@
 % commit a new revision with funny log message
 checking in src/a,v
 % convert again
+connecting to cvsrepo
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 9 log entries
 creating changesets
 6 changeset entries
-connecting to cvsrepo
-scanning source...
 sorting...
 converting...
 0 funny
--- a/tests/test-convert-cvs-synthetic.out	Sat Apr 11 21:15:27 2009 +0200
+++ b/tests/test-convert-cvs-synthetic.out	Sat Apr 11 21:17:11 2009 +0200
@@ -34,13 +34,13 @@
 new revision: 1.1.4.2; previous revision: 1.1.4.1
 % convert to hg
 initializing destination proj.hg repository
+connecting to *REPO*
+scanning source...
 using builtin cvsps
 collecting CVS rlog
 9 log entries
 creating changesets
 4 changeset entries
-connecting to *REPO*
-scanning source...
 sorting...
 converting...
 3 add file1 on trunk