Show More
@@ -295,7 +295,7 b' class basectx(object):' | |||
|
295 | 295 | |
|
296 | 296 | def diff(self, ctx2=None, match=None, changes=None, opts=None, |
|
297 | 297 | losedatafn=None, prefix='', relroot='', copy=None, |
|
298 | hunksfilterfn=None): | |
|
298 | copysourcematch=None, hunksfilterfn=None): | |
|
299 | 299 | """Returns a diff generator for the given contexts and matcher""" |
|
300 | 300 | if ctx2 is None: |
|
301 | 301 | ctx2 = self.p1() |
@@ -304,6 +304,7 b' class basectx(object):' | |||
|
304 | 304 | return patch.diff(self._repo, ctx2, self, match=match, changes=changes, |
|
305 | 305 | opts=opts, losedatafn=losedatafn, prefix=prefix, |
|
306 | 306 | relroot=relroot, copy=copy, |
|
307 | copysourcematch=copysourcematch, | |
|
307 | 308 | hunksfilterfn=hunksfilterfn) |
|
308 | 309 | |
|
309 | 310 | def dirs(self): |
@@ -64,6 +64,7 b' def diffordiffstat(ui, repo, diffopts, n' | |||
|
64 | 64 | relroot = pathutil.canonpath(repo.root, repo.getcwd(), root) |
|
65 | 65 | else: |
|
66 | 66 | relroot = '' |
|
67 | copysourcematch = None | |
|
67 | 68 | if relroot != '': |
|
68 | 69 | # XXX relative roots currently don't work if the root is within a |
|
69 | 70 | # subrepo |
@@ -76,6 +77,7 b' def diffordiffstat(ui, repo, diffopts, n' | |||
|
76 | 77 | |
|
77 | 78 | relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path') |
|
78 | 79 | match = matchmod.intersectmatchers(match, relrootmatch) |
|
80 | copysourcematch = relrootmatch | |
|
79 | 81 | |
|
80 | 82 | if stat: |
|
81 | 83 | diffopts = diffopts.copy(context=0, noprefix=False) |
@@ -84,7 +86,8 b' def diffordiffstat(ui, repo, diffopts, n' | |||
|
84 | 86 | width = ui.termwidth() - graphwidth |
|
85 | 87 | |
|
86 | 88 | chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, prefix=prefix, |
|
87 |
relroot=relroot, |
|
|
89 | relroot=relroot, copysourcematch=copysourcematch, | |
|
90 | hunksfilterfn=hunksfilterfn) | |
|
88 | 91 | |
|
89 | 92 | if fp is not None or ui.canwritewithoutlabels(): |
|
90 | 93 | out = fp or ui |
@@ -2240,7 +2240,7 b' difffeatureopts = diffutil.difffeatureop' | |||
|
2240 | 2240 | |
|
2241 | 2241 | def diff(repo, node1=None, node2=None, match=None, changes=None, |
|
2242 | 2242 | opts=None, losedatafn=None, prefix='', relroot='', copy=None, |
|
2243 | hunksfilterfn=None): | |
|
2243 | copysourcematch=None, hunksfilterfn=None): | |
|
2244 | 2244 | '''yields diff of changes to files between two nodes, or node and |
|
2245 | 2245 | working directory. |
|
2246 | 2246 | |
@@ -2264,6 +2264,9 b' def diff(repo, node1=None, node2=None, m' | |||
|
2264 | 2264 | copy, if not empty, should contain mappings {dst@y: src@x} of copy |
|
2265 | 2265 | information. |
|
2266 | 2266 | |
|
2267 | if copysourcematch is not None, then copy sources will be filtered by this | |
|
2268 | matcher | |
|
2269 | ||
|
2267 | 2270 | hunksfilterfn, if not None, should be a function taking a filectx and |
|
2268 | 2271 | hunks generator that may yield filtered hunks. |
|
2269 | 2272 | ''' |
@@ -2277,7 +2280,7 b' def diff(repo, node1=None, node2=None, m' | |||
|
2277 | 2280 | repo, ctx1=ctx1, ctx2=ctx2, |
|
2278 | 2281 | match=match, changes=changes, opts=opts, |
|
2279 | 2282 | losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy, |
|
2280 | ): | |
|
2283 | copysourcematch=copysourcematch): | |
|
2281 | 2284 | if hunksfilterfn is not None: |
|
2282 | 2285 | # If the file has been removed, fctx2 is None; but this should |
|
2283 | 2286 | # not occur here since we catch removed files early in |
@@ -2292,7 +2295,8 b' def diff(repo, node1=None, node2=None, m' | |||
|
2292 | 2295 | yield text |
|
2293 | 2296 | |
|
2294 | 2297 | def diffhunks(repo, ctx1, ctx2, match=None, changes=None, |
|
2295 |
opts=None, losedatafn=None, prefix='', relroot='', copy=None |
|
|
2298 | opts=None, losedatafn=None, prefix='', relroot='', copy=None, | |
|
2299 | copysourcematch=None): | |
|
2296 | 2300 | """Yield diff of changes to files in the form of (`header`, `hunks`) tuples |
|
2297 | 2301 | where `header` is a list of diff headers and `hunks` is an iterable of |
|
2298 | 2302 | (`hunkrange`, `hunklines`) tuples. |
@@ -2337,11 +2341,11 b' def diffhunks(repo, ctx1, ctx2, match=No' | |||
|
2337 | 2341 | if opts.git or opts.upgrade: |
|
2338 | 2342 | copy = copies.pathcopies(ctx1, ctx2, match=match) |
|
2339 | 2343 | |
|
2340 | if relroot: | |
|
2341 |
# filter out copies where source side isn't inside the |
|
|
2344 | if copysourcematch: | |
|
2345 | # filter out copies where source side isn't inside the matcher | |
|
2342 | 2346 | # (copies.pathcopies() already filtered out the destination) |
|
2343 | 2347 | copy = {dst: src for dst, src in copy.iteritems() |
|
2344 | if src.startswith(relroot)} | |
|
2348 | if copysourcematch(src)} | |
|
2345 | 2349 | |
|
2346 | 2350 | modifiedset = set(modified) |
|
2347 | 2351 | addedset = set(added) |
General Comments 0
You need to be logged in to leave comments.
Login now