[PATCH 1 of 2] convert: fix tags node in revmap

Edouard Gomez ed.gomez at free.fr
Thu Nov 27 03:24:08 CST 2008

# HG changeset patch
# User Edouard Gomez <ed.gomez at free.fr>
# Date 1199837412 -3600
# Node ID c48daeae689ddbe1b4c0bcce548f0b6ca50393b8
# Parent  c4ce828e8074c51633ceaf21078e8d2696d0a4d2
convert: fix tags node in revmap

Using latest commit node as the source revid for the tags node
in the revision map file causes history corruption during
incremental conversions:
 - Do full conversion with some branches
   (eg: default and experimental) and tags (eg; v0.1, v0.2)
   Let's call tip: tip_conversion1, and the tags commit node:
 - [wait a few days]
 - Do an incremental conversion
   Let's call the first commit base_conversion2

We end up with:
 - Good history up to tip_conversion1
 - Tags correctly set in tags_commit
 - base_conversion1 is the child of tags_commit

The cause of corruption is that the mapfile lists the tag node
as the last real revision (tip_conversion1). So the incremental
conversion thinks the tag node is the parent of base_conversion2.

In the case of hg.tagsbranch != default, then the base_conversion1
node is based on a completly wrong history and wrong set of files
(none except .hgtags).

This patch tries to address that easily. It adds a callback in the
source classes so that they give the converter a fake node id for
tags commits.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -129,6 +129,14 @@
         '''Notify the source that a revision has been converted.'''
+    def gettagsnodename(self):
+        """Return a source node name that can be put in the revision map file.
+        This node name is fake but won't cause any crash when parsing the
+        revision map on incremental conversions.
+        """
+        return '0'
 class converter_sink(object):
     """Conversion sink (target) interface"""
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -291,7 +291,7 @@
                 # write another hash correspondence to override the previous
                 # one so we don't end up with extra tag heads
                 if nrev:
-                    self.map[c] = nrev
+                    self.map[self.source.gettagsnodename()] = nrev
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -442,6 +442,9 @@
         self.convertfp.write('%s %d\n' % (destrev, self.revnum(rev)))
+    def gettagsnodename(self):
+         return self.revid(0)
     # -- helper functions --
     def revid(self, revnum, module=None):

More information about the Mercurial-devel mailing list