##// END OF EJS Templates
diff: add experimental support for "merge diffs"...
Augie Fackler -
r47177:1a7d12c8 default
parent child Browse files
Show More
@@ -29,6 +29,7 b' from . import ('
29 bundlecaches,
29 bundlecaches,
30 changegroup,
30 changegroup,
31 cmdutil,
31 cmdutil,
32 context as contextmod,
32 copies,
33 copies,
33 debugcommands as debugcommandsmod,
34 debugcommands as debugcommandsmod,
34 destutil,
35 destutil,
@@ -2464,6 +2465,16 b" def debugcomplete(ui, cmd=b'', **opts):"
2464 (b'', b'from', b'', _(b'revision to diff from'), _(b'REV1')),
2465 (b'', b'from', b'', _(b'revision to diff from'), _(b'REV1')),
2465 (b'', b'to', b'', _(b'revision to diff to'), _(b'REV2')),
2466 (b'', b'to', b'', _(b'revision to diff to'), _(b'REV2')),
2466 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2467 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2468 (
2469 b'',
2470 b'merge',
2471 False,
2472 _(
2473 b'show difference between auto-merge and committed '
2474 b'merge for merge commits (EXPERIMENTAL)'
2475 ),
2476 _(b'REV'),
2477 ),
2467 ]
2478 ]
2468 + diffopts
2479 + diffopts
2469 + diffopts2
2480 + diffopts2
@@ -2544,13 +2555,31 b' def diff(ui, repo, *pats, **opts):'
2544 to_rev = opts.get(b'to')
2555 to_rev = opts.get(b'to')
2545 stat = opts.get(b'stat')
2556 stat = opts.get(b'stat')
2546 reverse = opts.get(b'reverse')
2557 reverse = opts.get(b'reverse')
2558 diffmerge = opts.get(b'merge')
2547
2559
2548 cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
2560 cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
2549 cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
2561 cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
2550 if change:
2562 if change:
2551 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2563 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2552 ctx2 = scmutil.revsingle(repo, change, None)
2564 ctx2 = scmutil.revsingle(repo, change, None)
2553 ctx1 = ctx2.p1()
2565 if diffmerge and ctx2.p2().node() != nullid:
2566 pctx1 = ctx2.p1()
2567 pctx2 = ctx2.p2()
2568 wctx = contextmod.overlayworkingctx(repo)
2569 wctx.setbase(pctx1)
2570 with ui.configoverride(
2571 {
2572 (
2573 b'ui',
2574 b'forcemerge',
2575 ): b'internal:merge3-lie-about-conflicts',
2576 },
2577 b'diff --merge',
2578 ):
2579 mergemod.merge(pctx2, wc=wctx)
2580 ctx1 = wctx
2581 else:
2582 ctx1 = ctx2.p1()
2554 elif from_rev or to_rev:
2583 elif from_rev or to_rev:
2555 repo = scmutil.unhidehashlikerevs(
2584 repo = scmutil.unhidehashlikerevs(
2556 repo, [from_rev] + [to_rev], b'nowarn'
2585 repo, [from_rev] + [to_rev], b'nowarn'
@@ -336,7 +336,7 b' Show all commands + options'
336 debugwhyunstable:
336 debugwhyunstable:
337 debugwireargs: three, four, five, ssh, remotecmd, insecure
337 debugwireargs: three, four, five, ssh, remotecmd, insecure
338 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
338 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
339 diff: rev, from, to, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
339 diff: rev, from, to, change, merge, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
340 export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
340 export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
341 files: rev, print0, include, exclude, template, subrepos
341 files: rev, print0, include, exclude, template, subrepos
342 forget: interactive, include, exclude, dry-run
342 forget: interactive, include, exclude, dry-run
@@ -194,4 +194,108 b" must be similar to 'hg diff --change 5':"
194 9
194 9
195 10
195 10
196
196
197 merge diff should show only manual edits to a merge:
198
199 $ hg diff --merge -c 6
200 merging file.txt
201 (no diff output is expected here)
202
203 Construct an "evil merge" that does something other than just the merge.
204
205 $ hg co ".^"
206 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
207 $ hg merge -r 5
208 merging file.txt
209 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
210 (branch merge, don't forget to commit)
211 $ echo 11 >> file.txt
212 $ hg ci -m 'merge 8 to y with manual edit of 11' # 7
213 created new head
214 $ hg diff -c 7
215 diff -r 273b50f17c6d -r 8ad85e839ba7 file.txt
216 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
217 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
218 @@ -6,6 +6,7 @@
219 5
220 6
221 7
222 -8
223 +y
224 9
225 10
226 +11
227 Contrast with the `hg diff -c 7` version above: only the manual edit shows
228 up, making it easy to identify changes someone is otherwise trying to sneak
229 into a merge.
230 $ hg diff --merge -c 7
231 merging file.txt
232 diff -r 8ad85e839ba7 file.txt
233 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
234 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
235 @@ -9,3 +9,4 @@
236 y
237 9
238 10
239 +11
240
241 Set up a conflict.
242 $ hg co ".^"
243 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
244 $ sed -e 's,^8$,z,' file.txt > file.txt.tmp
245 $ mv file.txt.tmp file.txt
246 $ hg ci -m 'conflicting edit: 8 to z'
247 created new head
248 $ echo "this file is new in p1 of the merge" > new-file-p1.txt
249 $ hg ci -Am 'new file' new-file-p1.txt
250 $ hg log -r . --template 'p1 will be rev {rev}\n'
251 p1 will be rev 9
252 $ hg co 5
253 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
254 $ echo "this file is new in p2 of the merge" > new-file-p2.txt
255 $ hg ci -Am 'new file' new-file-p2.txt
256 created new head
257 $ hg log -r . --template 'p2 will be rev {rev}\n'
258 p2 will be rev 10
259 $ hg co -- 9
260 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
261 $ hg merge -r 10
262 merging file.txt
263 warning: conflicts while merging file.txt! (edit, then use 'hg resolve --mark')
264 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
265 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
266 [1]
267 $ hg revert file.txt -r .
268 $ hg resolve -ma
269 (no more unresolved files)
270 $ hg commit -m 'merge conflicted edit'
271 Without --merge, it's a diff against p1
272 $ hg diff --no-merge -c 11
273 diff -r fd1f17c90d7c -r 5010caab09f6 new-file-p2.txt
274 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
275 +++ b/new-file-p2.txt Thu Jan 01 00:00:00 1970 +0000
276 @@ -0,0 +1,1 @@
277 +this file is new in p2 of the merge
278 With --merge, it's a diff against the conflicted content.
279 $ hg diff --merge -c 11
280 merging file.txt
281 diff -r 5010caab09f6 file.txt
282 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
283 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
284 @@ -6,12 +6,6 @@
285 5
286 6
287 7
288 -<<<<<<< local: fd1f17c90d7c - test: new file
289 z
290 -||||||| base
291 -8
292 -=======
293 -y
294 ->>>>>>> other: d9e7de69eac3 - test: new file
295 9
296 10
297
298 There must _NOT_ be a .hg/merge directory leftover.
299 $ test ! -d .hg/merge
300 (No output is expected)
197 $ cd ..
301 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now