diff hgext/convert/cvsps.py @ 26593:c60dfcc0abf2

cvsps: fix computation of parent revisions when log caching is on cvsps computes the parent revisions of log entries by walking the cvs log sorted by (rcs, revision) and by iteratively maintaining a 'versions' dictionary which maps a (rcs, branch) pair onto the last revision seen for that pair. When log caching is on and a log cache exists, cvsps fails to set the parent revisions of new log entries because it does not iterate over the log cache in the parents computation. A complication is that a file rcs can change (move to/from the attic), with respect to its value in the log cache, if the file is removed/added back. This patch adds an iteration over the log cache to update the rcs of cached log entries, if changed, and to properly populate the 'versions' dictionary.
author Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
date Wed, 07 Oct 2015 11:33:52 +0300
parents 328739ea70c3
children 71176606fa0a
line wrap: on
line diff
--- a/hgext/convert/cvsps.py	Tue Oct 06 16:26:20 2015 -0500
+++ b/hgext/convert/cvsps.py	Wed Oct 07 11:33:52 2015 +0300
@@ -207,6 +207,7 @@
     # state machine begins here
     tags = {}     # dictionary of revisions on current file with their tags
     branchmap = {} # mapping between branch names and revision numbers
+    rcsmap = {}
     state = 0
     store = False # set when a new record can be appended
 
@@ -439,6 +440,8 @@
 
             log.append(e)
 
+            rcsmap[e.rcs.replace('/Attic/', '/')] = e.rcs
+
             if len(log) % 100 == 0:
                 ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80)+'\n')
 
@@ -446,6 +449,13 @@
 
     # find parent revisions of individual files
     versions = {}
+    for e in sorted(oldlog, key=lambda x: (x.rcs, x.revision)):
+        rcs = e.rcs.replace('/Attic/', '/')
+        if rcs in rcsmap:
+            e.rcs = rcsmap[rcs]
+        branch = e.revision[:-1]
+        versions[(e.rcs, branch)] = e.revision
+
     for e in log:
         branch = e.revision[:-1]
         p = versions.get((e.rcs, branch), None)