hgext/strip.py
changeset 21847 f6f122f4813b
parent 20102 04eaa8eec6a0
child 21854 ba3bc6474bbf
equal deleted inserted replaced
21846:8f23f8096606 21847:f6f122f4813b
    40         if checksubstate(repo):
    40         if checksubstate(repo):
    41             _("local changed subrepos found") # i18n tool detection
    41             _("local changed subrepos found") # i18n tool detection
    42             raise util.Abort(_("local changed subrepos found" + excsuffix))
    42             raise util.Abort(_("local changed subrepos found" + excsuffix))
    43     return m, a, r, d
    43     return m, a, r, d
    44 
    44 
    45 def strip(ui, repo, revs, update=True, backup="all", force=None):
    45 def strip(ui, repo, revs, update=True, backup="all", force=None, bookmark=None):
    46     wlock = lock = None
    46     wlock = lock = None
    47     try:
    47     try:
    48         wlock = repo.wlock()
    48         wlock = repo.wlock()
    49         lock = repo.lock()
    49         lock = repo.lock()
    50 
    50 
    57                 urev = p2
    57                 urev = p2
    58             hg.clean(repo, urev)
    58             hg.clean(repo, urev)
    59             repo.dirstate.write()
    59             repo.dirstate.write()
    60 
    60 
    61         repair.strip(ui, repo, revs, backup)
    61         repair.strip(ui, repo, revs, backup)
       
    62 
       
    63         marks = repo._bookmarks
       
    64         if bookmark:
       
    65             if bookmark == repo._bookmarkcurrent:
       
    66                 bookmarks.unsetcurrent(repo)
       
    67             del marks[bookmark]
       
    68             marks.write()
       
    69             ui.write(_("bookmark '%s' deleted\n") % bookmark)
    62     finally:
    70     finally:
    63         release(lock, wlock)
    71         release(lock, wlock)
    64 
    72 
    65 
    73 
    66 @command("strip",
    74 @command("strip",
   203 
   211 
   204             repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
   212             repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
   205             repo.dirstate.write()
   213             repo.dirstate.write()
   206             update = False
   214             update = False
   207 
   215 
   208         if opts.get('bookmark'):
       
   209             if mark == repo._bookmarkcurrent:
       
   210                 bookmarks.unsetcurrent(repo)
       
   211             del marks[mark]
       
   212             marks.write()
       
   213             ui.write(_("bookmark '%s' deleted\n") % mark)
       
   214 
   216 
   215         strip(ui, repo, revs, backup=backup, update=update,
   217         strip(ui, repo, revs, backup=backup, update=update,
   216               force=opts.get('force'))
   218               force=opts.get('force'), bookmark=opts.get('bookmark'))
   217     finally:
   219     finally:
   218         wlock.release()
   220         wlock.release()
   219 
   221 
   220     return 0
   222     return 0