Show More
@@ -1,239 +1,239 | |||
|
1 | 1 | test that a commit clears the merge state. |
|
2 | 2 | |
|
3 | 3 | $ hg init repo |
|
4 | 4 | $ cd repo |
|
5 | 5 | |
|
6 | 6 | $ echo foo > file1 |
|
7 | 7 | $ echo foo > file2 |
|
8 | 8 | $ hg commit -Am 'add files' |
|
9 | 9 | adding file1 |
|
10 | 10 | adding file2 |
|
11 | 11 | |
|
12 | 12 | $ echo bar >> file1 |
|
13 | 13 | $ echo bar >> file2 |
|
14 | 14 | $ hg commit -Am 'append bar to files' |
|
15 | 15 | |
|
16 | 16 | create a second head with conflicting edits |
|
17 | 17 | |
|
18 | 18 | $ hg up -C 0 |
|
19 | 19 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
20 | 20 | $ echo baz >> file1 |
|
21 | 21 | $ echo baz >> file2 |
|
22 | 22 | $ hg commit -Am 'append baz to files' |
|
23 | 23 | created new head |
|
24 | 24 | |
|
25 | 25 | create a third head with no conflicting edits |
|
26 | 26 | $ hg up -qC 0 |
|
27 | 27 | $ echo foo > file3 |
|
28 | 28 | $ hg commit -Am 'add non-conflicting file' |
|
29 | 29 | adding file3 |
|
30 | 30 | created new head |
|
31 | 31 | |
|
32 | 32 | failing merge |
|
33 | 33 | |
|
34 | 34 | $ hg up -qC 2 |
|
35 | 35 | $ hg merge --tool=internal:fail 1 |
|
36 | 36 | 0 files updated, 0 files merged, 0 files removed, 2 files unresolved |
|
37 | 37 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
38 | 38 | [1] |
|
39 | 39 | |
|
40 | 40 | resolve -l should contain unresolved entries |
|
41 | 41 | |
|
42 | 42 | $ hg resolve -l |
|
43 | 43 | U file1 |
|
44 | 44 | U file2 |
|
45 | 45 | |
|
46 | 46 | $ hg resolve -l --no-status |
|
47 | 47 | file1 |
|
48 | 48 | file2 |
|
49 | 49 | |
|
50 | 50 | resolving an unknown path should emit a warning, but not for -l |
|
51 | 51 | |
|
52 | 52 | $ hg resolve -m does-not-exist |
|
53 | 53 | arguments do not match paths that need resolving |
|
54 | 54 | $ hg resolve -l does-not-exist |
|
55 | 55 | |
|
56 | 56 | don't allow marking or unmarking driver-resolved files |
|
57 | 57 | |
|
58 | 58 | $ cat > $TESTTMP/markdriver.py << EOF |
|
59 | 59 | > '''mark and unmark files as driver-resolved''' |
|
60 | 60 | > from mercurial import cmdutil, merge, scmutil |
|
61 | 61 | > cmdtable = {} |
|
62 | 62 | > command = cmdutil.command(cmdtable) |
|
63 | 63 | > @command('markdriver', |
|
64 | 64 | > [('u', 'unmark', None, '')], |
|
65 | 65 | > 'FILE...') |
|
66 | 66 | > def markdriver(ui, repo, *pats, **opts): |
|
67 | 67 | > wlock = repo.wlock() |
|
68 | 68 | > try: |
|
69 | > ms = merge.mergestate(repo) | |
|
69 | > ms = merge.mergestate.read(repo) | |
|
70 | 70 | > m = scmutil.match(repo[None], pats, opts) |
|
71 | 71 | > for f in ms: |
|
72 | 72 | > if not m(f): |
|
73 | 73 | > continue |
|
74 | 74 | > if not opts['unmark']: |
|
75 | 75 | > ms.mark(f, 'd') |
|
76 | 76 | > else: |
|
77 | 77 | > ms.mark(f, 'u') |
|
78 | 78 | > ms.commit() |
|
79 | 79 | > finally: |
|
80 | 80 | > wlock.release() |
|
81 | 81 | > EOF |
|
82 | 82 | $ hg --config extensions.markdriver=$TESTTMP/markdriver.py markdriver file1 |
|
83 | 83 | $ hg resolve --list |
|
84 | 84 | D file1 |
|
85 | 85 | U file2 |
|
86 | 86 | $ hg resolve --mark file1 |
|
87 | 87 | not marking file1 as it is driver-resolved |
|
88 | 88 | this should not print out file1 |
|
89 | 89 | $ hg resolve --mark --all |
|
90 | 90 | (no more unresolved files -- run "hg resolve --all" to conclude) |
|
91 | 91 | $ hg resolve --mark 'glob:file*' |
|
92 | 92 | (no more unresolved files -- run "hg resolve --all" to conclude) |
|
93 | 93 | $ hg resolve --list |
|
94 | 94 | D file1 |
|
95 | 95 | R file2 |
|
96 | 96 | $ hg resolve --unmark file1 |
|
97 | 97 | not unmarking file1 as it is driver-resolved |
|
98 | 98 | (no more unresolved files -- run "hg resolve --all" to conclude) |
|
99 | 99 | $ hg resolve --unmark --all |
|
100 | 100 | $ hg resolve --list |
|
101 | 101 | D file1 |
|
102 | 102 | U file2 |
|
103 | 103 | $ hg --config extensions.markdriver=$TESTTMP/markdriver.py markdriver --unmark file1 |
|
104 | 104 | $ hg resolve --list |
|
105 | 105 | U file1 |
|
106 | 106 | U file2 |
|
107 | 107 | |
|
108 | 108 | resolve the failure |
|
109 | 109 | |
|
110 | 110 | $ echo resolved > file1 |
|
111 | 111 | $ hg resolve -m file1 |
|
112 | 112 | |
|
113 | 113 | resolve -l should show resolved file as resolved |
|
114 | 114 | |
|
115 | 115 | $ hg resolve -l |
|
116 | 116 | R file1 |
|
117 | 117 | U file2 |
|
118 | 118 | |
|
119 | 119 | $ hg resolve -l -Tjson |
|
120 | 120 | [ |
|
121 | 121 | { |
|
122 | 122 | "path": "file1", |
|
123 | 123 | "status": "R" |
|
124 | 124 | }, |
|
125 | 125 | { |
|
126 | 126 | "path": "file2", |
|
127 | 127 | "status": "U" |
|
128 | 128 | } |
|
129 | 129 | ] |
|
130 | 130 | |
|
131 | 131 | resolve -m without paths should mark all resolved |
|
132 | 132 | |
|
133 | 133 | $ hg resolve -m |
|
134 | 134 | (no more unresolved files) |
|
135 | 135 | $ hg commit -m 'resolved' |
|
136 | 136 | |
|
137 | 137 | resolve -l should be empty after commit |
|
138 | 138 | |
|
139 | 139 | $ hg resolve -l |
|
140 | 140 | |
|
141 | 141 | $ hg resolve -l -Tjson |
|
142 | 142 | [ |
|
143 | 143 | ] |
|
144 | 144 | |
|
145 | 145 | resolve --all should abort when no merge in progress |
|
146 | 146 | |
|
147 | 147 | $ hg resolve --all |
|
148 | 148 | abort: resolve command not applicable when not merging |
|
149 | 149 | [255] |
|
150 | 150 | |
|
151 | 151 | resolve -m should abort when no merge in progress |
|
152 | 152 | |
|
153 | 153 | $ hg resolve -m |
|
154 | 154 | abort: resolve command not applicable when not merging |
|
155 | 155 | [255] |
|
156 | 156 | |
|
157 | 157 | set up conflict-free merge |
|
158 | 158 | |
|
159 | 159 | $ hg up -qC 3 |
|
160 | 160 | $ hg merge 1 |
|
161 | 161 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
162 | 162 | (branch merge, don't forget to commit) |
|
163 | 163 | |
|
164 | 164 | resolve --all should do nothing in merge without conflicts |
|
165 | 165 | $ hg resolve --all |
|
166 | 166 | (no more unresolved files) |
|
167 | 167 | |
|
168 | 168 | resolve -m should do nothing in merge without conflicts |
|
169 | 169 | |
|
170 | 170 | $ hg resolve -m |
|
171 | 171 | (no more unresolved files) |
|
172 | 172 | |
|
173 | 173 | get back to conflicting state |
|
174 | 174 | |
|
175 | 175 | $ hg up -qC 2 |
|
176 | 176 | $ hg merge --tool=internal:fail 1 |
|
177 | 177 | 0 files updated, 0 files merged, 0 files removed, 2 files unresolved |
|
178 | 178 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
179 | 179 | [1] |
|
180 | 180 | |
|
181 | 181 | resolve without arguments should suggest --all |
|
182 | 182 | $ hg resolve |
|
183 | 183 | abort: no files or directories specified |
|
184 | 184 | (use --all to re-merge all unresolved files) |
|
185 | 185 | [255] |
|
186 | 186 | |
|
187 | 187 | resolve --all should re-merge all unresolved files |
|
188 | 188 | $ hg resolve --all |
|
189 | 189 | merging file1 |
|
190 | 190 | merging file2 |
|
191 | 191 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
192 | 192 | warning: conflicts while merging file2! (edit, then use 'hg resolve --mark') |
|
193 | 193 | [1] |
|
194 | 194 | $ cat file1.orig |
|
195 | 195 | foo |
|
196 | 196 | baz |
|
197 | 197 | $ cat file2.orig |
|
198 | 198 | foo |
|
199 | 199 | baz |
|
200 | 200 | |
|
201 | 201 | .orig files should exists where specified |
|
202 | 202 | $ hg resolve --all --verbose --config 'ui.origbackuppath=.hg/origbackups' |
|
203 | 203 | merging file1 |
|
204 | 204 | creating directory: $TESTTMP/repo/.hg/origbackups (glob) |
|
205 | 205 | merging file2 |
|
206 | 206 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
207 | 207 | warning: conflicts while merging file2! (edit, then use 'hg resolve --mark') |
|
208 | 208 | [1] |
|
209 | 209 | $ ls .hg/origbackups |
|
210 | 210 | file1.orig |
|
211 | 211 | file2.orig |
|
212 | 212 | $ grep '<<<' file1 > /dev/null |
|
213 | 213 | $ grep '<<<' file2 > /dev/null |
|
214 | 214 | |
|
215 | 215 | resolve <file> should re-merge file |
|
216 | 216 | $ echo resolved > file1 |
|
217 | 217 | $ hg resolve -q file1 |
|
218 | 218 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
219 | 219 | [1] |
|
220 | 220 | $ grep '<<<' file1 > /dev/null |
|
221 | 221 | |
|
222 | 222 | resolve <file> should do nothing if 'file' was marked resolved |
|
223 | 223 | $ echo resolved > file1 |
|
224 | 224 | $ hg resolve -m file1 |
|
225 | 225 | $ hg resolve -q file1 |
|
226 | 226 | $ cat file1 |
|
227 | 227 | resolved |
|
228 | 228 | |
|
229 | 229 | test crashed merge with empty mergestate |
|
230 | 230 | |
|
231 | 231 | $ hg up -qC 1 |
|
232 | 232 | $ mkdir .hg/merge |
|
233 | 233 | $ touch .hg/merge/state |
|
234 | 234 | |
|
235 | 235 | resolve -l should be empty |
|
236 | 236 | |
|
237 | 237 | $ hg resolve -l |
|
238 | 238 | |
|
239 | 239 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now