##// END OF EJS Templates
remotenames: add new namespaces for remotebookmarks and remotebranches...
Pulkit Goyal -
r36079:382aefea default
parent child Browse files
Show More
@@ -6,7 +6,19
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 """ showing remotebookmarks and remotebranches in UI """
9 """ showing remotebookmarks and remotebranches in UI
10
11 By default both remotebookmarks and remotebranches are turned on. Config knob to
12 control the individually are as follows.
13
14 Config options to tweak the default behaviour:
15
16 remotenames.bookmarks
17 Boolean value to enable or disable showing of remotebookmarks
18
19 remotenames.branches
20 Boolean value to enable or disable showing of remotebranches
21 """
10 22
11 23 from __future__ import absolute_import
12 24
@@ -17,6 +29,8 from mercurial.node import (
17 29 )
18 30 from mercurial import (
19 31 logexchange,
32 namespaces,
33 registrar,
20 34 )
21 35
22 36 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -25,6 +39,16 from mercurial import (
25 39 # leave the attribute unspecified.
26 40 testedwith = 'ships-with-hg-core'
27 41
42 configtable = {}
43 configitem = registrar.configitem(configtable)
44
45 configitem('remotenames', 'bookmarks',
46 default=True,
47 )
48 configitem('remotenames', 'branches',
49 default=True,
50 )
51
28 52 class lazyremotenamedict(UserDict.DictMixin):
29 53 """
30 54 Read-only dict-like Class to lazily resolve remotename entries
@@ -148,3 +172,36 class remotenames(dict):
148 172 for node in nodes:
149 173 self._nodetobranch.setdefault(node, []).append(name)
150 174 return self._nodetobranch
175
176 def reposetup(ui, repo):
177 if not repo.local():
178 return
179
180 repo._remotenames = remotenames(repo)
181 ns = namespaces.namespace
182
183 if ui.configbool('remotenames', 'bookmarks'):
184 remotebookmarkns = ns(
185 'remotebookmarks',
186 templatename='remotebookmarks',
187 logname='remote bookmark',
188 colorname='remotebookmark',
189 listnames=lambda repo: repo._remotenames.bmarktonodes().keys(),
190 namemap=lambda repo, name:
191 repo._remotenames.bmarktonodes().get(name, []),
192 nodemap=lambda repo, node:
193 repo._remotenames.nodetobmarks().get(node, []))
194 repo.names.addnamespace(remotebookmarkns)
195
196 if ui.configbool('remotenames', 'branches'):
197 remotebranchns = ns(
198 'remotebranches',
199 templatename='remotebranches',
200 logname='remote branch',
201 colorname='remotebranch',
202 listnames = lambda repo: repo._remotenames.branchtonodes().keys(),
203 namemap = lambda repo, name:
204 repo._remotenames.branchtonodes().get(name, []),
205 nodemap = lambda repo, node:
206 repo._remotenames.nodetobranch().get(node, []))
207 repo.names.addnamespace(remotebranchns)
@@ -6,6 +6,9 Testing the functionality to pull remote
6 6 > glog = log -G -T '{rev}:{node|short} {desc}'
7 7 > [experimental]
8 8 > remotenames = True
9 > [extensions]
10 > remotenames =
11 > show =
9 12 > EOF
10 13
11 14 Making a server repo
@@ -66,6 +69,19 Making a client repo
66 69 ec2426147f0e39dbc9cef599b066be6035ce691d\x00default\x00default (esc)
67 70 3e1487808078543b0af6d10dadf5d46943578db0\x00default\x00wat (esc)
68 71
72 $ hg show work
73 o 3e14 (wat) (default/wat) added bar
74 |
75 ~
76 @ ec24 (default/default) Added h
77 |
78 ~
79
80 $ hg update "default/wat"
81 1 files updated, 0 files merged, 3 files removed, 0 files unresolved
82 $ hg identify
83 3e1487808078 (wat) tip
84
69 85 Making a new server
70 86 -------------------
71 87
@@ -106,3 +122,63 Pulling form the new server
106 122 ec2426147f0e39dbc9cef599b066be6035ce691d\x00default\x00default (esc)
107 123 ec2426147f0e39dbc9cef599b066be6035ce691d\x00$TESTTMP/server2\x00default (esc)
108 124 3e1487808078543b0af6d10dadf5d46943578db0\x00$TESTTMP/server2\x00wat (esc)
125
126 $ hg log -G
127 @ changeset: 8:3e1487808078
128 | branch: wat
129 | tag: tip
130 | remote branch:$TESTTMP/server2/wat
131 | remote branch:default/wat
132 | parent: 4:aa98ab95a928
133 | user: test
134 | date: Thu Jan 01 00:00:00 1970 +0000
135 | summary: added bar
136 |
137 | o changeset: 7:ec2426147f0e
138 | | remote branch:$TESTTMP/server2/default
139 | | remote branch:default/default
140 | | user: test
141 | | date: Thu Jan 01 00:00:00 1970 +0000
142 | | summary: Added h
143 | |
144 | o changeset: 6:87d6d6676308
145 | | bookmark: bar
146 | | remote bookmark:$TESTTMP/server2/bar
147 | | remote bookmark:default/bar
148 | | user: test
149 | | date: Thu Jan 01 00:00:00 1970 +0000
150 | | summary: Added g
151 | |
152 | o changeset: 5:825660c69f0c
153 |/ user: test
154 | date: Thu Jan 01 00:00:00 1970 +0000
155 | summary: Added f
156 |
157 o changeset: 4:aa98ab95a928
158 | user: test
159 | date: Thu Jan 01 00:00:00 1970 +0000
160 | summary: Added e
161 |
162 o changeset: 3:62615734edd5
163 | bookmark: foo
164 | remote bookmark:$TESTTMP/server2/foo
165 | remote bookmark:default/foo
166 | user: test
167 | date: Thu Jan 01 00:00:00 1970 +0000
168 | summary: Added d
169 |
170 o changeset: 2:28ad74487de9
171 | user: test
172 | date: Thu Jan 01 00:00:00 1970 +0000
173 | summary: Added c
174 |
175 o changeset: 1:29becc82797a
176 | user: test
177 | date: Thu Jan 01 00:00:00 1970 +0000
178 | summary: Added b
179 |
180 o changeset: 0:18d04c59bb5d
181 user: test
182 date: Thu Jan 01 00:00:00 1970 +0000
183 summary: Added a
184
General Comments 0
You need to be logged in to leave comments. Login now