[rtems-source-builder commit] sb: Make the source and patch labels have sortable label.

Chris Johns chrisj at rtems.org
Thu Mar 26 00:14:52 UTC 2015


Module:    rtems-source-builder
Branch:    master
Commit:    2e54abc9bacaf17a15f5dc744e4a839c82f9b28a
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=2e54abc9bacaf17a15f5dc744e4a839c82f9b28a

Author:    Chris Johns <chrisj at rtems.org>
Date:      Thu Mar 26 11:12:13 2015 +1100

sb: Make the source and patch labels have sortable label.

This patch changes 'patch1' to 'patch0001' so sorting of the macro
keys in the patch macro map returns the order the patches are declared.
The helps mamage patch sets that need a specific order.

---

 source-builder/sb/macros.py  | 2 +-
 source-builder/sb/sources.py | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/source-builder/sb/macros.py b/source-builder/sb/macros.py
index 1f37ae4..d2bdc91 100644
--- a/source-builder/sb/macros.py
+++ b/source-builder/sb/macros.py
@@ -199,7 +199,7 @@ class macros:
 
     def map_keys(self, _map):
         if _map in self.macros:
-            return self.macros[_map].keys()
+            return sorted(self.macros[_map].keys())
         return []
 
     def map_num_keys(self, _map):
diff --git a/source-builder/sb/sources.py b/source-builder/sb/sources.py
index 1a40a73..beae0db 100644
--- a/source-builder/sb/sources.py
+++ b/source-builder/sb/sources.py
@@ -26,6 +26,9 @@ import log
 def _args(args):
     return [i for s in [ii.split() for ii in args] for i in s]
 
+def _make_key(label, index):
+    return '%s%04d' % (label, index)
+
 def add(label, args, macros, error):
     args = _args(args)
     if len(args) < 2:
@@ -34,7 +37,7 @@ def add(label, args, macros, error):
     macros.create_map(_map)
     index = 0
     while True:
-        key = '%s%d' % (label, index)
+        key = _make_key(label, index)
         if key not in macros.map_keys(_map):
             break
         index += 1
@@ -49,7 +52,7 @@ def set(label, args, macros, error):
         error('%%%s requires at least 2 arguments' % (label))
     _map = '%s-%s' % (label, args[0])
     macros.create_map(_map)
-    key = '%s0' % (label)
+    key = _make_key(label, 0)
     if key not in macros.map_keys(_map):
         macros.set_write_map(_map)
         macros.define(key, ' '.join(args[1:]))



More information about the vc mailing list