[PATCH evolve-ext] inhbit: don't crash on commit with no changes

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu May 21 23:32:49 CDT 2015



On 05/21/2015 07:44 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1432144712 25200
> #      Wed May 20 10:58:32 2015 -0700
> # Node ID f2dacc9545308e1805861ae39820efeea79b6e11
> # Parent  bc9f871734475292c48dfe54e3040601b32ae4c8
> inhbit: don't crash on commit with no changes

Awesome. pushed to main.

>
> Before this patch inhibit would crash when running hg amend with no changes.
> This patch fixes this case and adds a test to prevent regression.
>
> diff --git a/hgext/inhibit.py b/hgext/inhibit.py
> --- a/hgext/inhibit.py
> +++ b/hgext/inhibit.py
> @@ -43,7 +43,8 @@
>
>           def commit(self, *args, **kwargs):
>               newnode = super(obsinhibitedrepo, self).commit(*args, **kwargs)
> -            _inhibitmarkers(repo, [newnode])
> +            if newnode is not None:
> +                _inhibitmarkers(repo, [newnode])
>               return newnode
>
>       repo.__class__ = obsinhibitedrepo
> diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
> --- a/tests/test-inhibit.t
> +++ b/tests/test-inhibit.t
> @@ -594,15 +594,22 @@
>     |
>     o  0:54ccbc537fc2 add cA
>
> +  $ cat >> $HGRCPATH <<EOF
> +  > [extensions]
> +  > EOF
> +  $ echo "inhibit=$(echo $(dirname $TESTDIR))/hgext/inhibit.py" >> $HGRCPATH
> +
> +Empty commit
> +  $ hg amend
> +  nothing changed
> +  [1]
>
>   Inhibit should not work without directaccess
>     $ cat >> $HGRCPATH <<EOF
>     > [extensions]
>     > directaccess=!
>     > EOF
> -  $ echo "inhibit=$(echo $(dirname $TESTDIR))/hgext/inhibit.py" >> $HGRCPATH
> -
>     $ hg up 15
>     abort: Cannot use inhibit without the direct access extension
>     [255]
> -
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list