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.
This commit is contained in:
Richard Quirk 2009-05-01 11:32:19 +02:00
parent c620d68ecc
commit 1652c239fa
3 changed files with 52 additions and 6 deletions

View File

@ -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)

View File

@ -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

View File

@ -10,18 +10,16 @@ converting...
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@example.org>
date: Mon Jan 01 00:00:15 2007 +0000
files: a
description:
Merge branch other
committer: test <test@example.org>
% 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 <test@example.org>
date: Mon Jan 01 00:00:21 2007 +0000
files: foo
description:
addfoo2
committer: test <test@example.org>
changeset: 0:0735477b0224
user: test <test@example.org>
date: Mon Jan 01 00:00:20 2007 +0000
files: foo
description:
addfoo