[PATCH] bookmarks: further flatten code
Kevin Bullock
kbullock+mercurial at ringworld.org
Thu Oct 18 16:42:20 CDT 2012
# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1350596053 18000
# Node ID c284085d17a87f7039e439b23485cdf0693a15f1
# Parent 361ab1e2086f6db05b260cabc1702dd3323243dc
bookmarks: further flatten code
This hopefully clarifies the behavior when no NAME is passed, by
separating the branches for listing bookmarks vs. deactivating the
current bookmark.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -850,28 +850,31 @@ def bookmark(ui, repo, mark=None, rev=No
bookmarks.setcurrent(repo, mark)
bookmarks.write(repo)
+ # Same message whether trying to deactivate the current bookmark (-i
+ # with no NAME) or listing bookmarks
+ elif len(marks) == 0:
+ ui.status(_("no bookmarks set\n"))
+
+ elif inactive:
+ if not repo._bookmarkcurrent:
+ ui.status(_("no active bookmark\n"))
+ else:
+ bookmarks.setcurrent(repo, None)
+
else: # show bookmarks
- if len(marks) == 0:
- ui.status(_("no bookmarks set\n"))
- elif inactive:
- if not repo._bookmarkcurrent:
- ui.status(_("no active bookmark\n"))
+ for bmark, n in sorted(marks.iteritems()):
+ current = repo._bookmarkcurrent
+ if bmark == current and n == cur:
+ prefix, label = '*', 'bookmarks.current'
else:
- bookmarks.setcurrent(repo, None)
- else:
- for bmark, n in sorted(marks.iteritems()):
- current = repo._bookmarkcurrent
- if bmark == current and n == cur:
- prefix, label = '*', 'bookmarks.current'
- else:
- prefix, label = ' ', ''
-
- if ui.quiet:
- ui.write("%s\n" % bmark, label=label)
- else:
- ui.write(" %s %-25s %d:%s\n" % (
- prefix, bmark, repo.changelog.rev(n), hexfn(n)),
- label=label)
+ prefix, label = ' ', ''
+
+ if ui.quiet:
+ ui.write("%s\n" % bmark, label=label)
+ else:
+ ui.write(" %s %-25s %d:%s\n" % (
+ prefix, bmark, repo.changelog.rev(n), hexfn(n)),
+ label=label)
@command('branch',
[('f', 'force', None,
More information about the Mercurial-devel
mailing list