Debian Codegraph @

tests/test-patch.t

raw
1 $ cat > patchtool.py <<EOF
2 > import sys
3 > print('Using custom patch')
4 > if '--binary' in sys.argv:
5 > print('--binary found !')
6 > EOF
7
8 $ echo "[ui]" >> $HGRCPATH
9 $ echo "patch=\"$PYTHON\" ../patchtool.py" >> $HGRCPATH
10
11 $ hg init a
12 $ cd a
13 $ echo a > a
14 $ hg commit -Ama -d '1 0'
15 adding a
16 $ echo b >> a
17 $ hg commit -Amb -d '2 0'
18 $ cd ..
19
20 This test checks that:
21 - custom patch commands with arguments actually work
22 - patch code does not try to add weird arguments like
23 --binary when custom patch commands are used. For instance
24 --binary is added by default under win32.
25
26 check custom patch options are honored
27
28 $ hg --cwd a export -o ../a.diff tip
29 $ hg clone -r 0 a b
30 adding changesets
31 adding manifests
32 adding file changes
33 added 1 changesets with 1 changes to 1 files
34 new changesets 8580ff50825a
35 updating to branch default
36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37
38 $ hg --cwd b import -v ../a.diff
39 applying ../a.diff
40 Using custom patch
41 applied to working directory
42
43 Issue2417: hg import with # comments in description
44
45 Prepare source repo and patch:
46
47 $ rm $HGRCPATH
48 $ hg init c
49 $ cd c
50 $ printf "a\rc" > a
51 $ hg ci -A -m 0 a -d '0 0'
52 $ printf "a\rb\rc" > a
53 $ cat << eof > log
54 > first line which can't start with '# '
55 > # second line is a comment but that shouldn't be a problem.
56 > A patch marker like this was more problematic even after d7452292f9d3:
57 > # HG changeset patch
58 > # User lines looks like this - but it _is_ just a comment
59 > eof
60 $ hg ci -l log -d '0 0'
61 $ hg export -o p 1
62 $ cd ..
63
64 Clone and apply patch:
65
66 $ hg clone -r 0 c d
67 adding changesets
68 adding manifests
69 adding file changes
70 added 1 changesets with 1 changes to 1 files
71 new changesets 7fadb901d403
72 updating to branch default
73 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
74 $ cd d
75 $ hg import ../c/p
76 applying ../c/p
77 $ hg log -v -r 1
78 changeset: 1:cd0bde79c428
79 tag: tip
80 user: test
81 date: Thu Jan 01 00:00:00 1970 +0000
82 files: a
83 description:
84 first line which can't start with '# '
85 # second line is a comment but that shouldn't be a problem.
86 A patch marker like this was more problematic even after d7452292f9d3:
87 # HG changeset patch
88 # User lines looks like this - but it _is_ just a comment
89
90
91
92 Error exit (issue4746)
93
94 $ cat >> exit1.py <<EOF
95 > import sys
96 > sys.exit(1)
97 > EOF
98
99 $ hg import ../c/p --config ui.patch="\"$PYTHON\" \"`pwd`/exit1.py\""
100 applying ../c/p
101 abort: patch command failed: exited with status 1
102 [255]
103
104 $ cd ..