# HG changeset patch # User Kevin Bullock # 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 -r 361ab1e2086f -r c284085d17a8 mercurial/commands.py --- a/mercurial/commands.py Wed Oct 17 21:42:06 2012 -0500 +++ b/mercurial/commands.py Thu Oct 18 16:34:13 2012 -0500 @@ -850,28 +850,31 @@ bookmarks.setcurrent(repo, mark) bookmarks.write(repo) - 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")) - else: - bookmarks.setcurrent(repo, None) + # 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: - 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) + bookmarks.setcurrent(repo, None) + + else: # show bookmarks + 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) @command('branch', [('f', 'force', None,