# HG changeset patch # User Stefan Rusek # Date 2008-12-05 08:38:17 # Node ID 4c3e0ad58c5bcb92caee3f28bc4c92899aa7fca2 # Parent 95e1260b8134c7977298b52f53c60a1b69951a79 bookmarks: Adds support for a --non-bookmarked option to push diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py --- a/hgext/bookmarks.py +++ b/hgext/bookmarks.py @@ -17,6 +17,7 @@ merge, hg update). ''' from mercurial.commands import templateopts, hex, short +from mercurial import extensions from mercurial.i18n import _ from mercurial import cmdutil, util, commands, changelog from mercurial.node import nullid, nullrev @@ -220,6 +221,24 @@ def reposetup(ui, repo): repo.__class__ = bookmark_repo +def pushnonbookmarked(orig, ui, repo, *args, **opts): + 'Call push with only the heads that are not bookmarked' + if opts.get('non_bookmarked'): + if opts.get('rev'): + heads = [repo.lookup(r) for r in opts.get('rev')] + else: + heads = repo.heads() + + markheads = parse(repo).values() + opts['rev'] = [head for head in heads if not(head in markheads)] + + orig(ui, repo, *args, **opts) + +def uisetup(ui): + 'Replace push with a decorator to provide --non-bookmarked option' + entry = extensions.wrapcommand(commands.table, 'push', pushnonbookmarked) + entry[1].append(('', 'non-bookmarked', None, _("push all heads that are not bookmarked"))) + cmdtable = { "bookmarks": (bookmark,