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

mercurial-bugs at mercurial-scm.org mercurial-bugs at mercurial-scm.org
Tue Jan 10 18:00:09 UTC 2017


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 at mercurial-scm.org
          Reporter: nathan12343 at gmail.com
                CC: mercurial-devel at 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
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]
             buff_size = size[0:dimension] + (1,) + size[dimension:]

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list