hgext/shelve.py
changeset 27197 6df3ec5bb813
parent 27092 156985f2dec0
child 27198 7df042d0784f
equal deleted inserted replaced
27196:7b4a61570d61 27197:6df3ec5bb813
   222         if dirstatebackup:
   222         if dirstatebackup:
   223             repo.vfs.unlink(dirstatebackup)
   223             repo.vfs.unlink(dirstatebackup)
   224 
   224 
   225 def createcmd(ui, repo, pats, opts):
   225 def createcmd(ui, repo, pats, opts):
   226     """subcommand that creates a new shelve"""
   226     """subcommand that creates a new shelve"""
   227 
   227     wlock = repo.wlock()
       
   228     try:
       
   229         return _docreatecmd(ui, repo, pats, opts)
       
   230     finally:
       
   231         lockmod.release(wlock)
       
   232 
       
   233 def _docreatecmd(ui, repo, pats, opts):
   228     def mutableancestors(ctx):
   234     def mutableancestors(ctx):
   229         """return all mutable ancestors for ctx (included)
   235         """return all mutable ancestors for ctx (included)
   230 
   236 
   231         Much faster than the revset ancestors(ctx) & draft()"""
   237         Much faster than the revset ancestors(ctx) & draft()"""
   232         seen = set([nullrev])
   238         seen = set([nullrev])
   283     if not opts['message']:
   289     if not opts['message']:
   284         opts['message'] = desc
   290         opts['message'] = desc
   285 
   291 
   286     name = opts['name']
   292     name = opts['name']
   287 
   293 
   288     wlock = lock = tr = None
   294     lock = tr = None
   289     try:
   295     try:
   290         wlock = repo.wlock()
       
   291         lock = repo.lock()
   296         lock = repo.lock()
   292 
   297 
   293         # use an uncommitted transaction to generate the bundle to avoid
   298         # use an uncommitted transaction to generate the bundle to avoid
   294         # pull races. ensure we don't print the abort message to stderr.
   299         # pull races. ensure we don't print the abort message to stderr.
   295         tr = repo.transaction('commit', report=lambda x: None)
   300         tr = repo.transaction('commit', report=lambda x: None)
   344         ui.status(_('shelved as %s\n') % name)
   349         ui.status(_('shelved as %s\n') % name)
   345         hg.update(repo, parent.node())
   350         hg.update(repo, parent.node())
   346 
   351 
   347         _aborttransaction(repo)
   352         _aborttransaction(repo)
   348     finally:
   353     finally:
   349         lockmod.release(tr, lock, wlock)
   354         lockmod.release(tr, lock)
   350 
   355 
   351 def cleanupcmd(ui, repo):
   356 def cleanupcmd(ui, repo):
   352     """subcommand that deletes all shelves"""
   357     """subcommand that deletes all shelves"""
   353 
   358 
   354     wlock = None
   359     wlock = None