Show More
@@ -29,6 +29,7 b' from . import (' | |||||
29 | copies, |
|
29 | copies, | |
30 | debugcommands as debugcommandsmod, |
|
30 | debugcommands as debugcommandsmod, | |
31 | destutil, |
|
31 | destutil, | |
|
32 | diffutil, | |||
32 | discovery, |
|
33 | discovery, | |
33 | encoding, |
|
34 | encoding, | |
34 | error, |
|
35 | error, | |
@@ -2655,7 +2656,7 b' def diff(ui, repo, *pats, **opts):' | |||||
2655 | if change: |
|
2656 | if change: | |
2656 | repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn') |
|
2657 | repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn') | |
2657 | ctx2 = logcmdutil.revsingle(repo, change, None) |
|
2658 | ctx2 = logcmdutil.revsingle(repo, change, None) | |
2658 |
ctx1 = |
|
2659 | ctx1 = diffutil.diff_parent(ctx2) | |
2659 | elif from_rev or to_rev: |
|
2660 | elif from_rev or to_rev: | |
2660 | repo = scmutil.unhidehashlikerevs( |
|
2661 | repo = scmutil.unhidehashlikerevs( | |
2661 | repo, [from_rev] + [to_rev], b'nowarn' |
|
2662 | repo, [from_rev] + [to_rev], b'nowarn' |
@@ -16,6 +16,7 b' from typing import (' | |||||
16 | ) |
|
16 | ) | |
17 |
|
17 | |||
18 | from .i18n import _ |
|
18 | from .i18n import _ | |
|
19 | from .node import nullrev | |||
19 |
|
20 | |||
20 | from . import ( |
|
21 | from . import ( | |
21 | mdiff, |
|
22 | mdiff, | |
@@ -155,3 +156,35 b' def difffeatureopts(' | |||||
155 | ) |
|
156 | ) | |
156 |
|
157 | |||
157 | return mdiff.diffopts(**pycompat.strkwargs(buildopts)) |
|
158 | return mdiff.diffopts(**pycompat.strkwargs(buildopts)) | |
|
159 | ||||
|
160 | ||||
|
161 | def diff_parent(ctx): | |||
|
162 | """get the context object to use as parent when diffing | |||
|
163 | ||||
|
164 | ||||
|
165 | If diff.merge is enabled, an overlayworkingctx of the auto-merged parents will be returned. | |||
|
166 | """ | |||
|
167 | repo = ctx.repo() | |||
|
168 | if repo.ui.configbool(b"diff", b"merge") and ctx.p2().rev() != nullrev: | |||
|
169 | # avoid circular import | |||
|
170 | from . import ( | |||
|
171 | context, | |||
|
172 | merge, | |||
|
173 | ) | |||
|
174 | ||||
|
175 | wctx = context.overlayworkingctx(repo) | |||
|
176 | wctx.setbase(ctx.p1()) | |||
|
177 | with repo.ui.configoverride( | |||
|
178 | { | |||
|
179 | ( | |||
|
180 | b"ui", | |||
|
181 | b"forcemerge", | |||
|
182 | ): b"internal:merge3-lie-about-conflicts", | |||
|
183 | }, | |||
|
184 | b"merge-diff", | |||
|
185 | ): | |||
|
186 | with repo.ui.silent(): | |||
|
187 | merge.merge(ctx.p2(), wc=wctx) | |||
|
188 | return wctx | |||
|
189 | else: | |||
|
190 | return ctx.p1() |
@@ -11,18 +11,18 b' import os' | |||||
11 | import posixpath |
|
11 | import posixpath | |
12 |
|
12 | |||
13 | from .i18n import _ |
|
13 | from .i18n import _ | |
14 |
from .node import |
|
14 | from .node import wdirrev | |
15 |
|
15 | |||
16 | from .thirdparty import attr |
|
16 | from .thirdparty import attr | |
17 |
|
17 | |||
18 | from . import ( |
|
18 | from . import ( | |
19 | dagop, |
|
19 | dagop, | |
|
20 | diffutil, | |||
20 | error, |
|
21 | error, | |
21 | formatter, |
|
22 | formatter, | |
22 | graphmod, |
|
23 | graphmod, | |
23 | match as matchmod, |
|
24 | match as matchmod, | |
24 | mdiff, |
|
25 | mdiff, | |
25 | merge, |
|
|||
26 | patch, |
|
26 | patch, | |
27 | pathutil, |
|
27 | pathutil, | |
28 | pycompat, |
|
28 | pycompat, | |
@@ -69,35 +69,6 b' def getlimit(opts):' | |||||
69 | return limit |
|
69 | return limit | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | def diff_parent(ctx): |
|
|||
73 | """get the context object to use as parent when diffing |
|
|||
74 |
|
||||
75 |
|
||||
76 | If diff.merge is enabled, an overlayworkingctx of the auto-merged parents will be returned. |
|
|||
77 | """ |
|
|||
78 | repo = ctx.repo() |
|
|||
79 | if repo.ui.configbool(b"diff", b"merge") and ctx.p2().rev() != nullrev: |
|
|||
80 | # avoid cycle context -> subrepo -> cmdutil -> logcmdutil |
|
|||
81 | from . import context |
|
|||
82 |
|
||||
83 | wctx = context.overlayworkingctx(repo) |
|
|||
84 | wctx.setbase(ctx.p1()) |
|
|||
85 | with repo.ui.configoverride( |
|
|||
86 | { |
|
|||
87 | ( |
|
|||
88 | b"ui", |
|
|||
89 | b"forcemerge", |
|
|||
90 | ): b"internal:merge3-lie-about-conflicts", |
|
|||
91 | }, |
|
|||
92 | b"merge-diff", |
|
|||
93 | ): |
|
|||
94 | with repo.ui.silent(): |
|
|||
95 | merge.merge(ctx.p2(), wc=wctx) |
|
|||
96 | return wctx |
|
|||
97 | else: |
|
|||
98 | return ctx.p1() |
|
|||
99 |
|
||||
100 |
|
||||
101 | def get_diff_chunks( |
|
72 | def get_diff_chunks( | |
102 | ui, |
|
73 | ui, | |
103 | repo, |
|
74 | repo, | |
@@ -273,7 +244,7 b' class changesetdiffer:' | |||||
273 | ui, |
|
244 | ui, | |
274 | ctx.repo(), |
|
245 | ctx.repo(), | |
275 | diffopts, |
|
246 | diffopts, | |
276 | diff_parent(ctx), |
|
247 | diffutil.diff_parent(ctx), | |
277 | ctx, |
|
248 | ctx, | |
278 | match=self._makefilematcher(ctx), |
|
249 | match=self._makefilematcher(ctx), | |
279 | stat=stat, |
|
250 | stat=stat, | |
@@ -286,7 +257,7 b' class changesetdiffer:' | |||||
286 | ui, |
|
257 | ui, | |
287 | ctx.repo(), |
|
258 | ctx.repo(), | |
288 | diffopts, |
|
259 | diffopts, | |
289 | diff_parent(ctx), |
|
260 | diffutil.diff_parent(ctx), | |
290 | ctx, |
|
261 | ctx, | |
291 | match=self._makefilematcher(ctx), |
|
262 | match=self._makefilematcher(ctx), | |
292 | stat=stat, |
|
263 | stat=stat, |
General Comments 0
You need to be logged in to leave comments.
Login now