Show More
@@ -24,6 +24,8 b' from __future__ import absolute_import' | |||||
24 |
|
24 | |||
25 | import UserDict |
|
25 | import UserDict | |
26 |
|
26 | |||
|
27 | from mercurial.i18n import _ | |||
|
28 | ||||
27 | from mercurial.node import ( |
|
29 | from mercurial.node import ( | |
28 | bin, |
|
30 | bin, | |
29 | ) |
|
31 | ) | |
@@ -32,6 +34,8 b' from mercurial import (' | |||||
32 | namespaces, |
|
34 | namespaces, | |
33 | pycompat, |
|
35 | pycompat, | |
34 | registrar, |
|
36 | registrar, | |
|
37 | revsetlang, | |||
|
38 | smartset, | |||
35 | templatekw, |
|
39 | templatekw, | |
36 | ) |
|
40 | ) | |
37 |
|
41 | |||
@@ -44,6 +48,7 b" testedwith = 'ships-with-hg-core'" | |||||
44 | configtable = {} |
|
48 | configtable = {} | |
45 | configitem = registrar.configitem(configtable) |
|
49 | configitem = registrar.configitem(configtable) | |
46 | templatekeyword = registrar.templatekeyword() |
|
50 | templatekeyword = registrar.templatekeyword() | |
|
51 | revsetpredicate = registrar.revsetpredicate() | |||
47 |
|
52 | |||
48 | configitem('remotenames', 'bookmarks', |
|
53 | configitem('remotenames', 'bookmarks', | |
49 | default=True, |
|
54 | default=True, | |
@@ -256,3 +261,35 b' def remotebrancheskw(**args):' | |||||
256 |
|
261 | |||
257 | return templatekw.showlist('remotebranch', remotebranches, args, |
|
262 | return templatekw.showlist('remotebranch', remotebranches, args, | |
258 | plural='remotebranches') |
|
263 | plural='remotebranches') | |
|
264 | ||||
|
265 | def _revsetutil(repo, subset, x, rtypes): | |||
|
266 | """utility function to return a set of revs based on the rtypes""" | |||
|
267 | ||||
|
268 | revs = set() | |||
|
269 | cl = repo.changelog | |||
|
270 | for rtype in rtypes: | |||
|
271 | if rtype in repo.names: | |||
|
272 | ns = repo.names[rtype] | |||
|
273 | for name in ns.listnames(repo): | |||
|
274 | revs.update(ns.nodes(repo, name)) | |||
|
275 | ||||
|
276 | results = (cl.rev(n) for n in revs if cl.hasnode(n)) | |||
|
277 | return subset & smartset.baseset(sorted(results)) | |||
|
278 | ||||
|
279 | @revsetpredicate('remotenames()') | |||
|
280 | def remotenamesrevset(repo, subset, x): | |||
|
281 | """All changesets which have a remotename on them.""" | |||
|
282 | revsetlang.getargs(x, 0, 0, _("remotenames takes no arguments")) | |||
|
283 | return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches')) | |||
|
284 | ||||
|
285 | @revsetpredicate('remotebranches()') | |||
|
286 | def remotebranchesrevset(repo, subset, x): | |||
|
287 | """All changesets which are branch heads on remotes.""" | |||
|
288 | revsetlang.getargs(x, 0, 0, _("remotebranches takes no arguments")) | |||
|
289 | return _revsetutil(repo, subset, x, ('remotebranches',)) | |||
|
290 | ||||
|
291 | @revsetpredicate('remotebookmarks()') | |||
|
292 | def remotebmarksrevset(repo, subset, x): | |||
|
293 | """All changesets which have bookmarks on remotes.""" | |||
|
294 | revsetlang.getargs(x, 0, 0, _("remotebookmarks takes no arguments")) | |||
|
295 | return _revsetutil(repo, subset, x, ('remotebookmarks',)) |
@@ -226,3 +226,36 b' Testing the templates provided by remote' | |||||
226 | | |
|
226 | | | |
227 | o 0:18d04c59bb5d [] () |
|
227 | o 0:18d04c59bb5d [] () | |
228 |
|
228 | |||
|
229 | Testing the revsets provided by remotenames extension | |||
|
230 | ||||
|
231 | `remotenames` revset | |||
|
232 | ||||
|
233 | $ hg log -r "remotenames()" -GT "{rev}:{node|short} {remotenames}\n" | |||
|
234 | @ 8:3e1487808078 $TESTTMP/server2/wat default/wat | |||
|
235 | : | |||
|
236 | : o 7:ec2426147f0e $TESTTMP/server2/default default/default | |||
|
237 | : | | |||
|
238 | : o 6:87d6d6676308 $TESTTMP/server2/bar default/bar | |||
|
239 | :/ | |||
|
240 | o 3:62615734edd5 $TESTTMP/server2/foo default/foo | |||
|
241 | | | |||
|
242 | ~ | |||
|
243 | ||||
|
244 | `remotebranches` revset | |||
|
245 | ||||
|
246 | $ hg log -r "remotebranches()" -GT "{rev}:{node|short} {remotenames}\n" | |||
|
247 | @ 8:3e1487808078 $TESTTMP/server2/wat default/wat | |||
|
248 | | | |||
|
249 | ~ | |||
|
250 | o 7:ec2426147f0e $TESTTMP/server2/default default/default | |||
|
251 | | | |||
|
252 | ~ | |||
|
253 | ||||
|
254 | `remotebookmarks` revset | |||
|
255 | ||||
|
256 | $ hg log -r "remotebookmarks()" -GT "{rev}:{node|short} {remotenames}\n" | |||
|
257 | o 6:87d6d6676308 $TESTTMP/server2/bar default/bar | |||
|
258 | : | |||
|
259 | o 3:62615734edd5 $TESTTMP/server2/foo default/foo | |||
|
260 | | | |||
|
261 | ~ |
General Comments 0
You need to be logged in to leave comments.
Login now