Patchwork [Bug,5461] New: Diff that ignores whitespace is incorrect in some cases

login
register
mail settings
Submitter mercurial-bugs@mercurial-scm.org
Date Jan. 10, 2017, 6 p.m.
Message ID <bug-5461-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/18173/
State Not Applicable
Headers show

Comments

mercurial-bugs@mercurial-scm.org - Jan. 10, 2017, 6 p.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=5461

            Bug ID: 5461
           Summary: Diff that ignores whitespace is incorrect in some
                    cases
           Product: Mercurial
           Version: 4.0.2
          Hardware: PC
                OS: Mac OS
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla@mercurial-scm.org
          Reporter: nathan12343@gmail.com
                CC: mercurial-devel@selenic.com

This originally showed up as a rendering bug on a bitbucket pull request:

https://bitbucket.org/yt_analysis/yt/pull-requests/2487/visualize-variables-on-multiple-mesh/diff?w=1#comment-29467805

This appears to be a syntax error since the line after the one I linked to
isn't getting indented correctly. 

After asking on the bitbucket IRC channel, it turns out that this is actually
coming from mercurial itself (bitbucket is just rendering the output of `hg
             buff_size = size[0:dimension] + (1,) + size[dimension:]

Patch

diff -w` here.

One can reproduce this using the following steps:

$ hg clone https://bitbucket.org/ngoldbaum/yt yt-ng
$ cd yt-ng
$ hg diff -w -r 98bb0abc0b14 -r 1b17fcd
yt/geometry/coordinates/cartesian_coordinates.py

The output from this command is here:

diff --git a/yt/geometry/coordinates/cartesian_coordinates.py
b/yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -68,11 +68,17 @@  class CartesianCoordinateHandler(Coordin
         if (hasattr(index, 'meshes') and
            not isinstance(index.meshes[0], SemiStructuredMesh)):
             ftype, fname = field
+            if ftype == "all":
+                mesh_id = 0
+                indices = index.meshes[0].connectivity_indices
+                for i in range(1, len(index.meshes)):
+                    indices = np.concatenate((indices,
index.meshes[i].connectivity_indices))
+            else:
             mesh_id = int(ftype[-1]) - 1
-            mesh = index.meshes[mesh_id]
-            coords = mesh.connectivity_coords
-            indices = mesh.connectivity_indices
-            offset = mesh._index_offset
+                indices = index.meshes[mesh_id].connectivity_indices
+
+            coords = index.meshes[mesh_id].connectivity_coords
+            offset = index.meshes[mesh_id]._index_offset
             ad = data_source.ds.all_data()
             field_data = ad[field]
             buff_size = size[0:dimension] + (1,) + size[dimension:]

And the output of `hg diff -r 98bb0abc0b14 -r 1b17fcd
yt/geometry/coordinates/cartesian_coordinates.py`, which is correct:

diff --git a/yt/geometry/coordinates/cartesian_coordinates.py
b/yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -68,11 +68,17 @@  class CartesianCoordinateHandler(Coordin
         if (hasattr(index, 'meshes') and
            not isinstance(index.meshes[0], SemiStructuredMesh)):
             ftype, fname = field
-            mesh_id = int(ftype[-1]) - 1
-            mesh = index.meshes[mesh_id]
-            coords = mesh.connectivity_coords
-            indices = mesh.connectivity_indices
-            offset = mesh._index_offset
+            if ftype == "all":
+                mesh_id = 0
+                indices = index.meshes[0].connectivity_indices
+                for i in range(1, len(index.meshes)):
+                    indices = np.concatenate((indices,
index.meshes[i].connectivity_indices))
+            else:
+                mesh_id = int(ftype[-1]) - 1
+                indices = index.meshes[mesh_id].connectivity_indices
+
+            coords = index.meshes[mesh_id].connectivity_coords
+            offset = index.meshes[mesh_id]._index_offset
             ad = data_source.ds.all_data()
             field_data = ad[field]