comparison mercurial/context.py @ 41646:d4c9eebdd72d

patch: replace "prefix" and "relroot" arguments by "pathfn" (API) The two arguments serve a very similar purpose: "relroot" is stripped from the front of the path, and then "prefix" (a subrepo path) is added (also to the front). Passing in a function that does that is more generic and will make it easier to respect ui.relative-paths in later patches (don't worry, I'm not going to respect that option for regular patches, only for --stat). I'm deliberately not calling it "uipathfn", because it's generally for producing valid diffs (including when prefix is non-empty), so things like using backslash on Windows is not an option. Differential Revision: https://phab.mercurial-scm.org/D5894
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 06 Feb 2019 23:12:56 -0800
parents 74f53d3bd685
children a4358f7345b4
comparison
equal deleted inserted replaced
41645:2306158314e9 41646:d4c9eebdd72d
292 include, exclude, default, 292 include, exclude, default,
293 auditor=r.nofsauditor, ctx=self, 293 auditor=r.nofsauditor, ctx=self,
294 listsubrepos=listsubrepos, badfn=badfn) 294 listsubrepos=listsubrepos, badfn=badfn)
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, pathfn=None, copy=None,
298 copysourcematch=None, 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()
302 if ctx2 is not None: 302 if ctx2 is not None:
303 ctx2 = self._repo[ctx2] 303 ctx2 = self._repo[ctx2]
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, pathfn=pathfn,
306 relroot=relroot, copy=copy, 306 copy=copy, copysourcematch=copysourcematch,
307 copysourcematch=copysourcematch,
308 hunksfilterfn=hunksfilterfn) 307 hunksfilterfn=hunksfilterfn)
309 308
310 def dirs(self): 309 def dirs(self):
311 return self._manifest.dirs() 310 return self._manifest.dirs()
312 311