destupdate: include the 'check' logic
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 29 Sep 2015 00:18:49 -0700
changeset 26629 ae5f7be2b4ab
parent 26628 45b86dbabbda
child 26630 3111b45a2bbf
destupdate: include the 'check' logic After moving logic from 'merge.update' into 'destutil.destupdate', we are now moving logic from 'command.update' in 'destutil.destupdate'. This will make the function actually useful in predicting (and altering) the update behavior.
mercurial/commands.py
mercurial/destutil.py
--- a/mercurial/commands.py	Mon Oct 05 03:50:47 2015 -0700
+++ b/mercurial/commands.py	Tue Sep 29 00:18:49 2015 -0700
@@ -6595,10 +6595,8 @@
 
         if check:
             cmdutil.bailifchanged(repo, merge=False)
-            if rev is None:
-                rev = repo[repo[None].branch()].rev()
-        elif rev is None:
-            rev = destutil.destupdate(repo, clean=clean)
+        if rev is None:
+            rev = destutil.destupdate(repo, clean=clean, check=check)
 
         repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
 
--- a/mercurial/destutil.py	Mon Oct 05 03:50:47 2015 -0700
+++ b/mercurial/destutil.py	Tue Sep 29 00:18:49 2015 -0700
@@ -11,7 +11,7 @@
     obsolete,
 )
 
-def destupdate(repo, clean=False):
+def destupdate(repo, clean=False, check=False):
     """destination for bare update operation
     """
     # Here is where we should consider bookmarks, divergent bookmarks, and tip
@@ -71,7 +71,7 @@
                     hint = _("commit and merge, or update --clean to"
                              " discard changes")
                     raise error.Abort(msg, hint=hint)
-                else:  # destination is not a descendant.
+                elif not check:  # destination is not a descendant.
                     msg = _("not a linear update")
                     hint = _("merge or update --check to force update")
                     raise error.Abort(msg, hint=hint)