Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
37089:9938992c5bae | 37090:a61fff493d98 |
---|---|
30 | 30 |
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, | |
36 extensions, | |
35 logexchange, | 37 logexchange, |
36 namespaces, | 38 namespaces, |
37 pycompat, | 39 pycompat, |
38 registrar, | 40 registrar, |
39 revsetlang, | 41 revsetlang, |
226 if name.startswith(hoist): | 228 if name.startswith(hoist): |
227 name = name[len(hoist):] | 229 name = name[len(hoist):] |
228 self._nodetohoists.setdefault(node[0], []).append(name) | 230 self._nodetohoists.setdefault(node[0], []).append(name) |
229 return self._nodetohoists | 231 return self._nodetohoists |
230 | 232 |
233 def wrapprintbookmarks(orig, ui, repo, bmarks, **opts): | |
234 if 'remotebookmarks' not in repo.names: | |
235 return | |
236 ns = repo.names['remotebookmarks'] | |
237 | |
238 for name in ns.listnames(repo): | |
239 nodes = ns.nodes(repo, name) | |
240 if not nodes: | |
241 continue | |
242 node = nodes[0] | |
243 | |
244 bmarks[name] = (node, ' ', '') | |
245 | |
246 return orig(ui, repo, bmarks, **opts) | |
247 | |
248 def extsetup(ui): | |
249 extensions.wrapfunction(bookmarks, '_printbookmarks', wrapprintbookmarks) | |
250 | |
231 def reposetup(ui, repo): | 251 def reposetup(ui, repo): |
232 if not repo.local(): | 252 if not repo.local(): |
233 return | 253 return |
234 | 254 |
235 repo._remotenames = remotenames(repo) | 255 repo._remotenames = remotenames(repo) |