D1759: remotenames: introduce a template keyword for remotenames
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Mon Dec 25 20:51:14 UTC 2017
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This patch introduces a template keyword named 'remotenames' which can be used
to get remotenames.
This is a part of moving hgremotenames extension to core.
hgremotenames: https://bitbucket.org/seanfarley/hgremotenames
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1759
AFFECTED FILES
hgext/remotenames.py
tests/test-logexchange.t
CHANGE DETAILS
diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -77,6 +77,26 @@
|
~
+ $ hg log -G -T "{rev}:{node|short} {remotenames}\n"
+ o 8:3e1487808078 $TESTTMP/server/wat
+ |
+ | @ 7:ec2426147f0e $TESTTMP/server/default
+ | |
+ | o 6:87d6d6676308 $TESTTMP/server/bar
+ | |
+ | o 5:825660c69f0c
+ |/
+ o 4:aa98ab95a928
+ |
+ o 3:62615734edd5 $TESTTMP/server/foo
+ |
+ o 2:28ad74487de9
+ |
+ o 1:29becc82797a
+ |
+ o 0:18d04c59bb5d
+
+
$ hg update "$TESTTMP/server/wat"
1 files updated, 0 files merged, 3 files removed, 0 files unresolved
$ hg identify
diff --git a/hgext/remotenames.py b/hgext/remotenames.py
--- a/hgext/remotenames.py
+++ b/hgext/remotenames.py
@@ -30,7 +30,9 @@
from mercurial import (
logexchange,
namespaces,
+ pycompat,
registrar,
+ templatekw,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -175,6 +177,9 @@
self._nodetobranch[node] = [name]
return self._nodetobranch
+def extsetup(ui):
+ templatekw.keywords['remotenames'] = remotenameskw
+
def reposetup(ui, repo):
if not repo.local():
return
@@ -207,3 +212,22 @@
nodemap = lambda repo, node:
repo._remotenames.nodetobranch().get(node, []))
repo.names.addnamespace(remotebranchns)
+
+def remotenameskw(**args):
+ """:remotenames: List of strings. List of remote names associated with the
+ changeset. If remotenames.suppressbranches is True then branch names will
+ be hidden if there is a bookmark at the same changeset.
+
+ """
+ args = pycompat.byteskwargs(args)
+ repo, ctx = args['repo'], args['ctx']
+
+ remotenames = []
+ if 'remotebookmarks' in repo.names:
+ remotenames = repo.names['remotebookmarks'].names(repo, ctx.node())
+
+ if 'remotebranches' in repo.names:
+ remotenames += repo.names['remotebranches'].names(repo, ctx.node())
+
+ return templatekw.showlist('remotename', remotenames, args,
+ plural='remotenames')
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list