[Updated] [+- ] D9066: merge: add a higher-level update() for the common `hg update` use case

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Sep 24 15:24:05 UTC 2020


martinvonz updated this revision to Diff 22833.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9066?vs=22807&id=22833

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9066/new/

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

AFFECTED FILES
  hgext/rebase.py
  hgext/transplant.py
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -2056,6 +2056,23 @@
     )
 
 
+def update(ctx, updatecheck=None, wc=None):
+    """Do a regular update to the given commit, aborting if there are conflicts.
+
+    The 'updatecheck' argument can be used to control what to do in case of
+    conflicts.
+    """
+    return _update(
+        ctx.repo(),
+        ctx.rev(),
+        branchmerge=False,
+        force=False,
+        labels=[b'working copy', b'destination'],
+        updatecheck=updatecheck,
+        wc=wc,
+    )
+
+
 def clean_update(ctx, wc=None):
     """Do a clean update to the given commit.
 
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -198,9 +198,7 @@
                     if pulls:
                         if source != repo:
                             exchange.pull(repo, source.peer(), heads=pulls)
-                        merge._update(
-                            repo, pulls[-1], branchmerge=False, force=False
-                        )
+                        merge.update(repo[pulls[-1]])
                         p1 = repo.dirstate.p1()
                         pulls = []
 
@@ -275,7 +273,7 @@
             tr.close()
             if pulls:
                 exchange.pull(repo, source.peer(), heads=pulls)
-                merge._update(repo, pulls[-1], branchmerge=False, force=False)
+                merge.update(repo[pulls[-1]])
         finally:
             self.saveseries(revmap, merges)
             self.transplants.write()
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -642,13 +642,7 @@
                         cmdutil.bailifchanged(repo)
                         self.inmemory = False
                         self._assignworkingcopy()
-                        mergemod._update(
-                            repo,
-                            p1,
-                            branchmerge=False,
-                            force=False,
-                            wc=self.wctx,
-                        )
+                        mergemod.update(repo[p1], wc=self.wctx)
                         rebasenode(
                             repo,
                             rev,



To: martinvonz, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200924/00dc731b/attachment-0002.html>


More information about the Mercurial-patches mailing list