Mercurial > hg
comparison hgext/shelve.py @ 39387:da84cca65036
shelve: fix crash on unshelve without .shelve metadata file
Follow up for c67c94c0e7ae and 38373da1af02.
The inline comment says "we should keep track of the unshelve node in case
we need to reuse it." Perhaps such case isn't tested, and this patch does
NOT add a test for the reuse of the unbundled revision.
Also, I have no idea what should be done if new revision is unbundled
because of "node not in repo".
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 31 Aug 2018 21:10:28 +0900 |
parents | 5f8282f368b2 |
children | 5d69e2412ec8 |
comparison
equal
deleted
inserted
replaced
39386:2df3271ef139 | 39387:da84cca65036 |
---|---|
763 return tmpwctx, addedbefore | 763 return tmpwctx, addedbefore |
764 | 764 |
765 def _unshelverestorecommit(ui, repo, basename): | 765 def _unshelverestorecommit(ui, repo, basename): |
766 """Recreate commit in the repository during the unshelve""" | 766 """Recreate commit in the repository during the unshelve""" |
767 repo = repo.unfiltered() | 767 repo = repo.unfiltered() |
768 node = None | |
768 if shelvedfile(repo, basename, 'shelve').exists(): | 769 if shelvedfile(repo, basename, 'shelve').exists(): |
769 node = shelvedfile(repo, basename, 'shelve').readinfo()['node'] | 770 node = shelvedfile(repo, basename, 'shelve').readinfo()['node'] |
770 if node is None or node not in repo: | 771 if node is None or node not in repo: |
771 with ui.configoverride({('ui', 'quiet'): True}): | 772 with ui.configoverride({('ui', 'quiet'): True}): |
772 shelvedfile(repo, basename, 'hg').applybundle() | 773 shelvedfile(repo, basename, 'hg').applybundle() |
773 shelvectx = repo['tip'] | 774 shelvectx = repo['tip'] |
774 # We might not strip the unbundled changeset, so we should keep track of | 775 # We might not strip the unbundled changeset, so we should keep track of |
775 # the unshelve node in case we need to reuse it (eg: unshelve --keep) | 776 # the unshelve node in case we need to reuse it (eg: unshelve --keep) |
776 if node is None: | 777 if node is None: |
777 info = {'node': nodemod.hex(node)} | 778 info = {'node': nodemod.hex(shelvectx.node())} |
778 shelvedfile(repo, basename, 'shelve').writeinfo(info) | 779 shelvedfile(repo, basename, 'shelve').writeinfo(info) |
779 else: | 780 else: |
780 shelvectx = repo[node] | 781 shelvectx = repo[node] |
781 | 782 |
782 return repo, shelvectx | 783 return repo, shelvectx |