author | Matt Mackall <mpm@selenic.com> |
Sat, 15 Oct 2011 12:52:43 -0500 | |
changeset 15268 | bd5103819c2e |
parent 14126 | fbbe9239574a |
child 15615 | 41885892796e |
permissions | -rw-r--r-- |
12119
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
1 |
$ cat >findbranch.py <<EOF |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
2 |
> import re, sys |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
3 |
> |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
4 |
> head_re = re.compile('^#(?:(?:\\s+([A-Za-z][A-Za-z0-9_]*)(?:\\s.*)?)|(?:\\s*))$') |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
5 |
> |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
6 |
> for line in sys.stdin: |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
7 |
> hmatch = head_re.match(line) |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
8 |
> if not hmatch: |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
9 |
> sys.exit(1) |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
10 |
> if hmatch.group(1) == 'Branch': |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
11 |
> sys.exit(0) |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
12 |
> sys.exit(1) |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
13 |
> EOF |
14126
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
14 |
|
12119
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
15 |
$ hg init a |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
16 |
$ cd a |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
17 |
$ echo "Rev 1" >rev |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
18 |
$ hg add rev |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
19 |
$ hg commit -m "No branch." |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
20 |
$ hg branch abranch |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
21 |
marked working directory as branch abranch |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
22 |
$ echo "Rev 2" >rev |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
23 |
$ hg commit -m "With branch." |
14126
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
24 |
|
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
25 |
$ hg export 0 > ../r0.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
26 |
$ hg export 1 > ../r1.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
27 |
$ cd .. |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
28 |
|
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
29 |
$ if python findbranch.py < r0.patch; then |
12119
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
30 |
> echo "Export of default branch revision has Branch header" 1>&2 |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
31 |
> exit 1 |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
32 |
> fi |
14126
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
33 |
|
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
34 |
$ if python findbranch.py < r1.patch; then |
12119
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
35 |
> : # Do nothing |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
36 |
> else |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
37 |
> echo "Export of branch revision is missing Branch header" 1>&2 |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
38 |
> exit 1 |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
39 |
> fi |
4442
871ff96a86cc
Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
40 |
|
12119
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
41 |
Make sure import still works with branch information in patches. |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
42 |
|
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
43 |
$ hg init b |
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
44 |
$ cd b |
14126
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
45 |
$ hg import ../r0.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
46 |
applying ../r0.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
47 |
$ hg import ../r1.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
48 |
applying ../r1.patch |
12119
46ab8c5dd99a
tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
4444
diff
changeset
|
49 |
$ cd .. |
14126
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
50 |
|
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
51 |
$ hg init c |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
52 |
$ cd c |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
53 |
$ hg import --exact ../r0.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
54 |
applying ../r0.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
55 |
$ hg import --exact ../r1.patch |
fbbe9239574a
tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12119
diff
changeset
|
56 |
applying ../r1.patch |