comparison hgext/rebase.py @ 38495:ba6d2c32f34a

rebase: add lock to cover whole dryrun process Before this patch it is easy for another hg to interrupt the dryrun. This patch make sure that dryrun will complete without any interruption. Differential Revision: https://phab.mercurial-scm.org/D3854
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Thu, 28 Jun 2018 23:36:45 +0530
parents 2394cd58b81f
children c92fdc27cbdd
comparison
equal deleted inserted replaced
38494:d4be8ea8f22d 38495:ba6d2c32f34a
816 userrevs = list(repo.revs(opts.get(r'auto_orphans'))) 816 userrevs = list(repo.revs(opts.get(r'auto_orphans')))
817 opts[r'rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] 817 opts[r'rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)]
818 opts[r'dest'] = '_destautoorphanrebase(SRC)' 818 opts[r'dest'] = '_destautoorphanrebase(SRC)'
819 819
820 if dryrun: 820 if dryrun:
821 leaveunfinished = True 821 rbsrt = rebaseruntime(repo, ui, inmemory=True,
822 inmemory = True 822 opts=pycompat.byteskwargs(opts))
823 rbsrt = rebaseruntime(repo, ui, inmemory, pycompat.byteskwargs(opts)) 823 with repo.wlock(), repo.lock():
824 try: 824 try:
825 overrides = {('rebase', 'singletransaction'): True} 825 overrides = {('rebase', 'singletransaction'): True}
826 with ui.configoverride(overrides, 'rebase'): 826 with ui.configoverride(overrides, 'rebase'):
827 _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt, 827 _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
828 leaveunfinished=leaveunfinished, **opts) 828 leaveunfinished=True, **opts)
829 except error.InMemoryMergeConflictsError: 829 except error.InMemoryMergeConflictsError:
830 ui.status(_('hit a merge conflict\n')) 830 ui.status(_('hit a merge conflict\n'))
831 return 1 831 return 1
832 else: 832 else:
833 ui.status(_('there will be no conflict, you can rebase\n')) 833 ui.status(_('there will be no conflict, you can rebase\n'))
834 return 0 834 return 0
835 finally: 835 finally:
836 with repo.wlock(), repo.lock():
837 rbsrt._prepareabortorcontinue(isabort=True) 836 rbsrt._prepareabortorcontinue(isabort=True)
838 elif inmemory: 837 elif inmemory:
839 try: 838 try:
840 # in-memory merge doesn't support conflicts, so if we hit any, abort 839 # in-memory merge doesn't support conflicts, so if we hit any, abort
841 # and re-run as an on-disk merge. 840 # and re-run as an on-disk merge.