Commit 037a0140902475f329e8712f82d772d6a6cef613

Thomas de Grivel 2015-09-23T06:26:57

Allow sorting resources in diff.

diff --git a/core/defs.lisp b/core/defs.lisp
index b33c73e..b171b7c 100644
--- a/core/defs.lisp
+++ b/core/defs.lisp
@@ -149,6 +149,8 @@
   `(let ((*parent-resource* ,(or resource '*adams*)))
      ,@body))
 
+(defgeneric resource-before-p (r1 r2))
+
 ;;  Specifying resources
 
 (defgeneric specified-property (resource property))
diff --git a/core/resource-container.lisp b/core/resource-container.lisp
index eff2679..ab65980 100644
--- a/core/resource-container.lisp
+++ b/core/resource-container.lisp
@@ -64,3 +64,8 @@
 
 (defun clear-resources (&optional (resource-container *parent-resource*))
   (clear-resources% resource-container))
+
+;;  Sorting resources
+
+(defmethod resource-before-p ((r1 resource) (r2 resource))
+  nil)
diff --git a/core/spec.lisp b/core/spec.lisp
index 18cf9ce..ecffa16 100644
--- a/core/spec.lisp
+++ b/core/spec.lisp
@@ -123,10 +123,12 @@ Second value lists properties in line with spec. Format is
 
 (defmethod resource-diff ((res resource-container))
   (append (call-next-method res)
-          (iter (for-resource r in res)
-                (for d = (resource-diff r))
-                (when d
-                  (collect (cons r d))))))
+          (sort (iter (for-resource r in res)
+                      (for d = (resource-diff r))
+                      (when d
+                        (collect (cons r d))))
+                #'resource-before-p
+                :key #'first)))
 
 (defmethod resource-diff ((host host))
   (with-host host