Mercurial > hg > mercurial-crew-with-dirclash
view tests/test-git-import @ 5192:33015dac5df5
convert: fix mercurial_sink.putcommit
Changeset 4ebc8693ce72 added some code to putcommit to avoid creating a
revision that touches no files, but this can break regular conversions
from some repositories:
- conceptually, since we're converting a repo, we should try to make
the new hg repo as similar as possible to the original repo - we
should create a new changeset, even if the original revision didn't
touch any files (maybe the commit message had some important bit);
- even if a "regular" revision that doesn't touch any file may seem
weird (and maybe even broken), it's completely legitimate for a merge
revision to not touch any file, and, if we just skip it, the
converted repo will end up with wrong history and possibly an extra
head.
As an example, say the crew and main hg repos are sync'ed. Somebody
sends an important patch to the mailing list. Matt quickly applies
and pushes it. But at the same time somebody also applies it to crew
and pushes it. Suppose the commit message ended up being a bit
different (say, there was a typo and somebody didn't fix it) or that
the date ended up being different (because of different patch-applying
scripts): the changeset hashes will be different, but the manifests
will be the same.
Since both changesets were pushed to public repos, it's hard to recall
them. If both are merged, the manifest from the resulting merge
revision will have the exact same contents as its parents - i.e. the
merge revision really doesn't touch any file at all.
To keep the file filtering stuff "working", the generic code was changed
to skip empty revisions if we're filtering the repo, fixing a bug in the
process (we want parents[0] instead of tip).
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Fri, 17 Aug 2007 20:18:05 -0300 |
parents | 4cd52978e188 |
children | 477136fa6571 |
line wrap: on
line source
#!/bin/sh hg init a cd a echo % new file hg import -mnew - <<EOF diff --git a/new b/new new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/new @@ -0,0 +1 @@ +a EOF echo % new empty file hg import -mempty - <<EOF diff --git a/empty b/empty new file mode 100644 EOF hg locate empty echo % chmod +x hg import -msetx - <<EOF diff --git a/new b/new old mode 100644 new mode 100755 EOF test -x new || echo failed echo % copy hg import -mcopy - <<EOF diff --git a/new b/copy old mode 100755 new mode 100644 similarity index 100% copy from new copy to copy diff --git a/new b/copyx similarity index 100% copy from new copy to copyx EOF if "$TESTDIR/hghave" -q execbit; then test -f copy -a ! -x copy || echo failed test -x copyx || echo failed else test -f copy || echo failed fi cat copy hg cat copy echo % rename hg import -mrename - <<EOF diff --git a/copy b/rename similarity index 100% rename from copy rename to rename EOF hg locate echo % delete hg import -mdelete - <<EOF diff --git a/copyx b/copyx deleted file mode 100755 index 7898192..0000000 --- a/copyx +++ /dev/null @@ -1 +0,0 @@ -a EOF hg locate test -f copyx && echo failed || true echo % regular diff hg import -mregular - <<EOF diff --git a/rename b/rename index 7898192..72e1fe3 100644 --- a/rename +++ b/rename @@ -1 +1,5 @@ a +a +a +a +a EOF echo % copy and modify hg import -mcopymod - <<EOF diff --git a/rename b/copy2 similarity index 80% copy from rename copy to copy2 index 72e1fe3..b53c148 100644 --- a/rename +++ b/copy2 @@ -1,5 +1,5 @@ a a -a +b a a EOF hg cat copy2 echo % rename and modify hg import -mrenamemod - <<EOF diff --git a/copy2 b/rename2 similarity index 80% rename from copy2 rename to rename2 index b53c148..8f81e29 100644 --- a/copy2 +++ b/rename2 @@ -1,5 +1,5 @@ a a b -a +c a EOF hg locate copy2 hg cat rename2 echo % one file renamed multiple times hg import -mmultirenames - <<EOF diff --git a/rename2 b/rename3 rename from rename2 rename to rename3 diff --git a/rename2 b/rename3-2 rename from rename2 rename to rename3-2 EOF hg log -vCr. --template '{rev} {files} / {file_copies%filecopy}\n' hg locate rename2 rename3 rename3-2 hg cat rename3 echo hg cat rename3-2 echo foo > foo hg add foo hg ci -m 'add foo' echo % binary files and regular patch hunks hg import -m binaryregular - <<EOF diff --git a/binary b/binary new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 Lc\${NkU|;|M00aO5 diff --git a/foo b/foo2 rename from foo rename to foo2 EOF cat foo2 hg manifest --debug | grep binary echo % many binary files hg import -m multibinary - <<EOF diff --git a/mbinary1 b/mbinary1 new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 Lc\${NkU|;|M00aO5 diff --git a/mbinary2 b/mbinary2 new file mode 100644 index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490 GIT binary patch literal 5 Mc\${NkU|\`?^000jF3jhEB EOF hg manifest --debug | grep mbinary echo % filenames with spaces hg import -m spaces - <<EOF diff --git a/foo bar b/foo bar new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/foo bar @@ -0,0 +1 @@ +foo EOF cat "foo bar"