changeset 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 d4be8ea8f22d
children c92fdc27cbdd
files hgext/rebase.py
diffstat 1 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue May 29 00:26:20 2018 +0200
+++ b/hgext/rebase.py	Thu Jun 28 23:36:45 2018 +0530
@@ -818,22 +818,21 @@
         opts[r'dest'] = '_destautoorphanrebase(SRC)'
 
     if dryrun:
-        leaveunfinished = True
-        inmemory = True
-        rbsrt = rebaseruntime(repo, ui, inmemory, pycompat.byteskwargs(opts))
-        try:
-            overrides = {('rebase', 'singletransaction'): True}
-            with ui.configoverride(overrides, 'rebase'):
-                _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
-                            leaveunfinished=leaveunfinished, **opts)
-        except error.InMemoryMergeConflictsError:
-            ui.status(_('hit a merge conflict\n'))
-            return 1
-        else:
-            ui.status(_('there will be no conflict, you can rebase\n'))
-            return 0
-        finally:
-            with repo.wlock(), repo.lock():
+        rbsrt = rebaseruntime(repo, ui, inmemory=True,
+                              opts=pycompat.byteskwargs(opts))
+        with repo.wlock(), repo.lock():
+            try:
+                overrides = {('rebase', 'singletransaction'): True}
+                with ui.configoverride(overrides, 'rebase'):
+                    _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
+                                leaveunfinished=True, **opts)
+            except error.InMemoryMergeConflictsError:
+                ui.status(_('hit a merge conflict\n'))
+                return 1
+            else:
+                ui.status(_('there will be no conflict, you can rebase\n'))
+                return 0
+            finally:
                 rbsrt._prepareabortorcontinue(isabort=True)
     elif inmemory:
         try: