Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/logcmdutil.py @ 41630:035cae1d197f
patch: let caller pass in root-filtering matcher (API)
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.
Differential Revision: https://phab.mercurial-scm.org/D5892
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 06 Feb 2019 17:46:20 -0800 |
parents | d683aca738cd |
children | 74f53d3bd685 |
comparison
equal
deleted
inserted
replaced
41629:e834f6f6f221 | 41630:035cae1d197f |
---|---|
71 relroot += '/' | 71 relroot += '/' |
72 for matchroot in match.files(): | 72 for matchroot in match.files(): |
73 if not matchroot.startswith(relroot): | 73 if not matchroot.startswith(relroot): |
74 ui.warn(_('warning: %s not inside relative root %s\n') % ( | 74 ui.warn(_('warning: %s not inside relative root %s\n') % ( |
75 match.uipath(matchroot), uirelroot)) | 75 match.uipath(matchroot), uirelroot)) |
76 | |
77 relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path') | |
78 match = matchmod.intersectmatchers(match, relrootmatch) | |
76 | 79 |
77 if stat: | 80 if stat: |
78 diffopts = diffopts.copy(context=0, noprefix=False) | 81 diffopts = diffopts.copy(context=0, noprefix=False) |
79 width = 80 | 82 width = 80 |
80 if not ui.plain(): | 83 if not ui.plain(): |