changeset 3001:a7c4c7537999

mercurial.el: add hg-status.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 22 Aug 2006 11:37:18 -0700
parents b6e6d2a9c5bc
children 65efeb7b2c56
files contrib/mercurial.el
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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