[PATCH] Add committer tag only when needed in git conversion

Richard Quirk richard.quirk at gmail.com
Fri May 1 04:38:17 CDT 2009


# HG changeset patch
# User Richard Quirk <richard.quirk at gmail.com>
# Date 1241170339 -7200
# Node ID 33524896bb2ad2bd8fe612883ffde6601102af21
# Parent  52c5be55af82a0bd6401a9c3a61de1357a4345eb
Add committer tag only when needed in git conversion

Convert from a git repo added a committer: tag in the log message
even if the committer and the author were the same person.

diff -r 52c5be55af82 -r 33524896bb2a hgext/convert/git.py
--- a/hgext/convert/git.py	Thu Apr 30 19:22:06 2009 -0500
+++ b/hgext/convert/git.py	Fri May 01 11:32:19 2009 +0200
@@ -104,7 +104,8 @@
                 committer = " ".join(p[:-2])
                 if committer[0] == "<": committer = committer[1:-1]
                 committer = self.recode(committer)
-                message += "\ncommitter: %s\n" % committer
+                if committer != author:
+                    message += "\ncommitter: %s\n" % committer
             if n == "parent": parents.append(v)
 
         tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:]
diff -r 52c5be55af82 -r 33524896bb2a tests/test-convert-git
--- a/tests/test-convert-git	Thu Apr 30 19:22:06 2009 -0500
+++ b/tests/test-convert-git	Fri May 01 11:32:19 2009 +0200
@@ -148,4 +148,22 @@
 cd git-repo3-hg
 hg up -C
 python -c 'print len(file("b", "rb").read())'
+cd ..
 
+echo
+echo '% test author vs committer'
+mkdir git-repo4
+cd git-repo4
+git init-db >/dev/null 2>/dev/null
+echo >> foo
+git add foo
+commit -a -m addfoo
+echo >> foo
+GIT_AUTHOR_NAME="nottest"
+commit -a -m addfoo2
+cd ..
+
+echo '% convert author committer'
+hg convert git-repo4 git-repo4-hg
+cd git-repo4-hg
+hg log -v
diff -r 52c5be55af82 -r 33524896bb2a tests/test-convert-git.out
--- a/tests/test-convert-git.out	Thu Apr 30 19:22:06 2009 -0500
+++ b/tests/test-convert-git.out	Fri May 01 11:32:19 2009 +0200
@@ -10,18 +10,16 @@
 2 t4.1
 1 t4.2
 0 Merge branch other
-changeset:   5:4ab1af49a271
+changeset:   5:c78094926be2
 tag:         tip
-parent:      3:0222ab0998d7
-parent:      4:5333c870e3c2
+parent:      3:f5f5cb45432b
+parent:      4:4e174f80c67c
 user:        test <test at example.org>
 date:        Mon Jan 01 00:00:15 2007 +0000
 files:       a
 description:
 Merge branch other
 
-committer: test <test at example.org>
-
 
 % full conversion
 @    9 "Discard change to foo" files: foo
@@ -98,3 +96,31 @@
 0 addbinary
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 4096
+
+% test author vs committer
+% convert author committer
+initializing destination git-repo4-hg repository
+scanning source...
+sorting...
+converting...
+1 addfoo
+0 addfoo2
+changeset:   1:d63e967f93da
+tag:         tip
+user:        nottest <test at example.org>
+date:        Mon Jan 01 00:00:21 2007 +0000
+files:       foo
+description:
+addfoo2
+
+committer: test <test at example.org>
+
+
+changeset:   0:0735477b0224
+user:        test <test at example.org>
+date:        Mon Jan 01 00:00:20 2007 +0000
+files:       foo
+description:
+addfoo
+
+


More information about the Mercurial-devel mailing list