Patchwork [7,of,7] trydiff: transpose 'if opts.git or losedatafn' with 'if f[12]'

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 7, 2015, 1:13 a.m.
Message ID <f2115c93df5a61d84cc7.1423271616@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7737/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Feb. 7, 2015, 1:13 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1423267783 28800
#      Fri Feb 06 16:09:43 2015 -0800
# Node ID f2115c93df5a61d84cc71028fdb9abfa5b72b2ef
# Parent  889cc5e8b38f2d4390e64acc488403081fa261a9
trydiff: transpose 'if opts.git or losedatafn' with 'if f[12]'

Perhaps it's more readable this way...
Augie Fackler - Feb. 10, 2015, 6:18 p.m.
On Fri, Feb 06, 2015 at 05:13:36PM -0800, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1423267783 28800
> #      Fri Feb 06 16:09:43 2015 -0800
> # Node ID f2115c93df5a61d84cc71028fdb9abfa5b72b2ef
> # Parent  889cc5e8b38f2d4390e64acc488403081fa261a9
> trydiff: transpose 'if opts.git or losedatafn' with 'if f[12]'

Queued these, thanks.

>
> Perhaps it's more readable this way...
>
> diff -r 889cc5e8b38f -r f2115c93df5a mercurial/patch.py
> --- a/mercurial/patch.py	Thu Jan 22 23:29:00 2015 -0800
> +++ b/mercurial/patch.py	Fri Feb 06 16:09:43 2015 -0800
> @@ -1804,18 +1804,18 @@
>              ctx1, modified, added, removed, copy, opts):
>          content1 = None
>          content2 = None
> +        flag1 = None
> +        flag2 = None
>          if f1:
>              content1 = getfilectx(f1, ctx1).data()
> +            if opts.git or losedatafn:
> +                flag1 = ctx1.flags(f1)
>          if f2:
>              content2 = getfilectx(f2, ctx2).data()
> -        flag1 = None
> -        flag2 = None
> +            if opts.git or losedatafn:
> +                flag2 = ctx2.flags(f2)
>          binary = False
>          if opts.git or losedatafn:
> -            if f1:
> -                flag1 = ctx1.flags(f1)
> -            if f2:
> -                flag2 = ctx2.flags(f2)
>              binary = util.binary(content1) or util.binary(content2)
>
>          if losedatafn and not opts.git:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 889cc5e8b38f -r f2115c93df5a mercurial/patch.py
--- a/mercurial/patch.py	Thu Jan 22 23:29:00 2015 -0800
+++ b/mercurial/patch.py	Fri Feb 06 16:09:43 2015 -0800
@@ -1804,18 +1804,18 @@ 
             ctx1, modified, added, removed, copy, opts):
         content1 = None
         content2 = None
+        flag1 = None
+        flag2 = None
         if f1:
             content1 = getfilectx(f1, ctx1).data()
+            if opts.git or losedatafn:
+                flag1 = ctx1.flags(f1)
         if f2:
             content2 = getfilectx(f2, ctx2).data()
-        flag1 = None
-        flag2 = None
+            if opts.git or losedatafn:
+                flag2 = ctx2.flags(f2)
         binary = False
         if opts.git or losedatafn:
-            if f1:
-                flag1 = ctx1.flags(f1)
-            if f2:
-                flag2 = ctx2.flags(f2)
             binary = util.binary(content1) or util.binary(content2)
 
         if losedatafn and not opts.git: