1. Augie Fackler
  2. hg-remotebranches


Patrick Mézard  committed a802055

remotebranches: add remotebranches template keyword

Return names of all remote branches heads on a revision.

  • Participants
  • Parent commits fdda722
  • Branches default

Comments (0)

Files changed (3)


View file
  • Ignore whitespace
 ``remotebranches.upstream`` setting, it defaults to behaving
 identically to ``pushed()``. The ``remotebranches()`` revset simply
 returns all remote branches head changesets.
+When template keywords can be registered (Mercurial 1.5 and later),
+remotebranches adds a ``remotebranches`` keyword returning a space
+separated list of all names of remote branches heads on a changeset.

File hg_remotebranches.py

View file
  • Ignore whitespace
 except ImportError:
    revset = None
+    from mercurial import templatekw
+    # force demandimport to load templatekw
+    templatekw.keywords
+except ImportError:
+    templatekw = None
 from hgext import schemes
 def reposetup(ui, repo):
     revset.symbols.update({'upstream': upstream,
                            'pushed': pushed,
                            'remotebranches': remotebranchesrevset})
+def remotebrancheskw(**args):
+    """:remotebranches: List of strings. Any remote branch associated
+    with the changeset.
+    """
+    repo, ctx = args['repo'], args['ctx']
+    remotenodes = {}
+    for name, node in repo._remotebranches.iteritems():
+        remotenodes.setdefault(node, []).append(name)
+    if ctx.node() in remotenodes:
+        names = sorted(remotenodes[ctx.node()])
+        return templatekw.showlist('remotebranch', names,
+                                   plural='remotebranches', **args)
+if templatekw is not None:
+    templatekw.keywords['remotebranches'] = remotebrancheskw

File tests/test-remotebranches.t

View file
  • Ignore whitespace
   | |  summary:     add d
   | |
-Test remotebranches revset
+Test remotebranches revset and keyword
-  $ hg log -r 'remotebranches()' --template '{rev}:{node|short} {tags}\n'
+  $ hg log -r 'remotebranches()' \
+  >   --template '{rev}:{node|short} {remotebranches}\n'
   1:7c3bad9141dc alpha/default
   2:95cb4ab9fe1d alpha/stable
   3:78f83396d79e beta/default