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