##// END OF EJS Templates
rebase: use one dirstateguard for when using rebase.singletransaction...
Durham Goode -
r33621:609606d2 default
parent child Browse files
Show More
@@ -479,12 +479,17 b' class rebaseruntime(object):'
479 479 editopt = True
480 480 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
481 481 revtoreuse = max(self.state)
482 newnode = concludenode(repo, revtoreuse, p1, self.external,
483 commitmsg=commitmsg,
484 extrafn=_makeextrafn(self.extrafns),
485 editor=editor,
486 keepbranches=self.keepbranchesf,
487 date=self.date)
482
483 dsguard = None
484 if ui.configbool('rebase', 'singletransaction'):
485 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
486 with util.acceptintervention(dsguard):
487 newnode = concludenode(repo, revtoreuse, p1, self.external,
488 commitmsg=commitmsg,
489 extrafn=_makeextrafn(self.extrafns),
490 editor=editor,
491 keepbranches=self.keepbranchesf,
492 date=self.date)
488 493 if newnode is None:
489 494 newrev = self.dest
490 495 else:
@@ -711,10 +716,16 b' def rebase(ui, repo, **opts):'
711 716 return retcode
712 717
713 718 tr = None
714 if ui.configbool('rebase', 'singletransaction'):
719 dsguard = None
720
721 singletr = ui.configbool('rebase', 'singletransaction')
722 if singletr:
715 723 tr = repo.transaction('rebase')
716 724 with util.acceptintervention(tr):
717 rbsrt._performrebase(tr)
725 if singletr:
726 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
727 with util.acceptintervention(dsguard):
728 rbsrt._performrebase(tr)
718 729
719 730 rbsrt._finishrebase()
720 731
@@ -841,8 +852,10 b' def concludenode(repo, rev, p1, p2, comm'
841 852 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
842 853 but also store useful information in extra.
843 854 Return node of committed revision.'''
844 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
845 try:
855 dsguard = util.nullcontextmanager()
856 if not repo.ui.configbool('rebase', 'singletransaction'):
857 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
858 with dsguard:
846 859 repo.setparents(repo[p1].node(), repo[p2].node())
847 860 ctx = repo[rev]
848 861 if commitmsg is None:
@@ -864,10 +877,7 b' def concludenode(repo, rev, p1, p2, comm'
864 877 date=date, extra=extra, editor=editor)
865 878
866 879 repo.dirstate.setbranch(repo[newnode].branch())
867 dsguard.close()
868 880 return newnode
869 finally:
870 release(dsguard)
871 881
872 882 def rebasenode(repo, rev, p1, base, state, collapse, dest):
873 883 'Rebase a single revision rev on top of p1 using base as merge ancestor'
@@ -43,6 +43,16 b' class dirstateguard(object):'
43 43 # ``release(tr, ....)``.
44 44 self._abort()
45 45
46 def __enter__(self):
47 return self
48
49 def __exit__(self, exc_type, exc_val, exc_tb):
50 try:
51 if exc_type is None:
52 self.close()
53 finally:
54 self.release()
55
46 56 def close(self):
47 57 if not self._active: # already inactivated
48 58 msg = (_("can't close already inactivated backup: %s")
@@ -602,6 +602,10 b' def acceptintervention(tr=None):'
602 602 finally:
603 603 tr.release()
604 604
605 @contextlib.contextmanager
606 def nullcontextmanager():
607 yield
608
605 609 class _lrucachenode(object):
606 610 """A node in a doubly linked list.
607 611
@@ -379,3 +379,40 b' Multiple roots. Two children share two p'
379 379 /
380 380 o 0: A
381 381
382 Rebasing using a single transaction
383
384 $ hg init singletr && cd singletr
385 $ cat >> .hg/hgrc <<EOF
386 > [rebase]
387 > singletransaction=True
388 > EOF
389 $ hg debugdrawdag <<'EOF'
390 > Z
391 > |
392 > | D
393 > | |
394 > | C
395 > | |
396 > Y B
397 > |/
398 > A
399 > EOF
400 - We should only see two status stored messages. One from the start, one from
401 - the end.
402 $ hg rebase --debug -b D -d Z | grep 'status stored'
403 rebase status stored
404 rebase status stored
405 $ hg tglog
406 o 5: D
407 |
408 o 4: C
409 |
410 o 3: B
411 |
412 o 2: Z
413 |
414 o 1: Y
415 |
416 o 0: A
417
418 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now