Show More
@@ -29,6 +29,7 from . import ( | |||
|
29 | 29 | copies, |
|
30 | 30 | debugcommands as debugcommandsmod, |
|
31 | 31 | destutil, |
|
32 | diffutil, | |
|
32 | 33 | discovery, |
|
33 | 34 | encoding, |
|
34 | 35 | error, |
@@ -2655,7 +2656,7 def diff(ui, repo, *pats, **opts): | |||
|
2655 | 2656 | if change: |
|
2656 | 2657 | repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn') |
|
2657 | 2658 | ctx2 = logcmdutil.revsingle(repo, change, None) |
|
2658 |
ctx1 = |
|
|
2659 | ctx1 = diffutil.diff_parent(ctx2) | |
|
2659 | 2660 | elif from_rev or to_rev: |
|
2660 | 2661 | repo = scmutil.unhidehashlikerevs( |
|
2661 | 2662 | repo, [from_rev] + [to_rev], b'nowarn' |
@@ -16,6 +16,7 from typing import ( | |||
|
16 | 16 | ) |
|
17 | 17 | |
|
18 | 18 | from .i18n import _ |
|
19 | from .node import nullrev | |
|
19 | 20 | |
|
20 | 21 | from . import ( |
|
21 | 22 | mdiff, |
@@ -155,3 +156,35 def difffeatureopts( | |||
|
155 | 156 | ) |
|
156 | 157 | |
|
157 | 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 import os | |||
|
11 | 11 | import posixpath |
|
12 | 12 | |
|
13 | 13 | from .i18n import _ |
|
14 |
from .node import |
|
|
14 | from .node import wdirrev | |
|
15 | 15 | |
|
16 | 16 | from .thirdparty import attr |
|
17 | 17 | |
|
18 | 18 | from . import ( |
|
19 | 19 | dagop, |
|
20 | diffutil, | |
|
20 | 21 | error, |
|
21 | 22 | formatter, |
|
22 | 23 | graphmod, |
|
23 | 24 | match as matchmod, |
|
24 | 25 | mdiff, |
|
25 | merge, | |
|
26 | 26 | patch, |
|
27 | 27 | pathutil, |
|
28 | 28 | pycompat, |
@@ -69,35 +69,6 def getlimit(opts): | |||
|
69 | 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 | 72 | def get_diff_chunks( |
|
102 | 73 | ui, |
|
103 | 74 | repo, |
@@ -273,7 +244,7 class changesetdiffer: | |||
|
273 | 244 | ui, |
|
274 | 245 | ctx.repo(), |
|
275 | 246 | diffopts, |
|
276 | diff_parent(ctx), | |
|
247 | diffutil.diff_parent(ctx), | |
|
277 | 248 | ctx, |
|
278 | 249 | match=self._makefilematcher(ctx), |
|
279 | 250 | stat=stat, |
@@ -286,7 +257,7 class changesetdiffer: | |||
|
286 | 257 | ui, |
|
287 | 258 | ctx.repo(), |
|
288 | 259 | diffopts, |
|
289 | diff_parent(ctx), | |
|
260 | diffutil.diff_parent(ctx), | |
|
290 | 261 | ctx, |
|
291 | 262 | match=self._makefilematcher(ctx), |
|
292 | 263 | stat=stat, |
General Comments 0
You need to be logged in to leave comments.
Login now