Debian Codegraph @

tests/test-impexp-branch.t

raw
1 $ echo '[extensions]' >> $HGRCPATH
2 $ echo 'strip =' >> $HGRCPATH
3
4 $ cat >findbranch.py <<EOF
5 > import re
6 > import sys
7 >
8 > head_re = re.compile(r'^#(?:(?:\\s+([A-Za-z][A-Za-z0-9_]*)(?:\\s.*)?)|(?:\\s*))$')
9 >
10 > for line in sys.stdin:
11 > hmatch = head_re.match(line)
12 > if not hmatch:
13 > sys.exit(1)
14 > if hmatch.group(1) == 'Branch':
15 > sys.exit(0)
16 > sys.exit(1)
17 > EOF
18
19 $ hg init a
20 $ cd a
21 $ echo "Rev 1" >rev
22 $ hg add rev
23 $ hg commit -m "No branch."
24 $ hg branch abranch
25 marked working directory as branch abranch
26 (branches are permanent and global, did you want a bookmark?)
27 $ echo "Rev 2" >rev
28 $ hg commit -m "With branch."
29
30 $ hg export 0 > ../r0.patch
31 $ hg export 1 > ../r1.patch
32 $ cd ..
33
34 $ if "$PYTHON" findbranch.py < r0.patch; then
35 > echo "Export of default branch revision has Branch header" 1>&2
36 > exit 1
37 > fi
38
39 $ if "$PYTHON" findbranch.py < r1.patch; then
40 > : # Do nothing
41 > else
42 > echo "Export of branch revision is missing Branch header" 1>&2
43 > exit 1
44 > fi
45
46 Make sure import still works with branch information in patches.
47
48 $ hg init b
49 $ cd b
50 $ hg import ../r0.patch
51 applying ../r0.patch
52 $ hg import ../r1.patch
53 applying ../r1.patch
54 $ cd ..
55
56 $ hg init c
57 $ cd c
58 $ hg import --exact --no-commit ../r0.patch
59 applying ../r0.patch
60 warning: can't check exact import with --no-commit
61 $ hg st
62 A rev
63 $ hg revert -a
64 forgetting rev
65 $ rm rev
66 $ hg import --exact ../r0.patch
67 applying ../r0.patch
68 $ hg import --exact ../r1.patch
69 applying ../r1.patch
70
71 Test --exact and patch header separators (issue3356)
72
73 $ hg strip --no-backup .
74 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
75 >>> import re
76 >>> p = open('../r1.patch', 'rb').read()
77 >>> p = re.sub(br'Parent\s+', b'Parent ', p)
78 >>> open('../r1-ws.patch', 'wb').write(p) and None
79 $ hg import --exact ../r1-ws.patch
80 applying ../r1-ws.patch
81
82 $ cd ..