##// END OF EJS Templates
shelve: extract some repeated creation of shelf instances to variables...
Martin von Zweigbergk -
r47005:ae7a77a7 default
parent child Browse files
Show More
@@ -463,10 +463,11 b' def _nothingtoshelvemessaging(ui, repo, '
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 )
@@ -602,11 +603,12 b' def deletecmd(ui, repo, 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
@@ -875,16 +877,17 b' def _unshelverestorecommit(ui, repo, tr,'
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
General Comments 0
You need to be logged in to leave comments. Login now