Mercurial > public > mercurial-scm > hg
comparison mercurial/logcmdutil.py @ 46497:4a012e531066
diff: extract function for getting possibly re-merged parent to diff against
We'll want to reuse the logic that `hg diff --change` with
`diff.merge` uses. At least `hg log -p` should reuse it. This patch
therefore extracts that code to a function.
Differential Revision: https://phab.mercurial-scm.org/D9957
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 04 Feb 2021 13:21:01 -0800 |
parents | 1bf2b44c4007 |
children | 3caa3698335e |
comparison
equal
deleted
inserted
replaced
46496:d57e607d9e33 | 46497:4a012e531066 |
---|---|
25 error, | 25 error, |
26 formatter, | 26 formatter, |
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, |
33 revset, | 34 revset, |
34 revsetlang, | 35 revsetlang, |
69 if limit <= 0: | 70 if limit <= 0: |
70 raise error.Abort(_(b'limit must be positive')) | 71 raise error.Abort(_(b'limit must be positive')) |
71 else: | 72 else: |
72 limit = None | 73 limit = None |
73 return limit | 74 return limit |
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() | |
74 | 105 |
75 | 106 |
76 def diffordiffstat( | 107 def diffordiffstat( |
77 ui, | 108 ui, |
78 repo, | 109 repo, |