Patchwork D3854: rebase: add lock to cover whole dryrun process

login
register
mail settings
Submitter phabricator
Date June 28, 2018, 8:09 p.m.
Message ID <differential-rev-PHID-DREV-ej6h52llceh6tukaio25-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32489/
State Superseded
Headers show

Comments

phabricator - June 28, 2018, 8:09 p.m.
khanchi97 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this patch it is easy for another hg to interrupt
  the dryrun. This patch make sure that dryrun will complete
  without any interruption.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3854

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - June 29, 2018, 12:57 p.m.
>      if dryrun:
> -        leaveunfinished = True
> -        inmemory = True
>          rbsrt = rebaseruntime(repo, ui, inmemory, opts)

Perhaps this is wrong. inmemory should be set to True, right?
phabricator - June 29, 2018, 1:03 p.m.
yuja added a comment.


  >   if dryrun:
  > 
  > - leaveunfinished = True
  > - inmemory = True rbsrt = rebaseruntime(repo, ui, inmemory, opts)
  
  Perhaps this is wrong. inmemory should be set to True, right?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3854

To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - June 29, 2018, 1:46 p.m.
khanchi97 added a comment.


  In https://phab.mercurial-scm.org/D3854#60248, @yuja wrote:
  
  > >   if dryrun:
  > > 
  > > - leaveunfinished = True
  > > - inmemory = True rbsrt = rebaseruntime(repo, ui, inmemory, opts)
  >
  > Perhaps this is wrong. inmemory should be set to True, right?
  
  
  Oops!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3854

To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -818,22 +818,20 @@ 
         opts[r'dest'] = '_destautoorphanrebase(SRC)'
 
     if dryrun:
-        leaveunfinished = True
-        inmemory = True
         rbsrt = rebaseruntime(repo, ui, inmemory, 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():
+        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: