Mercurial > hg-stable
changeset 5380:a5a7f7fd5554
convert_git: add --filemap support
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Thu, 04 Oct 2007 23:21:37 -0300 |
parents | d3e51dc804f8 |
children | 6874368120dc |
files | hgext/convert/git.py tests/test-convert-git tests/test-convert-git.out |
diffstat | 3 files changed, 159 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/git.py Thu Oct 04 23:21:37 2007 -0300 +++ b/hgext/convert/git.py Thu Oct 04 23:21:37 2007 -0300 @@ -122,3 +122,21 @@ tags[tag] = node return tags + + def getchangedfiles(self, version, i): + changes = [] + if i is None: + fh = self.gitcmd("git-diff-tree --root -m -r %s" % version) + for l in fh: + if "\t" not in l: + continue + m, f = l[:-1].split("\t") + changes.append(f) + fh.close() + else: + fh = self.gitcmd("git-diff-tree --name-only --root -r %s %s^%s --" + % (version, version, i+1)) + changes = [f.rstrip('\n') for f in fh] + fh.close() + + return changes
--- a/tests/test-convert-git Thu Oct 04 23:21:37 2007 -0300 +++ b/tests/test-convert-git Thu Oct 04 23:21:37 2007 -0300 @@ -4,6 +4,7 @@ echo "[extensions]" >> $HGRCPATH echo "convert=" >> $HGRCPATH +echo 'hgext.graphlog =' >> $HGRCPATH GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL @@ -54,3 +55,78 @@ hg convert --datesort git-repo hg -R git-repo-hg tip -v + +count=10 +mkdir git-repo2 +cd git-repo2 +git init-db >/dev/null 2>/dev/null + +echo foo > foo +git add foo +commit -a -m 'add foo' + +echo >> foo +commit -a -m 'change foo' + +git checkout -b Bar HEAD^ >/dev/null 2>/dev/null +echo quux >> quux +git add quux +commit -a -m 'add quux' + +echo bar > bar +git add bar +commit -a -m 'add bar' + +git checkout -b Baz HEAD^ >/dev/null 2>/dev/null +echo baz > baz +git add baz +commit -a -m 'add baz' + +git checkout master >/dev/null 2>/dev/null +git pull --no-commit . Bar Baz > /dev/null 2>/dev/null +commit -m 'Octopus merge' + +echo bar >> bar +commit -a -m 'change bar' + +git checkout -b Foo HEAD^ >/dev/null 2>/dev/null +echo >> foo +commit -a -m 'change foo' + +git checkout master >/dev/null 2>/dev/null +git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null +commit -m 'Discard change to foo' + +cd .. + +glog() +{ + hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@" +} + +splitrepo() +{ + msg="$1" + files="$2" + opts=$3 + echo "% $files: $msg" + prefix=`echo "$files" | sed -e 's/ /-/g'` + fmap="$prefix.fmap" + repo="$prefix.repo" + for i in $files; do + echo "include $i" >> "$fmap" + done + hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo" + glog -R "$repo" + hg -R "$repo" manifest --debug +} + +echo '% full conversion' +hg -q convert --datesort git-repo2 fullrepo +glog -R fullrepo +hg -R fullrepo manifest --debug + +splitrepo 'octopus merge' 'foo bar baz' + +splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' +
--- a/tests/test-convert-git.out Thu Oct 04 23:21:37 2007 -0300 +++ b/tests/test-convert-git.out Thu Oct 04 23:21:37 2007 -0300 @@ -23,3 +23,68 @@ committer: test <test@example.org> +% full conversion +o 9 "Discard change to foo" files: foo +|\ +| o 8 "change foo" files: foo +| | +o | 7 "change bar" files: bar +|/ +o 6 "(octopus merge fixup)" files: +|\ +| o 5 "Octopus merge" files: baz +| |\ +o | | 4 "add baz" files: baz +| | | ++---o 3 "add bar" files: bar +| | +o | 2 "add quux" files: quux +| | +| o 1 "change foo" files: foo +|/ +o 0 "add foo" files: foo + +245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar +354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz +9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo +88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux +% foo bar baz: octopus merge +o 8 "Discard change to foo" files: foo +|\ +| o 7 "change foo" files: foo +| | +o | 6 "change bar" files: bar +|/ +o 5 "(octopus merge fixup)" files: +|\ +| o 4 "Octopus merge" files: baz +| |\ +o | | 3 "add baz" files: baz +| | | ++---o 2 "add bar" files: bar +| | +| o 1 "change foo" files: foo +|/ +o 0 "add foo" files: foo + +245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar +354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz +9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo +% foo baz quux: only some parents of an octopus merge; "discard" a head +o 6 "Discard change to foo" files: foo +| +o 5 "change foo" files: foo +| +o 4 "Octopus merge" files: +|\ +| o 3 "add baz" files: baz +| | +| o 2 "add quux" files: quux +| | +o | 1 "change foo" files: foo +|/ +o 0 "add foo" files: foo + +354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz +9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo +88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux