Commits

Patrick Mézard committed fdda722

remotebranches: add remotebranches() revset

It simply returns all remote branches heads.

  • Participants
  • Parent commits 9678262

Comments (0)

Files changed (3)

 kinds of manipulation on the repository path may not function as expected.
 
 When revsets are available (Mercurial 1.7 and later), remotebranches
-makes two new revsets available: ``pushed()`` and ``upstream()``. The
-``pushed()`` revset returns all revisions that are have been pushed to
-any repository tracked by remotebranches. The ``upstream()`` set is
-those revisions which are in a repository whose path is listed in the
-``upstream`` field of the ``[remotebranches]`` configuration
-section. If there is no ``remotebranches.upstream`` setting, it
-defaults to behaving identically to ``pushed()``.
+makes three new revsets available: ``pushed()``, ``upstream()`` and
+``remotebranches()``. The ``pushed()`` revset returns all revisions
+that are have been pushed to any repository tracked by
+remotebranches. The ``upstream()`` set is those revisions which are in
+a repository whose path is listed in the ``upstream`` field of the
+``[remotebranches]`` configuration section. If there is no
+``remotebranches.upstream`` setting, it defaults to behaving
+identically to ``pushed()``. The ``remotebranches()`` revset simply
+returns all remote branches head changesets.

File hg_remotebranches.py

     args = revset.getargs(x, 0, 0, "pushed takes no arguments")
     return upstream_revs(lambda x: True, repo, subset, x)
 
+def remotebranchesrevset(repo, subset, x):
+    """``remotebranches()``
+    All remote branches heads.
+    """
+    args = revset.getargs(x, 0, 0, "remotebranches takes no arguments")
+    remoterevs = set(repo[n].rev() for n in repo._remotebranches.itervalues())
+    return [r for r in subset if r in remoterevs]
+
 if revset is not None:
     revset.symbols.update({'upstream': upstream,
-                           'pushed': pushed})
+                           'pushed': pushed,
+                           'remotebranches': remotebranchesrevset})

File tests/test-remotebranches.t

   | |  date:        Thu Jan 01 00:00:00 1970 +0000
   | |  summary:     add d
   | |
+
+Test remotebranches revset
+
+  $ hg log -r 'remotebranches()' --template '{rev}:{node|short} {tags}\n'
+  1:7c3bad9141dc alpha/default
+  2:95cb4ab9fe1d alpha/stable
+  3:78f83396d79e beta/default
+  4:8948da77173b beta/stable