##// END OF EJS Templates
shelve: pass transaction around to clarify where it's used...
Martin von Zweigbergk -
r41043:a06dc62f default
parent child Browse files
Show More
@@ -137,7 +137,7 b' class shelvedfile(object):'
137 137 raise
138 138 raise error.Abort(_("shelved change '%s' not found") % self.name)
139 139
140 def applybundle(self):
140 def applybundle(self, tr):
141 141 fp = self.opener()
142 142 try:
143 143 targetphase = phases.internal
@@ -145,7 +145,6 b' class shelvedfile(object):'
145 145 targetphase = phases.secret
146 146 gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
147 147 pretip = self.repo['tip']
148 tr = self.repo.currenttransaction()
149 148 bundle2.applybundle(self.repo, gen, tr,
150 149 source='unshelve',
151 150 url='bundle:' + self.vfs.join(self.fname),
@@ -324,10 +323,9 b' def _restoreactivebookmark(repo, mark):'
324 323 if mark:
325 324 bookmarks.activate(repo, mark)
326 325
327 def _aborttransaction(repo):
326 def _aborttransaction(repo, tr):
328 327 '''Abort current transaction for shelve/unshelve, but keep dirstate
329 328 '''
330 tr = repo.currenttransaction()
331 329 dirstatebackupname = 'dirstate.shelve'
332 330 narrowspecbackupname = 'narrowspec.shelve'
333 331 repo.dirstate.savebackup(tr, dirstatebackupname)
@@ -444,12 +442,11 b' def _includeunknownfiles(repo, pats, opt'
444 442 extra['shelve_unknown'] = '\0'.join(s.unknown)
445 443 repo[None].add(s.unknown)
446 444
447 def _finishshelve(repo):
445 def _finishshelve(repo, tr):
448 446 if phases.supportinternal(repo):
449 tr = repo.currenttransaction()
450 447 tr.close()
451 448 else:
452 _aborttransaction(repo)
449 _aborttransaction(repo, tr)
453 450
454 451 def createcmd(ui, repo, pats, opts):
455 452 """subcommand that creates a new shelve"""
@@ -516,7 +513,7 b' def _docreatecmd(ui, repo, pats, opts):'
516 513 if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
517 514 repo.dirstate.setbranch(origbranch)
518 515
519 _finishshelve(repo)
516 _finishshelve(repo, tr)
520 517 finally:
521 518 _restoreactivebookmark(repo, activebookmark)
522 519 lockmod.release(tr, lock)
@@ -791,7 +788,7 b' def _commitworkingcopychanges(ui, repo, '
791 788 tmpwctx = repo[node]
792 789 return tmpwctx, addedbefore
793 790
794 def _unshelverestorecommit(ui, repo, basename):
791 def _unshelverestorecommit(ui, repo, tr, basename):
795 792 """Recreate commit in the repository during the unshelve"""
796 793 repo = repo.unfiltered()
797 794 node = None
@@ -799,7 +796,7 b' def _unshelverestorecommit(ui, repo, bas'
799 796 node = shelvedfile(repo, basename, 'shelve').readinfo()['node']
800 797 if node is None or node not in repo:
801 798 with ui.configoverride({('ui', 'quiet'): True}):
802 shelvectx = shelvedfile(repo, basename, 'hg').applybundle()
799 shelvectx = shelvedfile(repo, basename, 'hg').applybundle(tr)
803 800 # We might not strip the unbundled changeset, so we should keep track of
804 801 # the unshelve node in case we need to reuse it (eg: unshelve --keep)
805 802 if node is None:
@@ -879,7 +876,7 b' def _finishunshelve(repo, oldtiprev, tr,'
879 876 # hooks still fire and try to operate on the missing commits.
880 877 # Clean up manually to prevent this.
881 878 repo.unfiltered().changelog.strip(oldtiprev, tr)
882 _aborttransaction(repo)
879 _aborttransaction(repo, tr)
883 880
884 881 def _checkunshelveuntrackedproblems(ui, repo, shelvectx):
885 882 """Check potential problems which may result from working
@@ -1023,7 +1020,7 b' def _dounshelve(ui, repo, *shelved, **op'
1023 1020 activebookmark = _backupactivebookmark(repo)
1024 1021 tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts,
1025 1022 tmpwctx)
1026 repo, shelvectx = _unshelverestorecommit(ui, repo, basename)
1023 repo, shelvectx = _unshelverestorecommit(ui, repo, tr, basename)
1027 1024 _checkunshelveuntrackedproblems(ui, repo, shelvectx)
1028 1025 branchtorestore = ''
1029 1026 if shelvectx.branch() != shelvectx.p1().branch():
General Comments 0
You need to be logged in to leave comments. Login now