--- a/hgext/shelve.py Wed Dec 19 13:35:11 2018 -0500
+++ b/hgext/shelve.py Mon May 07 17:08:17 2018 -0700
@@ -137,7 +137,7 @@
raise
raise error.Abort(_("shelved change '%s' not found") % self.name)
- def applybundle(self):
+ def applybundle(self, tr):
fp = self.opener()
try:
targetphase = phases.internal
@@ -145,7 +145,6 @@
targetphase = phases.secret
gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
pretip = self.repo['tip']
- tr = self.repo.currenttransaction()
bundle2.applybundle(self.repo, gen, tr,
source='unshelve',
url='bundle:' + self.vfs.join(self.fname),
@@ -324,10 +323,9 @@
if mark:
bookmarks.activate(repo, mark)
-def _aborttransaction(repo):
+def _aborttransaction(repo, tr):
'''Abort current transaction for shelve/unshelve, but keep dirstate
'''
- tr = repo.currenttransaction()
dirstatebackupname = 'dirstate.shelve'
narrowspecbackupname = 'narrowspec.shelve'
repo.dirstate.savebackup(tr, dirstatebackupname)
@@ -444,12 +442,11 @@
extra['shelve_unknown'] = '\0'.join(s.unknown)
repo[None].add(s.unknown)
-def _finishshelve(repo):
+def _finishshelve(repo, tr):
if phases.supportinternal(repo):
- tr = repo.currenttransaction()
tr.close()
else:
- _aborttransaction(repo)
+ _aborttransaction(repo, tr)
def createcmd(ui, repo, pats, opts):
"""subcommand that creates a new shelve"""
@@ -516,7 +513,7 @@
if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
repo.dirstate.setbranch(origbranch)
- _finishshelve(repo)
+ _finishshelve(repo, tr)
finally:
_restoreactivebookmark(repo, activebookmark)
lockmod.release(tr, lock)
@@ -791,7 +788,7 @@
tmpwctx = repo[node]
return tmpwctx, addedbefore
-def _unshelverestorecommit(ui, repo, basename):
+def _unshelverestorecommit(ui, repo, tr, basename):
"""Recreate commit in the repository during the unshelve"""
repo = repo.unfiltered()
node = None
@@ -799,7 +796,7 @@
node = shelvedfile(repo, basename, 'shelve').readinfo()['node']
if node is None or node not in repo:
with ui.configoverride({('ui', 'quiet'): True}):
- shelvectx = shelvedfile(repo, basename, 'hg').applybundle()
+ shelvectx = shelvedfile(repo, basename, 'hg').applybundle(tr)
# We might not strip the unbundled changeset, so we should keep track of
# the unshelve node in case we need to reuse it (eg: unshelve --keep)
if node is None:
@@ -879,7 +876,7 @@
# hooks still fire and try to operate on the missing commits.
# Clean up manually to prevent this.
repo.unfiltered().changelog.strip(oldtiprev, tr)
- _aborttransaction(repo)
+ _aborttransaction(repo, tr)
def _checkunshelveuntrackedproblems(ui, repo, shelvectx):
"""Check potential problems which may result from working
@@ -1023,7 +1020,7 @@
activebookmark = _backupactivebookmark(repo)
tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts,
tmpwctx)
- repo, shelvectx = _unshelverestorecommit(ui, repo, basename)
+ repo, shelvectx = _unshelverestorecommit(ui, repo, tr, basename)
_checkunshelveuntrackedproblems(ui, repo, shelvectx)
branchtorestore = ''
if shelvectx.branch() != shelvectx.p1().branch():