# HG changeset patch # User Richard Quirk # Date 2009-05-01 09:32:19 # Node ID e3d3dad805f9f7c5f17c7a80cd659ecf25238ca1 # Parent 3477ad0b1f2cc1bd812823168dadbab07f67fca7 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 --git a/hgext/convert/git.py b/hgext/convert/git.py --- a/hgext/convert/git.py +++ b/hgext/convert/git.py @@ -90,6 +90,7 @@ class convert_git(converter_source): message = self.recode(message) l = c[:end].splitlines() parents = [] + author = committer = None for e in l[1:]: n, v = e.split(" ", 1) if n == "author": @@ -104,9 +105,10 @@ class convert_git(converter_source): committer = " ".join(p[:-2]) if committer[0] == "<": committer = committer[1:-1] committer = self.recode(committer) - message += "\ncommitter: %s\n" % committer if n == "parent": parents.append(v) + if committer and committer != author: + message += "\ncommitter: %s\n" % committer tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:] tz = -int(tzs) * (int(tzh) * 3600 + int(tzm)) date = tm + " " + str(tz) diff --git a/tests/test-convert-git b/tests/test-convert-git --- a/tests/test-convert-git +++ b/tests/test-convert-git @@ -148,4 +148,22 @@ hg convert git-repo3 git-repo3-hg 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 --git a/tests/test-convert-git.out b/tests/test-convert-git.out --- a/tests/test-convert-git.out +++ b/tests/test-convert-git.out @@ -10,18 +10,16 @@ 3 t3 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 date: Mon Jan 01 00:00:15 2007 +0000 files: a description: Merge branch other -committer: test - % full conversion @ 9 "Discard change to foo" files: foo @@ -98,3 +96,31 @@ converting... 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 +date: Mon Jan 01 00:00:21 2007 +0000 +files: foo +description: +addfoo2 + +committer: test + + +changeset: 0:0735477b0224 +user: test +date: Mon Jan 01 00:00:20 2007 +0000 +files: foo +description: +addfoo + +