[Cl-darcs-cvs] r127 - cl-darcs/trunk

mhenoch at common-lisp.net mhenoch at common-lisp.net
Fri Aug 24 12:25:39 UTC 2007


Author: mhenoch
Date: Fri Aug 24 08:25:38 2007
New Revision: 127

Modified:
   cl-darcs/trunk/touching.lisp
Log:
Add FIND-TOUCHING methods for FILE-PATCH, ADD-FILE-PATCH and RM-FILE-PATCH.


Modified: cl-darcs/trunk/touching.lisp
==============================================================================
--- cl-darcs/trunk/touching.lisp	(original)
+++ cl-darcs/trunk/touching.lisp	Fri Aug 24 08:25:38 2007
@@ -56,10 +56,39 @@
     (when touching-patches
       (make-instance 'composite-patch :patches (nreverse touching-patches)))))
 
-(defmethod find-touching ((patch file-patch) filename direction)
+(defmethod find-touching :around ((patch file-patch) filename direction)
+  ;; File patches touch a single file, so we can ignore them if they
+  ;; don't touch the file we're interested in.
   (declare (ignore direction))
   (when (equal filename (patch-filename patch))
-    (values patch filename)))
+    (call-next-method)))
+
+(defmethod find-touching ((patch file-patch) filename direction)
+  ;; By default, assume that file patches modify an existing file.
+  (declare (ignore direction))
+  (values patch filename))
+
+(defmethod find-touching ((patch add-file-patch) filename direction)
+  ;; Adding a file is different, though.
+  (ecase direction
+    (:forwards
+     ;; Should this happen in normal circumstances?  If the file was
+     ;; created by this patch, noone would know about its existence
+     ;; before.
+     (values patch filename))
+    (:backwards
+     ;; Before this patch, the file didn't exist.
+     (values patch nil))))
+
+(defmethod find-touching ((patch rm-file-patch) filename direction)
+  ;; As is removing a file.
+  (ecase direction
+    (:forwards
+     ;; After this patch, the file doesn't exist.
+     (values patch nil))
+    (:backwards
+     ;; Should this happen?
+     (values patch filename))))
 
 (defmethod find-touching ((patch directory-patch) filename direction)
   (declare (ignore direction))



More information about the Cl-darcs-cvs mailing list