diff hgext/remotenames.py @ 37090:a61fff493d98

remotenames: show remote bookmarks in `hg bookmarks` This patch adds functionality to show list of remote bookmarks in `hg bookmarks` command. There is some indenting problem in the test output as the current bookmark printing code in core can handle bookmark names of size 25 only gracefully. The idea is taken from hgremotenames extension which has --remote and --all flags to show remote bookmarks. However, this patch by defaults support showing list of remote bookmarks if remotenames extension is enabled and remotebookmarks are turned on. Differential Revision: https://phab.mercurial-scm.org/D2808
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 12 Mar 2018 18:38:26 +0530
parents 9938992c5bae
children 678ab0de7296
line wrap: on
line diff
--- a/hgext/remotenames.py	Sun Mar 11 16:17:51 2018 +0530
+++ b/hgext/remotenames.py	Mon Mar 12 18:38:26 2018 +0530
@@ -32,6 +32,8 @@
     bin,
 )
 from mercurial import (
+    bookmarks,
+    extensions,
     logexchange,
     namespaces,
     pycompat,
@@ -228,6 +230,24 @@
                     self._nodetohoists.setdefault(node[0], []).append(name)
         return self._nodetohoists
 
+def wrapprintbookmarks(orig, ui, repo, bmarks, **opts):
+    if 'remotebookmarks' not in repo.names:
+        return
+    ns = repo.names['remotebookmarks']
+
+    for name in ns.listnames(repo):
+        nodes = ns.nodes(repo, name)
+        if not nodes:
+            continue
+        node = nodes[0]
+
+        bmarks[name] = (node, ' ', '')
+
+    return orig(ui, repo, bmarks, **opts)
+
+def extsetup(ui):
+    extensions.wrapfunction(bookmarks, '_printbookmarks', wrapprintbookmarks)
+
 def reposetup(ui, repo):
     if not repo.local():
         return