mercurial.el: add hg-status.
authorBryan O'Sullivan <bos@serpentine.com>
Tue, 22 Aug 2006 11:37:18 -0700
changeset 3001 a7c4c7537999
parent 3000 b6e6d2a9c5bc
child 3002 65efeb7b2c56
mercurial.el: add hg-status.
contrib/mercurial.el
--- a/contrib/mercurial.el	Tue Aug 22 11:36:58 2006 -0700
+++ b/contrib/mercurial.el	Tue Aug 22 11:37:18 2006 -0700
@@ -554,6 +554,23 @@
 	      (cdr state)
 	    'normal)))))
 
+(defun hg-status (&rest paths)
+  "Return status of PATHS as an alist.
+Each entry is a pair (FILE-NAME . STATUS)."
+  (let ((s (apply 'hg-run "status" "-marduc" paths))
+	 result)
+      (dolist (entry (split-string (hg-chomp (cdr s)) "\n") (nreverse result))
+	(let ((state (cdr (assoc (substring entry 0 2)
+				 '(("M " . modified)
+				   ("A " . added)
+				   ("R " . removed)
+				   ("! " . deleted)
+				   ("C " . normal)
+				   ("I " . ignored)
+				   ("? " . nil)))))
+	      (name (substring entry 2)))
+	  (setq result (cons (cons name state) result)))))))
+
 (defmacro hg-view-output (args &rest body)
   "Execute BODY in a clean buffer, then quickly display that buffer.
 If the buffer contains one line, its contents are displayed in the