hgext/remotenames.py
changeset 40069 fd4d59cf2ebb
parent 40068 b313f2c3b8c6
child 42603 3018749a71bb
equal deleted inserted replaced
40068:b313f2c3b8c6 40069:fd4d59cf2ebb
    31 from mercurial.node import (
    31 from mercurial.node import (
    32     bin,
    32     bin,
    33 )
    33 )
    34 from mercurial import (
    34 from mercurial import (
    35     bookmarks,
    35     bookmarks,
       
    36     error,
    36     extensions,
    37     extensions,
    37     logexchange,
    38     logexchange,
    38     namespaces,
    39     namespaces,
    39     pycompat,
    40     pycompat,
    40     registrar,
    41     registrar,
   353     args = revsetlang.getargs(x, 0, 1, _('only one argument accepted'))
   354     args = revsetlang.getargs(x, 0, 1, _('only one argument accepted'))
   354     if args:
   355     if args:
   355         kind, pattern, matcher = stringutil.stringmatcher(
   356         kind, pattern, matcher = stringutil.stringmatcher(
   356             revsetlang.getstring(args[0], _('argument must be a string')))
   357             revsetlang.getstring(args[0], _('argument must be a string')))
   357     else:
   358     else:
       
   359         kind = pattern = None
   358         matcher = util.always
   360         matcher = util.always
   359 
   361 
   360     nodes = set()
   362     nodes = set()
   361     cl = repo.changelog
   363     cl = repo.changelog
   362     for rtype in rtypes:
   364     for rtype in rtypes:
   364             ns = repo.names[rtype]
   366             ns = repo.names[rtype]
   365             for name in ns.listnames(repo):
   367             for name in ns.listnames(repo):
   366                 if not matcher(name):
   368                 if not matcher(name):
   367                     continue
   369                     continue
   368                 nodes.update(ns.nodes(repo, name))
   370                 nodes.update(ns.nodes(repo, name))
       
   371     if kind == 'literal' and not nodes:
       
   372         raise error.RepoLookupError(_("remote name '%s' does not exist")
       
   373                                     % pattern)
   369 
   374 
   370     revs = (cl.rev(n) for n in nodes if cl.hasnode(n))
   375     revs = (cl.rev(n) for n in nodes if cl.hasnode(n))
   371     return subset & smartset.baseset(revs)
   376     return subset & smartset.baseset(revs)
   372 
   377 
   373 @revsetpredicate('remotenames([name])')
   378 @revsetpredicate('remotenames([name])')