Mercurial > hg
annotate tests/test-impexp-branch @ 5378:8a2915f57dfc
convert: add a mode where mercurial_sink skips empty revisions.
The getchanges function of some converter_source classes can return
some false positives. I.e. they sometimes claim that a file "foo"
was changed in some revision, even though its contents are still the
same.
convert_svn is particularly bad, but I think this can also happen with
convert_cvs and, at least in theory, with mercurial_source.
For regular conversions this is not really a problem - as long as
getfile returns the right contents, we'll get a converted revision
with the right contents. But when we use --filemap, this could lead
to superfluous revisions being converted.
Instead of fixing every converter_source, I decided to change
mercurial_sink to work around this problem.
When --filemap is used, we're interested only in revisions that touch
some specific files. If a revision doesn't change any of these files,
then we're not interested in it (at least for revisions with a single
parent; merges are special).
For mercurial_sink, we abuse this property and rollback a commit if
the manifest text hasn't changed. This avoids duplicating the logic
from localrepo.filecommit to detect unchanged files.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Thu, 04 Oct 2007 23:21:37 -0300 |
parents | 32ea809e5bd1 |
children |
rev | line source |
---|---|
4442
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
1 #!/bin/sh |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
2 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
3 cat >findbranch.py <<EOF |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
4 import re, sys |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
5 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
6 head_re = re.compile('^#(?:(?:\\s+([A-Za-z][A-Za-z0-9_]*)(?:\\s.*)?)|(?:\\s*))$') |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
7 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
8 for line in sys.stdin: |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
9 hmatch = head_re.match(line) |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
10 if not hmatch: |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
11 sys.exit(1) |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
12 if hmatch.group(1) == 'Branch': |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
13 sys.exit(0) |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
14 sys.exit(1) |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
15 EOF |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
16 hg init a |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
17 cd a |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
18 echo "Rev 1" >rev |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
19 hg add rev |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
20 hg commit -m "No branch." |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
21 hg branch abranch |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
22 echo "Rev 2" >rev |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
23 hg commit -m "With branch." |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
24 if hg export 0 | python ../findbranch.py; then |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
25 echo "Export of default branch revision has Branch header" 1>&2 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
26 exit 1 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
27 fi |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
28 if hg export 1 | python ../findbranch.py; then |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
29 : # Do nothing |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
30 else |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
31 echo "Export of branch revision is missing Branch header" 1>&2 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
32 exit 1 |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
33 fi |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
34 # Make sure import still works with branch information in patches. |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
35 cd .. |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
36 hg init b |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
37 cd b |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
38 hg -R ../a export 0 | hg import - |
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
39 hg -R ../a export 1 | hg import - |
4444
32ea809e5bd1
Alter test to test import --exact to make sure it works with branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4442
diff
changeset
|
40 cd .. |
32ea809e5bd1
Alter test to test import --exact to make sure it works with branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4442
diff
changeset
|
41 rm -rf b |
32ea809e5bd1
Alter test to test import --exact to make sure it works with branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4442
diff
changeset
|
42 hg init b |
32ea809e5bd1
Alter test to test import --exact to make sure it works with branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4442
diff
changeset
|
43 cd b |
32ea809e5bd1
Alter test to test import --exact to make sure it works with branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4442
diff
changeset
|
44 hg -R ../a export 0 | hg import --exact - |
32ea809e5bd1
Alter test to test import --exact to make sure it works with branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4442
diff
changeset
|
45 hg -R ../a export 1 | hg import --exact - |