 ;; Print usage information.
 
 (defn usage []
-  (println (str "\nUsage: revdiff item [regex]\n"))
-  (println "  item  : svn uri or name of versioned working-copy object")
+  (println (str "\nUsage: revdiff object [regex]\n"))
+  (println "  object  : svn uri or name of versioned working-copy object")
   (println "  regex : only show diffs where a changed line matches regex\n"))
 
-;; If item is a uri, the "-rn:m" revision-range format will not work if item is
-;; no longer present in the head revision, in which case we have to use the
-;; "item@n item@m" revision-specification format. Return the correctly formatted
-;; versioned-path(s) string for use by a diff command.
+;; If object is a uri, the "-rn:m" revision-range format will not work if object
+;; is no longer present in the head revision, in which case we have to use the
+;; "object@n object@m" revision-specification format. Return the correctly
+;; formatted versioned-path(s) string for use by a diff command.
 
-(defn vpaths [r1 r2 path item]
-  (if (uri? item)
+(defn vpaths [r1 r2 path object]
+  (if (uri? object)
     (list (str path "@" r1) (str path "@" r2))
     (list (str "-r" r1 ":" r2) path)))
 
 (defn -main [& args]
-  (let [item (first args) filt (or (second args) ".*")]
-    (if (not item)
+  (let [object (first args) filt (or (second args) ".*")]
+    (if (not object)
       (usage)
       (do
-        (diffrevpairs item filt (revpairs (revlist item) item))
+        (diffrevpairs object filt (revpairs (revlist object) object))
         (shutdown-agents)))))


;; Strip peg revision, if present.

(defn baseitem [item]
  (clojure.string/replace item #"@[0-9]+$" ""))

;; A string containing the output of "diff" on the two svn revision of item.

(defn diff [r1 r2 item]
  (let [item (baseitem item)
        v (vpaths r1 r2 item item)]
    (sh "svn" "diff" "--diff-cmd" "diff" "-x" "-u0" shhh (first v) (second v))))

;; Given a list of revision pairs, diff those for which the given filter term
;; (if any) is present on a changed line in that pair. If no filter term is
;; given, diff all changed files from all revision pairs.

(defn diffrevpairs [item filt revpairs]
  (when (seq revpairs)
    (let [r1 (first revpairs)
          r2 (first (rest revpairs))
          mf (matching-files r1 r2 item filt)]
      (println (str "Checking: r" r1 " vs r" r2))
      (doseq [filename mf] (svndiff r1 r2 filename item))
      (diffrevpairs item filt (rest (rest revpairs))))))

;; Try to explain why this has failed.


                          filename (trim (first all-lines))]
                      (if (some matching-line-in? changes) filename)))))))

;; Return a newest-first sequence of revision numbers in which the object
;; changed.

(defn revlist [object]
  (let [logstream (java.io.ByteArrayInputStream. (.getBytes (log object)))]
    (for [e (try
              (xml-seq (parse logstream))
              (catch Exception e (errmsg)))
