Show More
@@ -14,10 +14,14 b' control the individually are as follows.' | |||
|
14 | 14 | Config options to tweak the default behaviour: |
|
15 | 15 | |
|
16 | 16 | remotenames.bookmarks |
|
17 | Boolean value to enable or disable showing of remotebookmarks | |
|
17 | Boolean value to enable or disable showing of remotebookmarks (default: True) | |
|
18 | 18 | |
|
19 | 19 | remotenames.branches |
|
20 | Boolean value to enable or disable showing of remotebranches | |
|
20 | Boolean value to enable or disable showing of remotebranches (default: True) | |
|
21 | ||
|
22 | remotenames.hoistedpeer | |
|
23 | Name of the peer whose remotebookmarks should be hoisted into the top-level | |
|
24 | namespace (default: 'default') | |
|
21 | 25 | """ |
|
22 | 26 | |
|
23 | 27 | from __future__ import absolute_import |
@@ -61,6 +65,9 b" configitem('remotenames', 'bookmarks'," | |||
|
61 | 65 | configitem('remotenames', 'branches', |
|
62 | 66 | default=True, |
|
63 | 67 | ) |
|
68 | configitem('remotenames', 'hoistedpeer', | |
|
69 | default='default', | |
|
70 | ) | |
|
64 | 71 | |
|
65 | 72 | class lazyremotenamedict(mutablemapping): |
|
66 | 73 | """ |
@@ -173,6 +180,8 b' class remotenames(object):' | |||
|
173 | 180 | def _invalidatecache(self): |
|
174 | 181 | self._nodetobmarks = None |
|
175 | 182 | self._nodetobranch = None |
|
183 | self._hoisttonodes = None | |
|
184 | self._nodetohoists = None | |
|
176 | 185 | |
|
177 | 186 | def bmarktonodes(self): |
|
178 | 187 | return self.bookmarks |
@@ -197,6 +206,28 b' class remotenames(object):' | |||
|
197 | 206 | self._nodetobranch.setdefault(node, []).append(name) |
|
198 | 207 | return self._nodetobranch |
|
199 | 208 | |
|
209 | def hoisttonodes(self, hoist): | |
|
210 | if not self._hoisttonodes: | |
|
211 | marktonodes = self.bmarktonodes() | |
|
212 | self._hoisttonodes = {} | |
|
213 | hoist += '/' | |
|
214 | for name, node in marktonodes.iteritems(): | |
|
215 | if name.startswith(hoist): | |
|
216 | name = name[len(hoist):] | |
|
217 | self._hoisttonodes[name] = node | |
|
218 | return self._hoisttonodes | |
|
219 | ||
|
220 | def nodetohoists(self, hoist): | |
|
221 | if not self._nodetohoists: | |
|
222 | marktonodes = self.bmarktonodes() | |
|
223 | self._nodetohoists = {} | |
|
224 | hoist += '/' | |
|
225 | for name, node in marktonodes.iteritems(): | |
|
226 | if name.startswith(hoist): | |
|
227 | name = name[len(hoist):] | |
|
228 | self._nodetohoists.setdefault(node[0], []).append(name) | |
|
229 | return self._nodetohoists | |
|
230 | ||
|
200 | 231 | def reposetup(ui, repo): |
|
201 | 232 | if not repo.local(): |
|
202 | 233 | return |
@@ -217,6 +248,22 b' def reposetup(ui, repo):' | |||
|
217 | 248 | repo._remotenames.nodetobmarks().get(node, [])) |
|
218 | 249 | repo.names.addnamespace(remotebookmarkns) |
|
219 | 250 | |
|
251 | # hoisting only works if there are remote bookmarks | |
|
252 | hoist = ui.config('remotenames', 'hoistedpeer') | |
|
253 | if hoist: | |
|
254 | hoistednamens = ns( | |
|
255 | 'hoistednames', | |
|
256 | templatename='hoistednames', | |
|
257 | colorname='hoistedname', | |
|
258 | logfmt='hoisted name: %s\n', | |
|
259 | listnames = lambda repo: | |
|
260 | repo._remotenames.hoisttonodes(hoist).keys(), | |
|
261 | namemap = lambda repo, name: | |
|
262 | repo._remotenames.hoisttonodes(hoist).get(name, []), | |
|
263 | nodemap = lambda repo, node: | |
|
264 | repo._remotenames.nodetohoists(hoist).get(node, [])) | |
|
265 | repo.names.addnamespace(hoistednamens) | |
|
266 | ||
|
220 | 267 | if ui.configbool('remotenames', 'branches'): |
|
221 | 268 | remotebranchns = ns( |
|
222 | 269 | 'remotebranches', |
@@ -145,6 +145,7 b' Pulling form the new server' | |||
|
145 | 145 | | | bookmark: bar |
|
146 | 146 | | | remote bookmark: $TESTTMP/server2/bar |
|
147 | 147 | | | remote bookmark: default/bar |
|
148 | | | hoisted name: bar | |
|
148 | 149 | | | user: test |
|
149 | 150 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
150 | 151 | | | summary: Added g |
@@ -163,6 +164,7 b' Pulling form the new server' | |||
|
163 | 164 | | bookmark: foo |
|
164 | 165 | | remote bookmark: $TESTTMP/server2/foo |
|
165 | 166 | | remote bookmark: default/foo |
|
167 | | hoisted name: foo | |
|
166 | 168 | | user: test |
|
167 | 169 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
168 | 170 | | summary: Added d |
@@ -226,6 +228,28 b' Testing the templates provided by remote' | |||
|
226 | 228 | | |
|
227 | 229 | o 0:18d04c59bb5d [] () |
|
228 | 230 | |
|
231 | The `hoistednames` template keyword | |
|
232 | ||
|
233 | $ hg log -GT "{rev}:{node|short} ({hoistednames})" | |
|
234 | @ 8:3e1487808078 () | |
|
235 | | | |
|
236 | | o 7:ec2426147f0e () | |
|
237 | | | | |
|
238 | | o 6:87d6d6676308 (bar) | |
|
239 | | | | |
|
240 | | o 5:825660c69f0c () | |
|
241 | |/ | |
|
242 | o 4:aa98ab95a928 () | |
|
243 | | | |
|
244 | o 3:62615734edd5 (foo) | |
|
245 | | | |
|
246 | o 2:28ad74487de9 () | |
|
247 | | | |
|
248 | o 1:29becc82797a () | |
|
249 | | | |
|
250 | o 0:18d04c59bb5d () | |
|
251 | ||
|
252 | ||
|
229 | 253 |
|
|
230 | 254 | |
|
231 | 255 |
` |
@@ -259,3 +283,47 b' Testing the revsets provided by remotena' | |||
|
259 | 283 |
|
|
260 | 284 | | |
|
261 | 285 | ~ |
|
286 | ||
|
287 | Updating to revision using hoisted name | |
|
288 | ||
|
289 | Deleting local bookmark to make sure we update to hoisted name only | |
|
290 | ||
|
291 | $ hg bookmark -d bar | |
|
292 | ||
|
293 | $ hg up bar | |
|
294 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
295 | ||
|
296 | $ hg log -r . | |
|
297 | changeset: 6:87d6d6676308 | |
|
298 | remote bookmark: $TESTTMP/server2/bar | |
|
299 | remote bookmark: default/bar | |
|
300 | hoisted name: bar | |
|
301 | user: test | |
|
302 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
303 | summary: Added g | |
|
304 | ||
|
305 | When both local bookmark and hoisted name exists but on different revs | |
|
306 | ||
|
307 | $ hg up 8 | |
|
308 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
|
309 | ||
|
310 | $ hg bookmark foo | |
|
311 | moving bookmark 'foo' forward from 62615734edd5 | |
|
312 | ||
|
313 | Local bookmark should take precedence over hoisted name | |
|
314 | ||
|
315 | $ hg up foo | |
|
316 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
317 | ||
|
318 | $ hg log -r . | |
|
319 | changeset: 8:3e1487808078 | |
|
320 | branch: wat | |
|
321 | bookmark: foo | |
|
322 | tag: tip | |
|
323 | remote branch: $TESTTMP/server2/wat | |
|
324 | remote branch: default/wat | |
|
325 | parent: 4:aa98ab95a928 | |
|
326 | user: test | |
|
327 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
328 | summary: added bar | |
|
329 |
General Comments 0
You need to be logged in to leave comments.
Login now