hgext/mq.py
changeset 16718 3290e24bb3f0
parent 16705 c2d9ef43ff6c
child 16733 4da10c00a20c
equal deleted inserted replaced
16716:0311a6abd38a 16718:3290e24bb3f0
  2888                                   ' number greater than REV which are not'
  2888                                   ' number greater than REV which are not'
  2889                                   ' descendants of REV (DEPRECATED)')),
  2889                                   ' descendants of REV (DEPRECATED)')),
  2890           ('', 'no-backup', None, _('no backups')),
  2890           ('', 'no-backup', None, _('no backups')),
  2891           ('', 'nobackup', None, _('no backups (DEPRECATED)')),
  2891           ('', 'nobackup', None, _('no backups (DEPRECATED)')),
  2892           ('n', '', None, _('ignored  (DEPRECATED)')),
  2892           ('n', '', None, _('ignored  (DEPRECATED)')),
  2893           ('k', 'keep', None, _("do not modify working copy during strip"))],
  2893           ('k', 'keep', None, _("do not modify working copy during strip")),
  2894           _('hg strip [-k] [-f] [-n] REV...'))
  2894           ('B', 'bookmark', '', _("remove revs only reachable from given"
       
  2895                                   " bookmark"))],
       
  2896           _('hg strip [-k] [-f] [-n] [-B bookmark] REV...'))
  2895 def strip(ui, repo, *revs, **opts):
  2897 def strip(ui, repo, *revs, **opts):
  2896     """strip changesets and all their descendants from the repository
  2898     """strip changesets and all their descendants from the repository
  2897 
  2899 
  2898     The strip command removes the specified changesets and all their
  2900     The strip command removes the specified changesets and all their
  2899     descendants. If the working directory has uncommitted changes, the
  2901     descendants. If the working directory has uncommitted changes, the
  2924         backup = 'none'
  2926         backup = 'none'
  2925 
  2927 
  2926     cl = repo.changelog
  2928     cl = repo.changelog
  2927     revs = list(revs) + opts.get('rev')
  2929     revs = list(revs) + opts.get('rev')
  2928     revs = set(scmutil.revrange(repo, revs))
  2930     revs = set(scmutil.revrange(repo, revs))
       
  2931 
       
  2932     if opts.get('bookmark'):
       
  2933         mark = opts.get('bookmark')
       
  2934         marks = repo._bookmarks
       
  2935         if mark not in marks:
       
  2936             raise util.Abort(_("bookmark '%s' not found") % mark)
       
  2937 
       
  2938         # If the requested bookmark is not the only one pointing to a
       
  2939         # a revision we have to only delete the bookmark and not strip
       
  2940         # anything. revsets cannot detect that case.
       
  2941         uniquebm = True
       
  2942         for m, n in marks.iteritems():
       
  2943             if m != mark and n == repo[mark].node():
       
  2944                 uniquebm = False
       
  2945                 break
       
  2946         if uniquebm:
       
  2947             rsrevs = repo.revs("ancestors(bookmark(%s)) - "
       
  2948                                "ancestors(head() and not bookmark(%s)) - "
       
  2949                                "ancestors(bookmark() and not bookmark(%s))",
       
  2950                                mark, mark, mark)
       
  2951             revs.update(set(rsrevs))
       
  2952         if not revs:
       
  2953             del marks[mark]
       
  2954             repo._writebookmarks(mark)
       
  2955             ui.write(_("bookmark '%s' deleted\n") % mark)
       
  2956 
  2929     if not revs:
  2957     if not revs:
  2930         raise util.Abort(_('empty revision set'))
  2958         raise util.Abort(_('empty revision set'))
  2931 
  2959 
  2932     descendants = set(cl.descendants(*revs))
  2960     descendants = set(cl.descendants(*revs))
  2933     strippedrevs = revs.union(descendants)
  2961     strippedrevs = revs.union(descendants)
  2971         finally:
  2999         finally:
  2972             wlock.release()
  3000             wlock.release()
  2973 
  3001 
  2974     repo.mq.strip(repo, revs, backup=backup, update=update,
  3002     repo.mq.strip(repo, revs, backup=backup, update=update,
  2975                   force=opts.get('force'))
  3003                   force=opts.get('force'))
       
  3004 
       
  3005     if opts.get('bookmark'):
       
  3006         del marks[mark]
       
  3007         repo._writebookmarks(marks)
       
  3008         ui.write(_("bookmark '%s' deleted\n") % mark)
       
  3009 
  2976     return 0
  3010     return 0
  2977 
  3011 
  2978 @command("qselect",
  3012 @command("qselect",
  2979          [('n', 'none', None, _('disable all guards')),
  3013          [('n', 'none', None, _('disable all guards')),
  2980           ('s', 'series', None, _('list all guards in series file')),
  3014           ('s', 'series', None, _('list all guards in series file')),