[PATCH 2 of 2 default-dest] update: introduce a 'UpdateAbort' exception
Augie Fackler
raf at durin42.com
Thu Oct 15 08:22:41 CDT 2015
On Thu, Oct 15, 2015 at 01:05:40AM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1444044386 25200
> # Mon Oct 05 04:26:26 2015 -0700
> # Node ID d167df335d7de382a333a86d813399dc6817b19d
> # Parent f005ccc592ba7bff1232c2f07061a0909d1d1496
> # EXP-Topic defaultdest
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> # hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r d167df335d7d
> update: introduce a 'UpdateAbort' exception
queued with some minor tweaks
>
> The 'postincoming' function used by 'hg pull --update' and 'hg unbundle' is
> catching 'Abort' exceptions to intercept failed update. This feel like abit too
> wide to me, so I'm introducing a more precise exception to specify update
> destination issue.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5194,11 +5194,11 @@ def postincoming(ui, repo, modheads, opt
> movemarkfrom = None
> if not checkout:
> updata = destutil.destupdate(repo)
> checkout, movemarkfrom, brev = updata
> ret = hg.update(repo, checkout)
> - except error.Abort as inst:
> + except error.UpdateAbort as inst:
> ui.warn(_("not updating: %s\n") % str(inst))
> if inst.hint:
> ui.warn(_("(%s)\n") % inst.hint)
> return 0
> if not ret and not checkout:
> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
> --- a/mercurial/destutil.py
> +++ b/mercurial/destutil.py
> @@ -82,12 +82,12 @@ def destupdate(repo, clean=False, check=
> if not repo[rev].node() in foreground:
> if dirty:
> msg = _("uncommitted changes")
> hint = _("commit and merge, or update --clean to"
> " discard changes")
> - raise error.Abort(msg, hint=hint)
> + raise error.UpdateAbort(msg, hint=hint)
> 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)
> + raise error.UpdateAbort(msg, hint=hint)
>
> return rev, movemark, activemark
> diff --git a/mercurial/error.py b/mercurial/error.py
> --- a/mercurial/error.py
> +++ b/mercurial/error.py
> @@ -64,10 +64,14 @@ class HookAbort(Abort):
> pass
>
> class ConfigError(Abort):
> """Exception raised when parsing config files"""
>
> +class UpdateAbort(Abort):
> + """Raised when an update is aborted for destination issue"""
> + pass
> +
> class OutOfBandError(Exception):
> """Exception raised when a remote repo reports failure"""
>
> def __init__(self, *args, **kw):
> Exception.__init__(self, *args)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list