[PATCH 2 of 5] match: extract base class for matchers
Yuya Nishihara
yuya at tcha.org
Thu May 25 09:32:06 EDT 2017
On Tue, 23 May 2017 17:04:34 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # Date 1495089913 25200
> # Wed May 17 23:45:13 2017 -0700
> # Node ID d87d3fba9d29df0fc13681cbd69d8dc5e0a5ff51
> # Parent 0f4af20ceddd58eb37db6d1aa2f0331b29b1137a
> match: extract base class for matchers
The series looks good to me. Queued, thanks.
A few nits inline.
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -201,19 +201,107 @@
> kindpats.append((kind, pat, ''))
> return kindpats
>
> -class matcher(object):
> +class basematcher(object):
> + def abs(self, f):
> + '''Convert a repo path back to path that is relative to the root of the
> + matcher.'''
> + return f
> +
> + def rel(self, f):
> + '''Convert repo path back to path that is relative to cwd of matcher.'''
> + return util.pathto(self._root, self._cwd, f)
> +
> + def uipath(self, f):
> + '''Convert repo path to a display path. If patterns or -I/-X were used
> + to create this matcher, the display path will be relative to cwd.
> + Otherwise it is relative to the root of the repo.'''
> + return self.rel(f)
The default uipath() implementation does not agree with the doc and is unused
now. Perhaps it's better to raise NotImplementedError.
> + def visitdir(self, dir):
> + '''Decides whether a directory should be visited based on whether it
> + has potential matches in it or one of its subdirectories. This is
> + based on the match's primary, included, and excluded patterns.
> +
> + Returns the string 'all' if the given directory and all subdirectories
> + should be visited. Otherwise returns True or False indicating whether
> + the given directory should be visited.
> +
> + This function's behavior is undefined if it has returned False for
> + one of the dir's parent directories.
> + '''
> + return False
This visitdir() seems also useless.
More information about the Mercurial-devel
mailing list