##// 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 464 def _shelvecreatedcommit(repo, node, name, match):
465 465 info = {b'node': hex(node)}
466 Shelf(repo, name).writeinfo(info)
466 shelf = Shelf(repo, name)
467 shelf.writeinfo(info)
467 468 bases = list(mutableancestors(repo[node]))
468 Shelf(repo, name).writebundle(bases, node)
469 with Shelf(repo, name).open_patch(b'wb') as fp:
469 shelf.writebundle(bases, node)
470 with shelf.open_patch(b'wb') as fp:
470 471 cmdutil.exportfile(
471 472 repo, [node], fp, opts=mdiff.diffopts(git=True), match=match
472 473 )
@@ -602,11 +603,12 b' def deletecmd(ui, repo, pats):'
602 603 raise error.InputError(_(b'no shelved changes specified!'))
603 604 with repo.wlock():
604 605 for name in pats:
605 if not Shelf(repo, name).exists():
606 shelf = Shelf(repo, name)
607 if not shelf.exists():
606 608 raise error.InputError(
607 609 _(b"shelved change '%s' not found") % name
608 610 )
609 Shelf(repo, name).movetobackup()
611 shelf.movetobackup()
610 612 cleanupoldbackups(repo)
611 613
612 614
@@ -875,16 +877,17 b' def _unshelverestorecommit(ui, repo, tr,'
875 877 """Recreate commit in the repository during the unshelve"""
876 878 repo = repo.unfiltered()
877 879 node = None
878 if Shelf(repo, basename).hasinfo():
879 node = Shelf(repo, basename).readinfo()[b'node']
880 shelf = Shelf(repo, basename)
881 if shelf.hasinfo():
882 node = shelf.readinfo()[b'node']
880 883 if node is None or node not in repo:
881 884 with ui.configoverride({(b'ui', b'quiet'): True}):
882 shelvectx = Shelf(repo, basename).applybundle(tr)
885 shelvectx = shelf.applybundle(tr)
883 886 # We might not strip the unbundled changeset, so we should keep track of
884 887 # the unshelve node in case we need to reuse it (eg: unshelve --keep)
885 888 if node is None:
886 889 info = {b'node': hex(shelvectx.node())}
887 Shelf(repo, basename).writeinfo(info)
890 shelf.writeinfo(info)
888 891 else:
889 892 shelvectx = repo[node]
890 893
General Comments 0
You need to be logged in to leave comments. Login now