diff -r fda1df3d4e06 -r 6346e21eecc8 hgext/remotenames.py --- a/hgext/remotenames.py Thu Jul 12 03:12:09 2018 +0530 +++ b/hgext/remotenames.py Thu Oct 04 21:35:12 2018 -0400 @@ -347,28 +347,18 @@ return templateutil.compatlist(context, mapping, 'remotebranch', remotebranches, plural='remotebranches') -def _revsetutil(repo, subset, x, rtypes, args): +def _revsetutil(repo, subset, x, rtypes, matcher): """utility function to return a set of revs based on the rtypes""" revs = set() cl = repo.changelog - literals, matchers = args - # whether arguments were passed or not - argspassed = bool(literals or matchers) for rtype in rtypes: if rtype in repo.names: ns = repo.names[rtype] for name in ns.listnames(repo): - if argspassed: - if name in literals: - revs.update(ns.nodes(repo, name)) - continue - for matcher in matchers: - if matcher(name): - revs.update(ns.nodes(repo, name)) - break - else: - revs.update(ns.nodes(repo, name)) + if not matcher(name): + continue + revs.update(ns.nodes(repo, name)) results = (cl.rev(n) for n in revs if cl.hasnode(n)) return subset & smartset.baseset(sorted(results)) @@ -376,48 +366,29 @@ def _parseargs(x): """parses the argument passed in revsets - returns (literals, matchers) where, - literals is a set of literals passed by user - matchers is a list of matcher objects for patterns passed by user + Returns a matcher for the passed pattern. """ - - # set of paths passed as literals - literals = set() - # list of matcher to match the patterns passed as names - matchers = [] - - if not x: - return literals, matchers + args = revsetlang.getargs(x, 0, 1, _('only one argument accepted')) + for arg in args: + kind, pattern, matcher = stringutil.stringmatcher( + revsetlang.getstring(arg, _('argument must be a string'))) + return matcher + return lambda a: True - args = set() - lx = revsetlang.getlist(x) - err = _('the argument must be a string') - for entry in lx: - args.add(revsetlang.getstring(entry, err)) - for p in args: - kind, pattern, matcher = stringutil.stringmatcher(p) - if kind == 'literal': - literals.add(pattern) - else: - matchers.append(matcher) - return literals, matchers - -@revsetpredicate('remotenames([name, ...])') +@revsetpredicate('remotenames([name])') def remotenamesrevset(repo, subset, x): - """All changesets which have a remotename on them. If paths are specified, - remotenames of those remote paths are only considered. + """All changesets which have a remotename on them. If `name` is + specified, only remotenames of matching remote paths are considered. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. """ - - args = _parseargs(x) return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'), - args) + _parseargs(x)) -@revsetpredicate('remotebranches([name, ...])') +@revsetpredicate('remotebranches([name])') def remotebranchesrevset(repo, subset, x): - """All changesets which are branch heads on remotes. If paths are specified, - only those remotes paths are considered. + """All changesets which are branch heads on remotes. If `name` is + specified, only remotenames of matching remote paths are considered. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. """ @@ -425,10 +396,10 @@ args = _parseargs(x) return _revsetutil(repo, subset, x, ('remotebranches',), args) -@revsetpredicate('remotebookmarks([name, ...])') +@revsetpredicate('remotebookmarks([name])') def remotebmarksrevset(repo, subset, x): - """All changesets which have bookmarks on remotes. If paths are specified, - only those remote paths are considered. + """All changesets which have bookmarks on remotes. If `name` is + specified, only remotenames of matching remote paths are considered. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. """