This revision was automatically updated to reflect the committed changes.
Closed by commit rHG382aefea8faf: remotenames: add new namespaces for 
remotebookmarks and remotebranches (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1758?vs=5147&id=5523

REVISION DETAIL
  https://phab.mercurial-scm.org/D1758

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
@@ -6,6 +6,9 @@
   > glog = log -G -T '{rev}:{node|short}  {desc}'
   > [experimental]
   > remotenames = True
+  > [extensions]
+  > remotenames =
+  > show =
   > EOF
 
 Making a server repo
@@ -66,6 +69,19 @@
   ec2426147f0e39dbc9cef599b066be6035ce691d\x00default\x00default (esc)
   3e1487808078543b0af6d10dadf5d46943578db0\x00default\x00wat (esc)
 
+  $ hg show work
+  o  3e14 (wat) (default/wat) added bar
+  |
+  ~
+  @  ec24 (default/default) Added h
+  |
+  ~
+
+  $ hg update "default/wat"
+  1 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ hg identify
+  3e1487808078 (wat) tip
+
 Making a new server
 -------------------
 
@@ -106,3 +122,63 @@
   ec2426147f0e39dbc9cef599b066be6035ce691d\x00default\x00default (esc)
   ec2426147f0e39dbc9cef599b066be6035ce691d\x00$TESTTMP/server2\x00default (esc)
   3e1487808078543b0af6d10dadf5d46943578db0\x00$TESTTMP/server2\x00wat (esc)
+
+  $ hg log -G
+  @  changeset:   8:3e1487808078
+  |  branch:      wat
+  |  tag:         tip
+  |  remote branch:$TESTTMP/server2/wat
+  |  remote branch:default/wat
+  |  parent:      4:aa98ab95a928
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     added bar
+  |
+  | o  changeset:   7:ec2426147f0e
+  | |  remote branch:$TESTTMP/server2/default
+  | |  remote branch:default/default
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  summary:     Added h
+  | |
+  | o  changeset:   6:87d6d6676308
+  | |  bookmark:    bar
+  | |  remote bookmark:$TESTTMP/server2/bar
+  | |  remote bookmark:default/bar
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  summary:     Added g
+  | |
+  | o  changeset:   5:825660c69f0c
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     Added f
+  |
+  o  changeset:   4:aa98ab95a928
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added e
+  |
+  o  changeset:   3:62615734edd5
+  |  bookmark:    foo
+  |  remote bookmark:$TESTTMP/server2/foo
+  |  remote bookmark:default/foo
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added d
+  |
+  o  changeset:   2:28ad74487de9
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added c
+  |
+  o  changeset:   1:29becc82797a
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added b
+  |
+  o  changeset:   0:18d04c59bb5d
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     Added a
+  
diff --git a/hgext/remotenames.py b/hgext/remotenames.py
--- a/hgext/remotenames.py
+++ b/hgext/remotenames.py
@@ -6,7 +6,19 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-""" showing remotebookmarks and remotebranches in UI """
+""" showing remotebookmarks and remotebranches in UI
+
+By default both remotebookmarks and remotebranches are turned on. Config knob 
to
+control the individually are as follows.
+
+Config options to tweak the default behaviour:
+
+remotenames.bookmarks
+  Boolean value to enable or disable showing of remotebookmarks
+
+remotenames.branches
+  Boolean value to enable or disable showing of remotebranches
+"""
 
 from __future__ import absolute_import
 
@@ -17,14 +29,26 @@
 )
 from mercurial import (
     logexchange,
+    namespaces,
+    registrar,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' 
for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('remotenames', 'bookmarks',
+    default=True,
+)
+configitem('remotenames', 'branches',
+    default=True,
+)
+
 class lazyremotenamedict(UserDict.DictMixin):
     """
     Read-only dict-like Class to lazily resolve remotename entries
@@ -148,3 +172,36 @@
                 for node in nodes:
                     self._nodetobranch.setdefault(node, []).append(name)
         return self._nodetobranch
+
+def reposetup(ui, repo):
+    if not repo.local():
+        return
+
+    repo._remotenames = remotenames(repo)
+    ns = namespaces.namespace
+
+    if ui.configbool('remotenames', 'bookmarks'):
+        remotebookmarkns = ns(
+            'remotebookmarks',
+            templatename='remotebookmarks',
+            logname='remote bookmark',
+            colorname='remotebookmark',
+            listnames=lambda repo: repo._remotenames.bmarktonodes().keys(),
+            namemap=lambda repo, name:
+                repo._remotenames.bmarktonodes().get(name, []),
+            nodemap=lambda repo, node:
+                repo._remotenames.nodetobmarks().get(node, []))
+        repo.names.addnamespace(remotebookmarkns)
+
+    if ui.configbool('remotenames', 'branches'):
+        remotebranchns = ns(
+            'remotebranches',
+            templatename='remotebranches',
+            logname='remote branch',
+            colorname='remotebranch',
+            listnames = lambda repo: repo._remotenames.branchtonodes().keys(),
+            namemap = lambda repo, name:
+                repo._remotenames.branchtonodes().get(name, []),
+            nodemap = lambda repo, node:
+                repo._remotenames.nodetobranch().get(node, []))
+        repo.names.addnamespace(remotebranchns)



To: pulkit, #hg-reviewers, durin42
Cc: martinvonz, durin42, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to