Debian Codegraph @

tests/test-import-merge.t

raw
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "mq=" >> $HGRCPATH
3
4 $ tipparents() {
5 > hg parents --template "{rev}:{node|short} {desc|firstline}\n" -r tip
6 > }
7
8 Test import and merge diffs
9
10 $ hg init repo
11 $ cd repo
12 $ echo a > a
13 $ hg ci -Am adda
14 adding a
15 $ echo a >> a
16 $ hg ci -m changea
17 $ echo c > c
18 $ hg ci -Am addc
19 adding c
20 $ hg up 0
21 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
22 $ echo b > b
23 $ hg ci -Am addb
24 adding b
25 created new head
26 $ hg up 1
27 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
28 $ hg merge 3
29 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 (branch merge, don't forget to commit)
31 $ hg ci -m merge
32 $ hg export . > ../merge.diff
33 $ grep -v '^merge$' ../merge.diff > ../merge.nomsg.diff
34 $ cd ..
35 $ hg clone -r2 repo repo2
36 adding changesets
37 adding manifests
38 adding file changes
39 added 3 changesets with 3 changes to 2 files
40 new changesets 07f494440405:890ecaa90481
41 updating to branch default
42 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 $ cd repo2
44 $ hg pull -r3 ../repo
45 pulling from ../repo
46 searching for changes
47 adding changesets
48 adding manifests
49 adding file changes
50 added 1 changesets with 1 changes to 1 files (+1 heads)
51 new changesets 102a90ea7b4a
52 (run 'hg heads' to see heads, 'hg merge' to merge)
53
54 Test without --exact and diff.p1 == workingdir.p1
55
56 $ hg up 1
57 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
58 $ cat > $TESTTMP/editor.sh <<EOF
59 > env | grep HGEDITFORM
60 > echo merge > \$1
61 > EOF
62 $ HGEDITOR="sh $TESTTMP/editor.sh" hg import --edit ../merge.nomsg.diff
63 applying ../merge.nomsg.diff
64 HGEDITFORM=import.normal.merge
65 $ tipparents
66 1:540395c44225 changea
67 3:102a90ea7b4a addb
68 $ hg strip --no-backup tip
69 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
70
71 Test without --exact and diff.p1 != workingdir.p1
72
73 $ hg up 2
74 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
75 $ hg import ../merge.diff
76 applying ../merge.diff
77 warning: import the patch as a normal revision
78 (use --exact to import the patch as a merge)
79 $ tipparents
80 2:890ecaa90481 addc
81 $ hg strip --no-backup tip
82 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
83
84 Test with --exact
85
86 $ hg import --exact ../merge.diff
87 applying ../merge.diff
88 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
89 $ tipparents
90 1:540395c44225 changea
91 3:102a90ea7b4a addb
92 $ hg strip --no-backup tip
93 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
94
95 Test with --bypass and diff.p1 == workingdir.p1
96
97 $ hg up 1
98 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 $ hg import --bypass ../merge.diff
100 applying ../merge.diff
101 $ tipparents
102 1:540395c44225 changea
103 3:102a90ea7b4a addb
104 $ hg strip --no-backup tip
105
106 Test with --bypass and diff.p1 != workingdir.p1
107
108 $ hg up 2
109 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 $ hg import --bypass ../merge.diff
111 applying ../merge.diff
112 warning: import the patch as a normal revision
113 (use --exact to import the patch as a merge)
114 $ tipparents
115 2:890ecaa90481 addc
116 $ hg strip --no-backup tip
117
118 Test with --bypass and --exact
119
120 $ hg import --bypass --exact ../merge.diff
121 applying ../merge.diff
122 $ tipparents
123 1:540395c44225 changea
124 3:102a90ea7b4a addb
125 $ hg strip --no-backup tip
126
127 $ cd ..
128
129 Test that --exact on a bad header doesn't corrupt the repo (issue3616)
130
131 $ hg init repo3
132 $ cd repo3
133 $ echo a>a
134 $ hg ci -Aqm0
135 $ echo a>>a
136 $ hg ci -m1
137 $ echo a>>a
138 $ hg ci -m2
139 $ echo a>a
140 $ echo b>>a
141 $ echo a>>a
142 $ hg ci -m3
143 $ hg export 2 | head -7 > ../a.patch
144 $ hg export tip > out
145 >>> apatch = open("../a.patch", "ab")
146 >>> apatch.write(b"".join(open("out", 'rb').readlines()[7:])) and None
147
148 $ cd ..
149 $ hg clone -qr0 repo3 repo3-clone
150 $ cd repo3-clone
151 $ hg pull -qr1 ../repo3
152
153 $ hg import --exact ../a.patch
154 applying ../a.patch
155 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
156 patching file a
157 Hunk #1 succeeded at 1 with fuzz 1 (offset -1 lines).
158 transaction abort!
159 rollback completed
160 abort: patch is damaged or loses information
161 [255]
162 $ hg verify -q