Patchwork D2876: rebase: allow in-memory merge of the working copy parent

login
register
mail settings
Submitter phabricator
Date March 15, 2018, 8:20 p.m.
Message ID <differential-rev-PHID-DREV-734jcvnbxfcd3rrsxhsg-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29551/
State Superseded
Headers show

Comments

phabricator - March 15, 2018, 8:20 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this patch and when the rebase involved the working copy parent
  (and thus the working copy too), we would not do in-memory rebase even
  if requested to. The in-code comment explains that the reason had
  something to do with avoiding an extra update, but I don't know which
  update that refers to. Perhaps an earlier version of the code used to
  update to the destination before rebasing even if in-memory rebase was
  requested? That seems to not be done at least since https://phab.mercurial-scm.org/rHGaa660c1203a9e10b679fa6deee2e0e943e97cc95
  (rebase: do not bail on uncomitted changes if rebasing in-memory,
  2017-12-07).
  
  To see if this still made it slower, I create a single tiny commit on
  top of one branch of the mozilla-unified repo (commit a1098c82 to be
  exact) and rebased it to another branch (commit d4e9a7be). Before this
  patch that took 11.8s and after this patch it took 8.6s (I only did
  two runs each, but the timings were very consistent).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-inmemory.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -140,12 +140,11 @@ 
   $ ls -l f | cut -c -10
   -rwxr-xr-x
 
-Rebase the working copy parent, which should default to an on-disk merge even if
-we requested in-memory.
+Rebase the working copy parent
   $ hg up -C 3
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg rebase -r 3 -d 0 --debug | grep rebasing
-  rebasing on disk
+  rebasing in-memory
   rebasing 3:753feb6fd12a "c" (tip)
   $ hg tglog
   @  3: 844a7de3e617 'c'
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -599,8 +599,7 @@ 
         if newwd < 0:
             # original directory is a parent of rebase set root or ignored
             newwd = self.originalwd
-        if (newwd not in [c.rev() for c in repo[None].parents()] and
-                not self.inmemory):
+        if newwd not in [c.rev() for c in repo[None].parents()]:
             ui.note(_("update back to initial working directory parent\n"))
             hg.updaterepo(repo, newwd, False)
 
@@ -957,20 +956,10 @@ 
                 ui.status(_('nothing to rebase from %s to %s\n') %
                           ('+'.join(bytes(repo[r]) for r in base), dest))
             return None
-    # If rebasing the working copy parent, force in-memory merge to be off.
-    #
-    # This is because the extra work of checking out the newly rebased commit
-    # outweights the benefits of rebasing in-memory, and executing an extra
-    # update command adds a bit of overhead, so better to just do it on disk. In
-    # all other cases leave it on.
-    #
-    # Note that there are cases where this isn't true -- e.g., rebasing large
-    # stacks that include the WCP. However, I'm not yet sure where the cutoff
-    # is.
+
     rebasingwcp = repo['.'].rev() in rebaseset
     ui.log("rebase", "", rebase_rebasing_wcp=rebasingwcp)
     if rbsrt.inmemory and rebasingwcp:
-        rbsrt.inmemory = False
         # Check these since we did not before.
         cmdutil.checkunfinished(repo)
         cmdutil.bailifchanged(repo)