D5892: patch: let caller pass in root-filtering matcher (API)
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Feb 8 08:30:48 UTC 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The --root option to `hg diff` does two things:
- Shows paths relative to the given root
- Filters paths by the given root, including copy sources
The root argument is passed through down to patch.diff(). I feel like
we can make patch.diff() more generic by not passing down the root
argument, but instead pass:
- A function for taking a repo-relative path and printing it. I want to reuse this for showing cwd-relative paths later. This is the actual motivation for this patch.
- A matcher that's already been filtered by the root argument
- A second matcher that filters the copy sources
This is one step towards that.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5892
AFFECTED FILES
mercurial/logcmdutil.py
mercurial/patch.py
CHANGE DETAILS
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -32,7 +32,6 @@
encoding,
error,
mail,
- match as matchmod,
mdiff,
pathutil,
pycompat,
@@ -2320,10 +2319,6 @@
return getfilectx
getfilectx = lrugetfilectx()
- if relroot:
- relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
- match = matchmod.intersectmatchers(match, relrootmatch)
-
if not changes:
changes = ctx1.status(ctx2, match=match)
modified, added, removed = changes[:3]
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -74,6 +74,9 @@
ui.warn(_('warning: %s not inside relative root %s\n') % (
match.uipath(matchroot), uirelroot))
+ relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
+ match = matchmod.intersectmatchers(match, relrootmatch)
+
if stat:
diffopts = diffopts.copy(context=0, noprefix=False)
width = 80
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list