Mercurial > public > mercurial-scm > hg-stable
diff tests/test-convert-git.t @ 22470:8e0c4df28eec
convert: add support to detect git renames and copies
Git is fairly unique among VCSes in that it doesn't record copies and renames,
instead choosing to detect them on the fly. Since Mercurial expects copies and
renames to be recorded, it can be valuable to preserve this history while
converting a Git repository to Mercurial. This patch adds a new convert option,
called 'convert.git.similarity', which determines how similar files must be to
be treated as renames or copies.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 12 Sep 2014 11:23:26 -0700 |
parents | 3cb0318bb2dd |
children | cc5f94db672b |
line wrap: on
line diff
--- a/tests/test-convert-git.t Thu Sep 11 23:57:49 2014 -0700 +++ b/tests/test-convert-git.t Fri Sep 12 11:23:26 2014 -0700 @@ -241,8 +241,45 @@ 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux +test importing git renames and copies + + $ cd git-repo2 + $ git mv foo foo-renamed +since bar is not touched in this commit, this copy will not be detected + $ cp bar bar-copied + $ cp baz baz-copied + $ cp baz baz-copied2 + $ echo baz2 >> baz + $ git add bar-copied baz-copied baz-copied2 + $ commit -a -m 'rename and copy' + $ cd .. + +input validation + $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo + abort: convert.git.similarity must be a number + [255] + $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo + abort: similarity must be between 0 and 100 + [255] + $ hg convert --config convert.git.similarity=101 --datesort git-repo2 fullrepo + abort: similarity must be between 0 and 100 + [255] + + $ hg -q convert --config convert.git.similarity=100 --datesort git-repo2 fullrepo + $ hg -R fullrepo status -C --change master + M baz + A bar-copied + A baz-copied + baz + A baz-copied2 + baz + A foo-renamed + foo + R foo + test binary conversion (issue1359) + $ count=19 $ mkdir git-repo3 $ cd git-repo3 $ git init-db >/dev/null 2>/dev/null @@ -398,6 +435,29 @@ $ cd ../.. +make sure rename detection doesn't break removing and adding gitmodules + + $ cd git-repo6 + $ git mv .gitmodules .gitmodules-renamed + $ commit -a -m 'rename .gitmodules' + $ git mv .gitmodules-renamed .gitmodules + $ commit -a -m 'rename .gitmodules back' + $ cd .. + + $ hg --config convert.git.similarity=100 convert -q git-repo6 git-repo6-hg + $ hg -R git-repo6-hg log -r 'tip^' -T "{desc|firstline}\n" + rename .gitmodules + $ hg -R git-repo6-hg status -C --change 'tip^' + A .gitmodules-renamed + R .hgsub + R .hgsubstate + $ hg -R git-repo6-hg log -r tip -T "{desc|firstline}\n" + rename .gitmodules back + $ hg -R git-repo6-hg status -C --change tip + A .hgsub + A .hgsubstate + R .gitmodules-renamed + convert the revision removing '.gitmodules' itself (and related submodules)