##// END OF EJS Templates
diff: extract function for getting possibly re-merged parent to diff against...
Martin von Zweigbergk -
r47247:4a012e53 default
parent child Browse files
Show More
@@ -29,7 +29,6 b' from . import ('
29 bundlecaches,
29 bundlecaches,
30 changegroup,
30 changegroup,
31 cmdutil,
31 cmdutil,
32 context as contextmod,
33 copies,
32 copies,
34 debugcommands as debugcommandsmod,
33 debugcommands as debugcommandsmod,
35 destutil,
34 destutil,
@@ -2545,33 +2544,13 b' def diff(ui, repo, *pats, **opts):'
2545 to_rev = opts.get(b'to')
2544 to_rev = opts.get(b'to')
2546 stat = opts.get(b'stat')
2545 stat = opts.get(b'stat')
2547 reverse = opts.get(b'reverse')
2546 reverse = opts.get(b'reverse')
2548 diffmerge = ui.configbool(b'diff', b'merge')
2549
2547
2550 cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
2548 cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
2551 cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
2549 cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
2552 if change:
2550 if change:
2553 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2551 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2554 ctx2 = scmutil.revsingle(repo, change, None)
2552 ctx2 = scmutil.revsingle(repo, change, None)
2555 if diffmerge and ctx2.p2().node() != nullid:
2553 ctx1 = logcmdutil.diff_parent(ctx2)
2556 pctx1 = ctx2.p1()
2557 pctx2 = ctx2.p2()
2558 wctx = contextmod.overlayworkingctx(repo)
2559 wctx.setbase(pctx1)
2560 with ui.configoverride(
2561 {
2562 (
2563 b'ui',
2564 b'forcemerge',
2565 ): b'internal:merge3-lie-about-conflicts',
2566 },
2567 b'diff --merge',
2568 ):
2569 repo.ui.pushbuffer()
2570 mergemod.merge(pctx2, wc=wctx)
2571 repo.ui.popbuffer()
2572 ctx1 = wctx
2573 else:
2574 ctx1 = ctx2.p1()
2575 elif from_rev or to_rev:
2554 elif from_rev or to_rev:
2576 repo = scmutil.unhidehashlikerevs(
2555 repo = scmutil.unhidehashlikerevs(
2577 repo, [from_rev] + [to_rev], b'nowarn'
2556 repo, [from_rev] + [to_rev], b'nowarn'
@@ -27,6 +27,7 b' from . import ('
27 graphmod,
27 graphmod,
28 match as matchmod,
28 match as matchmod,
29 mdiff,
29 mdiff,
30 merge,
30 patch,
31 patch,
31 pathutil,
32 pathutil,
32 pycompat,
33 pycompat,
@@ -73,6 +74,36 b' def getlimit(opts):'
73 return limit
74 return limit
74
75
75
76
77 def diff_parent(ctx):
78 """get the context object to use as parent when diffing
79
80
81 If diff.merge is enabled, an overlayworkingctx of the auto-merged parents will be returned.
82 """
83 repo = ctx.repo()
84 if repo.ui.configbool(b"diff", b"merge") and ctx.p2().node() != nullid:
85 # avoid cycle context -> subrepo -> cmdutil -> logcmdutil
86 from . import context
87
88 wctx = context.overlayworkingctx(repo)
89 wctx.setbase(ctx.p1())
90 with repo.ui.configoverride(
91 {
92 (
93 b"ui",
94 b"forcemerge",
95 ): b"internal:merge3-lie-about-conflicts",
96 },
97 b"merge-diff",
98 ):
99 repo.ui.pushbuffer()
100 merge.merge(ctx.p2(), wc=wctx)
101 repo.ui.popbuffer()
102 return wctx
103 else:
104 return ctx.p1()
105
106
76 def diffordiffstat(
107 def diffordiffstat(
77 ui,
108 ui,
78 repo,
109 repo,
General Comments 0
You need to be logged in to leave comments. Login now