D7825: rebase: delete seemingly unnecessary needupdate()

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Jan 11 06:47:54 UTC 2020


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This seemed to be about checking that the user hasn't updated away
  when we asked them to resolve merge conflicts. These days we call
  `cmdutil.checkunfinished()` and refuse to update, so the user
  shouldn't be able to get into this state.
  
  `test-rebase-interruptions.t` actually has some tests where it
  disables the rebase extension in order to be allowed to do some of
  these updates. That still passes, but I wouldn't personally haved
  cared if that failed.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -798,7 +798,7 @@
                 shouldupdate = repo[b'.'].rev() in updateifonnodes
 
                 # Update away from the rebase if necessary
-                if shouldupdate or needupdate(repo, self.state):
+                if shouldupdate:
                     mergemod.update(
                         repo, self.originalwd, branchmerge=False, force=True
                     )
@@ -1056,10 +1056,9 @@
                         b'changesets'
                     ),
                 )
-            if needupdate(repo, rbsrt.state):
-                # update to the current working revision
-                # to clear interrupted merge
-                hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
+            # update to the current working revision
+            # to clear interrupted merge
+            hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
             rbsrt._finishrebase()
             return 0
     elif inmemory:
@@ -1924,25 +1923,6 @@
     repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
 
 
-def needupdate(repo, state):
-    '''check whether we should `update --clean` away from a merge, or if
-    somehow the working dir got forcibly updated, e.g. by older hg'''
-    parents = [p.rev() for p in repo[None].parents()]
-
-    # Are we in a merge state at all?
-    if len(parents) < 2:
-        return False
-
-    # We should be standing on the first as-of-yet unrebased commit.
-    firstunrebased = min(
-        [old for old, new in pycompat.iteritems(state) if new == nullrev]
-    )
-    if firstunrebased in parents:
-        return True
-
-    return False
-
-
 def sortsource(destmap):
     """yield source revisions in an order that we only rebase things once
 



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


More information about the Mercurial-devel mailing list