hgext/bookmarks.py
changeset 7478 4c3e0ad58c5b
parent 7316 9737041646bc
child 7479 cae586246331
child 7488 e80a734ba1fc
equal deleted inserted replaced
7318:95e1260b8134 7478:4c3e0ad58c5b
    15 It is possible to use bookmark names in every revision lookup (e.g. hg
    15 It is possible to use bookmark names in every revision lookup (e.g. hg
    16 merge, hg update).
    16 merge, hg update).
    17 '''
    17 '''
    18 
    18 
    19 from mercurial.commands import templateopts, hex, short
    19 from mercurial.commands import templateopts, hex, short
       
    20 from mercurial import extensions
    20 from mercurial.i18n import _
    21 from mercurial.i18n import _
    21 from mercurial import cmdutil, util, commands, changelog
    22 from mercurial import cmdutil, util, commands, changelog
    22 from mercurial.node import nullid, nullrev
    23 from mercurial.node import nullid, nullrev
    23 from mercurial.repo import RepoError
    24 from mercurial.repo import RepoError
    24 import mercurial, mercurial.localrepo, mercurial.repair, os
    25 import mercurial, mercurial.localrepo, mercurial.repair, os
   218                 write(repo, marks)
   219                 write(repo, marks)
   219             return result
   220             return result
   220 
   221 
   221     repo.__class__ = bookmark_repo
   222     repo.__class__ = bookmark_repo
   222 
   223 
       
   224 def pushnonbookmarked(orig, ui, repo, *args, **opts):
       
   225     'Call push with only the heads that are not bookmarked'
       
   226     if opts.get('non_bookmarked'):
       
   227         if opts.get('rev'):
       
   228             heads = [repo.lookup(r) for r in opts.get('rev')]
       
   229         else:
       
   230             heads = repo.heads()
       
   231 
       
   232 	markheads = parse(repo).values()
       
   233         opts['rev'] = [head for head in heads if not(head in markheads)]
       
   234         
       
   235     orig(ui, repo, *args, **opts)
       
   236 
       
   237 def uisetup(ui):
       
   238     'Replace push with a decorator to provide --non-bookmarked option'
       
   239     entry = extensions.wrapcommand(commands.table, 'push', pushnonbookmarked)
       
   240     entry[1].append(('', 'non-bookmarked', None, _("push all heads that are not bookmarked")))
       
   241 
   223 cmdtable = {
   242 cmdtable = {
   224     "bookmarks":
   243     "bookmarks":
   225         (bookmark,
   244         (bookmark,
   226          [('f', 'force', False, _('force')),
   245          [('f', 'force', False, _('force')),
   227           ('r', 'rev', '', _('revision')),
   246           ('r', 'rev', '', _('revision')),