[PATCH 1 of 2] convert: always track the hg source revision in the internal commit object

Matt Harbison mharbison72 at gmail.com
Sun Jun 14 12:58:41 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1434301440 14400
#      Sun Jun 14 13:04:00 2015 -0400
# Node ID be968ecf8f0ee09b5a06782418d57e64c7f0c3eb
# Parent  4388714b846e21cb2fefb686220c7c0d2df1b85a
convert: always track the hg source revision in the internal commit object

This will be needed in the next patch to determine if phases need to be
adjusted.  The insertion of the source revision in 'extras{}' is still
controlled by the config property.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -44,7 +44,7 @@
 
 class commit(object):
     def __init__(self, author, date, desc, parents, branch=None, rev=None,
-                 extra={}, sortkey=None):
+                 extra={}, sortkey=None, saverev=True):
         self.author = author or 'unknown'
         self.date = date or '0 0'
         self.desc = desc
@@ -53,6 +53,7 @@
         self.rev = rev
         self.extra = extra
         self.sortkey = sortkey
+        self.saverev = saverev
 
 class converter_source(object):
     """Conversion source interface"""
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -243,7 +243,7 @@
 
         if self.branchnames and commit.branch:
             extra['branch'] = commit.branch
-        if commit.rev:
+        if commit.rev and commit.saverev:
             extra['convert_revision'] = commit.rev
 
         while parents:
@@ -473,15 +473,13 @@
     def getcommit(self, rev):
         ctx = self.changectx(rev)
         parents = [p.hex() for p in self.parents(ctx)]
-        if self.saverev:
-            crev = rev
-        else:
-            crev = None
+        crev = rev
+
         return commit(author=ctx.user(),
                       date=util.datestr(ctx.date(), '%Y-%m-%d %H:%M:%S %1%2'),
                       desc=ctx.description(), rev=crev, parents=parents,
                       branch=ctx.branch(), extra=ctx.extra(),
-                      sortkey=ctx.rev())
+                      sortkey=ctx.rev(), saverev=self.saverev)
 
     def gettags(self):
         # This will get written to .hgtags, filter non global tags out.


More information about the Mercurial-devel mailing list