mercurial/shelve.py
changeset 46287 ae7a77a7ebc0
parent 46286 3b08f56c8a11
child 46288 61f8fc12e167
equal deleted inserted replaced
46286:3b08f56c8a11 46287:ae7a77a7ebc0
   461         ui.status(_(b"nothing changed\n"))
   461         ui.status(_(b"nothing changed\n"))
   462 
   462 
   463 
   463 
   464 def _shelvecreatedcommit(repo, node, name, match):
   464 def _shelvecreatedcommit(repo, node, name, match):
   465     info = {b'node': hex(node)}
   465     info = {b'node': hex(node)}
   466     Shelf(repo, name).writeinfo(info)
   466     shelf = Shelf(repo, name)
       
   467     shelf.writeinfo(info)
   467     bases = list(mutableancestors(repo[node]))
   468     bases = list(mutableancestors(repo[node]))
   468     Shelf(repo, name).writebundle(bases, node)
   469     shelf.writebundle(bases, node)
   469     with Shelf(repo, name).open_patch(b'wb') as fp:
   470     with shelf.open_patch(b'wb') as fp:
   470         cmdutil.exportfile(
   471         cmdutil.exportfile(
   471             repo, [node], fp, opts=mdiff.diffopts(git=True), match=match
   472             repo, [node], fp, opts=mdiff.diffopts(git=True), match=match
   472         )
   473         )
   473 
   474 
   474 
   475 
   600     """subcommand that deletes a specific shelve"""
   601     """subcommand that deletes a specific shelve"""
   601     if not pats:
   602     if not pats:
   602         raise error.InputError(_(b'no shelved changes specified!'))
   603         raise error.InputError(_(b'no shelved changes specified!'))
   603     with repo.wlock():
   604     with repo.wlock():
   604         for name in pats:
   605         for name in pats:
   605             if not Shelf(repo, name).exists():
   606             shelf = Shelf(repo, name)
       
   607             if not shelf.exists():
   606                 raise error.InputError(
   608                 raise error.InputError(
   607                     _(b"shelved change '%s' not found") % name
   609                     _(b"shelved change '%s' not found") % name
   608                 )
   610                 )
   609             Shelf(repo, name).movetobackup()
   611             shelf.movetobackup()
   610             cleanupoldbackups(repo)
   612             cleanupoldbackups(repo)
   611 
   613 
   612 
   614 
   613 def listshelves(repo):
   615 def listshelves(repo):
   614     """return all shelves in repo as list of (time, name)"""
   616     """return all shelves in repo as list of (time, name)"""
   873 
   875 
   874 def _unshelverestorecommit(ui, repo, tr, basename):
   876 def _unshelverestorecommit(ui, repo, tr, basename):
   875     """Recreate commit in the repository during the unshelve"""
   877     """Recreate commit in the repository during the unshelve"""
   876     repo = repo.unfiltered()
   878     repo = repo.unfiltered()
   877     node = None
   879     node = None
   878     if Shelf(repo, basename).hasinfo():
   880     shelf = Shelf(repo, basename)
   879         node = Shelf(repo, basename).readinfo()[b'node']
   881     if shelf.hasinfo():
       
   882         node = shelf.readinfo()[b'node']
   880     if node is None or node not in repo:
   883     if node is None or node not in repo:
   881         with ui.configoverride({(b'ui', b'quiet'): True}):
   884         with ui.configoverride({(b'ui', b'quiet'): True}):
   882             shelvectx = Shelf(repo, basename).applybundle(tr)
   885             shelvectx = shelf.applybundle(tr)
   883         # We might not strip the unbundled changeset, so we should keep track of
   886         # We might not strip the unbundled changeset, so we should keep track of
   884         # the unshelve node in case we need to reuse it (eg: unshelve --keep)
   887         # the unshelve node in case we need to reuse it (eg: unshelve --keep)
   885         if node is None:
   888         if node is None:
   886             info = {b'node': hex(shelvectx.node())}
   889             info = {b'node': hex(shelvectx.node())}
   887             Shelf(repo, basename).writeinfo(info)
   890             shelf.writeinfo(info)
   888     else:
   891     else:
   889         shelvectx = repo[node]
   892         shelvectx = repo[node]
   890 
   893 
   891     return repo, shelvectx
   894     return repo, shelvectx
   892 
   895