Patrick Mézard avatar Patrick Mézard committed fdda722

remotebranches: add remotebranches() revset

It simply returns all remote branches heads.

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.

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})

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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.