[PATCH] convert: record the source revision in the changelog

Brendan Cully brendan at kublai.com
Thu Jul 12 22:32:17 CDT 2007


# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1184297522 25200
# Node ID 6be49f24b7986ff7e1619032dd99173627f6a52c
# Parent  192cd95c2ba833805c8c762a6da14571eeb663c0
convert: record the source revision in the changelog

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -4,6 +4,9 @@ class NoRepo(Exception): pass
 
 class commit(object):
     def __init__(self, **parts):
+        self.rev = None
+        self.branch = None
+
         for x in "author date desc parents".split():
             if not x in parts:
                 raise util.Abort("commit missing field %s" % x)
diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -80,7 +80,8 @@ class convert_git(converter_source):
         date = tm + " " + str(tz)
         author = author or "unknown"
 
-        c = commit(parents=parents, date=date, author=author, desc=message)
+        c = commit(parents=parents, date=date, author=author, desc=message,
+                   rev = version)
         return c
 
     def gettags(self):
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -54,11 +54,11 @@ class convert_mercurial(converter_sink):
 
         text = commit.desc
         extra = {}
-        try:
-            extra["branch"] = commit.branch
-        except AttributeError:
-            pass
-
+        if commit.branch:
+            extra['branch'] = commit.branch
+        if commit.rev:
+            extra['source_revision'] = commit.rev
+            
         while parents:
             p1 = p2
             p2 = parents.pop(0)
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -484,7 +484,8 @@ class convert_svn(converter_source):
                           desc=log, 
                           parents=parents,
                           copies=copies,
-                          branch=branch)
+                          branch=branch,
+                          rev=rev.encode('utf-8'))
 
             self.commits[rev] = cset
             if self.child_cset and not self.child_cset.parents:


More information about the Mercurial-devel mailing list