comparison contrib/mercurial.el @ 2991:18c661e9abd9

mercurial.el: deal with more vagaries of "hg status". If we run "hg status" on a file that does not exist, it prints an error message. Attempt to extract the name of the file.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 22 Aug 2006 15:15:52 -0700
parents 78fe7e2c2e1e
children 681b681f7f09
comparison
equal deleted inserted replaced
2990:ac74046f8f58 2991:18c661e9abd9
593 593
594 (defun hg-path-status (root paths) 594 (defun hg-path-status (root paths)
595 "Return status of PATHS in repo ROOT as an alist. 595 "Return status of PATHS in repo ROOT as an alist.
596 Each entry is a pair (FILE-NAME . STATUS)." 596 Each entry is a pair (FILE-NAME . STATUS)."
597 (let ((s (apply 'hg-run "--cwd" root "status" "-marduc" paths)) 597 (let ((s (apply 'hg-run "--cwd" root "status" "-marduc" paths))
598 result) 598 result)
599 (dolist (entry (split-string (hg-chomp (cdr s)) "\n") (nreverse result)) 599 (dolist (entry (split-string (hg-chomp (cdr s)) "\n") (nreverse result))
600 (let ((state (cdr (assoc (substring entry 0 2) 600 (let (state name)
601 '(("M " . modified) 601 (if (equal (substring entry 1 2) " ")
602 ("A " . added) 602 (setq state (cdr (assoc (substring entry 0 2)
603 ("R " . removed) 603 '(("M " . modified)
604 ("! " . deleted) 604 ("A " . added)
605 ("C " . normal) 605 ("R " . removed)
606 ("I " . ignored) 606 ("! " . deleted)
607 ("? " . nil))))) 607 ("C " . normal)
608 (name (substring entry 2))) 608 ("I " . ignored)
609 (setq result (cons (cons name state) result)))))) 609 ("? " . nil))))
610 name (substring entry 2))
611 (setq name (substring entry 0 (search ": " entry :from-end t))))
612 (setq result (cons (cons name state) result))))))
610 613
611 (defmacro hg-view-output (args &rest body) 614 (defmacro hg-view-output (args &rest body)
612 "Execute BODY in a clean buffer, then quickly display that buffer. 615 "Execute BODY in a clean buffer, then quickly display that buffer.
613 If the buffer contains one line, its contents are displayed in the 616 If the buffer contains one line, its contents are displayed in the
614 minibuffer. Otherwise, the buffer is displayed in view-mode. 617 minibuffer. Otherwise, the buffer is displayed in view-mode.
639 (setq hg-prev-buffer ,prev-buf) 642 (setq hg-prev-buffer ,prev-buf)
640 (hg-view-mode ,prev-buf ,@v-m-rest)))))) 643 (hg-view-mode ,prev-buf ,@v-m-rest))))))
641 644
642 (put 'hg-view-output 'lisp-indent-function 1) 645 (put 'hg-view-output 'lisp-indent-function 1)
643 646
644 ;;; Context save and restore across revert. 647 ;;; Context save and restore across revert and other operations.
645 648
646 (defun hg-position-context (pos) 649 (defun hg-position-context (pos)
647 "Return information to help find the given position again." 650 "Return information to help find the given position again."
648 (let* ((end (min (point-max) (+ pos 98)))) 651 (let* ((end (min (point-max) (+ pos 98))))
649 (list pos 652 (list pos