Show More
@@ -305,6 +305,10 b' def bisected(repo, subset, x):' | |||
|
305 | 305 | def bookmark(repo, subset, x): |
|
306 | 306 | """``bookmark([name])`` |
|
307 | 307 | The named bookmark or all bookmarks. |
|
308 | ||
|
309 | If `name` starts with `re:`, the remainder of the name is treated as | |
|
310 | a regular expression. To match a bookmark that actually starts with `re:`, | |
|
311 | use the prefix `literal:`. | |
|
308 | 312 | """ |
|
309 | 313 | # i18n: "bookmark" is a keyword |
|
310 | 314 | args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) |
@@ -312,11 +316,26 b' def bookmark(repo, subset, x):' | |||
|
312 | 316 | bm = getstring(args[0], |
|
313 | 317 | # i18n: "bookmark" is a keyword |
|
314 | 318 | _('the argument to bookmark must be a string')) |
|
315 | bmrev = bookmarksmod.listbookmarks(repo).get(bm, None) | |
|
316 |
if |
|
|
317 | raise util.Abort(_("bookmark '%s' does not exist") % bm) | |
|
318 | bmrev = repo[bmrev].rev() | |
|
319 | return [r for r in subset if r == bmrev] | |
|
319 | kind, pattern, matcher = _stringmatcher(bm) | |
|
320 | if kind == 'literal': | |
|
321 | bmrev = bookmarksmod.listbookmarks(repo).get(bm, None) | |
|
322 | if not bmrev: | |
|
323 | raise util.Abort(_("bookmark '%s' does not exist") % bm) | |
|
324 | bmrev = repo[bmrev].rev() | |
|
325 | return [r for r in subset if r == bmrev] | |
|
326 | else: | |
|
327 | matchrevs = set() | |
|
328 | for name, bmrev in bookmarksmod.listbookmarks(repo).iteritems(): | |
|
329 | if matcher(name): | |
|
330 | matchrevs.add(bmrev) | |
|
331 | if not matchrevs: | |
|
332 | raise util.Abort(_("no bookmarks exist that match '%s'") | |
|
333 | % pattern) | |
|
334 | bmrevs = set() | |
|
335 | for bmrev in matchrevs: | |
|
336 | bmrevs.add(repo[bmrev].rev()) | |
|
337 | return [r for r in subset if r in bmrevs] | |
|
338 | ||
|
320 | 339 | bms = set([repo[r].rev() |
|
321 | 340 | for r in bookmarksmod.listbookmarks(repo).values()]) |
|
322 | 341 | return [r for r in subset if r in bms] |
@@ -84,6 +84,20 b' bookmarks revset' | |||
|
84 | 84 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
85 | 85 | summary: 1 |
|
86 | 86 | |
|
87 | $ hg log -r 'bookmark("re:X")' | |
|
88 | changeset: 0:f7b1eb17ad24 | |
|
89 | bookmark: X | |
|
90 | user: test | |
|
91 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
92 | summary: 0 | |
|
93 | ||
|
94 | changeset: 1:925d80f479bb | |
|
95 | bookmark: X2 | |
|
96 | tag: tip | |
|
97 | user: test | |
|
98 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
99 | summary: 1 | |
|
100 | ||
|
87 | 101 | $ hg log -r 'bookmark(unknown)' |
|
88 | 102 | abort: bookmark 'unknown' does not exist |
|
89 | 103 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now