comparison mercurial/commands.py @ 46448:1a7d12c82057

diff: add experimental support for "merge diffs" The way this works is it re-runs the merge and "stores" conflicts, and then diffs against the conflicted result. In a normal merge, you should only see diffs against conflicted regions or in cases where there was a semantic conflict but not a textual one. This makes it easier to detect "evil merges" that contain substantial new work embedded in the merge commit. Differential Revision: https://phab.mercurial-scm.org/D8504
author Augie Fackler <augie@google.com>
date Thu, 07 May 2020 16:50:26 -0400
parents 16c18d5e5dc8
children 62a0b5daa15f
comparison
equal deleted inserted replaced
46447:0cb1b02228a6 46448:1a7d12c82057
27 bookmarks, 27 bookmarks,
28 bundle2, 28 bundle2,
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,
35 dirstateguard, 36 dirstateguard,
36 discovery, 37 discovery,
2462 [ 2463 [
2463 (b'r', b'rev', [], _(b'revision (DEPRECATED)'), _(b'REV')), 2464 (b'r', b'rev', [], _(b'revision (DEPRECATED)'), _(b'REV')),
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
2470 + walkopts 2481 + walkopts
2471 + subrepoopts, 2482 + subrepoopts,
2542 change = opts.get(b'change') 2553 change = opts.get(b'change')
2543 from_rev = opts.get(b'from') 2554 from_rev = opts.get(b'from')
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'
2557 ) 2586 )
2558 ctx1 = scmutil.revsingle(repo, from_rev, None) 2587 ctx1 = scmutil.revsingle(repo, from_rev, None)