changeset ac9e1a3bed79 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=ac9e1a3bed79
description:
        style: Change include sorter to yield one line at a time

        The include sorter class normally yields one string per line and
        relies on the caller to merge lines into a block of text separated by
        newlines. However, there are cases when this isn't true. This makes
        diffing using Python's difflib hard. This changeset updates the
        include sorter to never do this and always yield one line at a time.

        Signed-off-by: Andreas Sandberg <[email protected]>
        Reviewed-by: Curtis Dunham <[email protected]>
        Reviewed-by: Steve Reinhardt <[email protected]>

diffstat:

 util/sort_includes.py |  22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diffs (49 lines):

diff -r 55f9a21e34b4 -r ac9e1a3bed79 util/sort_includes.py
--- a/util/sort_includes.py     Wed Mar 30 15:29:42 2016 +0100
+++ b/util/sort_includes.py     Wed Mar 30 15:30:05 2016 +0100
@@ -204,17 +204,15 @@
         return sorted(set(includes))
 
     def dump_includes(self):
-        blocks = []
-        # Create a list of blocks in the prescribed include
-        # order. Each entry in the list is a multi-line string with
-        # multiple includes.
+        includes = []
         for types in self.block_order:
-            block = "\n".join(self.dump_blocks(types))
-            if block:
-                blocks.append(block)
+            block = self.dump_blocks(types)
+            if includes and block:
+                includes.append("")
+            includes += block
 
         self.reset()
-        return "\n\n".join(blocks)
+        return includes
 
     def __call__(self, lines, filename, language):
         self.reset()
@@ -263,7 +261,8 @@
 
                 # Output pending includes, a new line between, and the
                 # current l.
-                yield self.dump_includes()
+                for include in self.dump_includes():
+                    yield include
                 yield ''
                 yield line
             else:
@@ -272,9 +271,8 @@
 
         # We've reached EOF, so dump any pending includes
         if processing_includes:
-            yield self.dump_includes()
-
-
+            for include in self.dump_includes():
+                yield include
 
 # default language types to try to apply our sorting rules to
 default_languages = frozenset(('C', 'C++', 'isa', 'python', 'scons', 'swig'))
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to