Patchwork [1,of,2] patches: move assignment outside the conditional

login
register
mail settings
Submitter Boris Feld
Date Feb. 6, 2018, 2:28 p.m.
Message ID <eee9cca843bc55727494.1517927282@FB>
Download mbox | patch
Permalink /patch/27379/
State Accepted
Headers show

Comments

Boris Feld - Feb. 6, 2018, 2:28 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1517923456 -3600
#      Tue Feb 06 14:24:16 2018 +0100
# Node ID eee9cca843bc557274945688ea52e16539d45e67
# Parent  1a31111e6239a2eb841a5dce5e1cf8212c54bf33
# EXP-Topic parallel-patching
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r eee9cca843bc
patches: move assignment outside the conditional

Having this movement in its own patch will make the next patch clearer.
Gregory Szorc - Feb. 6, 2018, 9:14 p.m.
On Tue, Feb 6, 2018 at 6:28 AM, Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1517923456 -3600
> #      Tue Feb 06 14:24:16 2018 +0100
> # Node ID eee9cca843bc557274945688ea52e16539d45e67
> # Parent  1a31111e6239a2eb841a5dce5e1cf8212c54bf33
> # EXP-Topic parallel-patching
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> eee9cca843bc
> patches: move assignment outside the conditional
>
> Having this movement in its own patch will make the next patch clearer.
>

Queued part 1.


>
> diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
> --- a/mercurial/cext/mpatch.c
> +++ b/mercurial/cext/mpatch.c
> @@ -110,7 +110,8 @@ patches(PyObject *self, PyObject *args)
>                 goto cleanup;
>         }
>         out = PyBytes_AsString(result);
> -       if ((r = mpatch_apply(out, in, inlen, patch)) < 0) {
> +       r = mpatch_apply(out, in, inlen, patch);
> +       if (r < 0) {
>                 Py_DECREF(result);
>                 result = NULL;
>         }
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
--- a/mercurial/cext/mpatch.c
+++ b/mercurial/cext/mpatch.c
@@ -110,7 +110,8 @@  patches(PyObject *self, PyObject *args)
 		goto cleanup;
 	}
 	out = PyBytes_AsString(result);
-	if ((r = mpatch_apply(out, in, inlen, patch)) < 0) {
+	r = mpatch_apply(out, in, inlen, patch);
+	if (r < 0) {
 		Py_DECREF(result);
 		result = NULL;
 	}