[PATCH 2 of 4] destupdate: include the 'check' logic

Augie Fackler raf at durin42.com
Fri Oct 9 10:06:19 CDT 2015


On Thu, Oct 08, 2015 at 02:42:16PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1443511129 25200
> #      Tue Sep 29 00:18:49 2015 -0700
> # Node ID 18cba2544597d954fde95ee36f6450faab57fcbc
> # Parent  6253db3dac7a5614020be223d0debdff9c2feefd
> destupdate: include the 'check' logic
>
> After moving logic from 'merge.update' into 'scmutil.destupdate', we are now

shouldn't this be destutil now?

> moving logic from 'command.update' in 'scmutil.destupdate'. This will make the
> function actually useful in predicting (and altering) the update behavior.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -6570,14 +6570,12 @@ def update(ui, repo, node=None, rev=None
>          if check and clean:
>              raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
>
>          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')
>
>          if clean:
>              ret = hg.clean(repo, rev)
> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
> --- a/mercurial/destutil.py
> +++ b/mercurial/destutil.py
> @@ -10,11 +10,11 @@ from . import (
>      error,
>      util,
>      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
>      # of current branch; but currently we are only checking the branch tips.
>      node = None
> @@ -70,11 +70,11 @@ def destupdate(repo, clean=False):
>                  if dirty:
>                      msg = _("uncommitted changes")
>                      hint = _("commit and merge, or update --clean to"
>                               " discard changes")
>                      raise util.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 util.Abort(msg, hint=hint)
>
>      return rev
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list