# HG changeset patch # User Kevin Bullock # Date 1350494123 18000 # Node ID 1e30c1bbd8c0064eab23956b6ee240ec593a481f # Parent 0291e122fb05a7acb2e9249091125571ee060022 bookmarks: simplify code Remove some unnecessary return statements and collect some checks into one place. As requested by Thomas Arendsen Hein . diff -r 0291e122fb05 -r 1e30c1bbd8c0 mercurial/commands.py --- a/mercurial/commands.py Wed Oct 17 11:50:47 2012 +0200 +++ b/mercurial/commands.py Wed Oct 17 12:15:23 2012 -0500 @@ -813,19 +813,18 @@ raise util.Abort(_("--rev is incompatible with --delete")) if rename and rev: raise util.Abort(_("--rev is incompatible with --rename")) + if mark is None and (delete or rev): + raise util.Abort(_("bookmark name required")) if delete: - if mark is None: - raise util.Abort(_("bookmark name required")) if mark not in marks: raise util.Abort(_("bookmark '%s' does not exist") % mark) if mark == repo._bookmarkcurrent: bookmarks.setcurrent(repo, None) del marks[mark] bookmarks.write(repo) - return - - if rename: + + elif rename: if mark is None: raise util.Abort(_("new bookmark name required")) mark = checkformat(mark) @@ -837,9 +836,8 @@ bookmarks.setcurrent(repo, mark) del marks[rename] bookmarks.write(repo) - return - - if mark is not None: + + elif mark is not None: mark = checkformat(mark) if inactive and mark == repo._bookmarkcurrent: bookmarks.setcurrent(repo, None) @@ -854,17 +852,14 @@ bookmarks.write(repo) return - if mark is None: - if rev: - raise util.Abort(_("bookmark name required")) + else: # mark is None if len(marks) == 0: ui.status(_("no bookmarks set\n")) - if inactive: + elif inactive: if not repo._bookmarkcurrent: ui.status(_("no active bookmark\n")) else: bookmarks.setcurrent(repo, None) - return else: for bmark, n in sorted(marks.iteritems()): current = repo._bookmarkcurrent @@ -879,7 +874,6 @@ ui.write(" %s %-25s %d:%s\n" % ( prefix, bmark, repo.changelog.rev(n), hexfn(n)), label=label) - return @command('branch', [('f', 'force', None,