]> code.delx.au - gnu-emacs/commitdiff
* vc-hg.el (vc-hg-internal-status): Inline in `vc-hg-state', the
authorDan Nicolaescu <dann@ics.uci.edu>
Thu, 5 Jul 2007 14:55:34 +0000 (14:55 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Thu, 5 Jul 2007 14:55:34 +0000 (14:55 +0000)
only caller, and delete.
(vc-hg-state): Deal with exceptions and only parse the output on
successful return.

* vc-hg.el (vc-hg-internal-log): Inline in
`vc-hg-workfile-version', the only caller, and delete.
(vc-hg-workfile-version): Deal with exceptions and only parse the
output on successful return.

lisp/ChangeLog
lisp/vc-hg.el

index 0912a5d6809fcd7cc832a813b5802cb4ec956947..9b3262d60bf6cb1c8ca7d80b619c01d9a675e994 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-05  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       * vc-hg.el (vc-hg-internal-status): Inline in `vc-hg-state', the
+       only caller, and delete.
+       (vc-hg-state): Deal with exceptions and only parse the output on
+       successful return.
+
+       * vc-hg.el (vc-hg-internal-log): Inline in
+       `vc-hg-workfile-version', the only caller, and delete.
+       (vc-hg-workfile-version): Deal with exceptions and only parse the
+       output on successful return.
+
 2007-07-04  Jay Belanger  <jay.p.belanger@gmail.com>
 
        * calculator.el (calculator-expt): Use more cases to determine
index 6a80fccbcbd70bd29728f07709c7d4a9188f5751..7bfa6953e60a8668761ca9a30253bea33f451933 100644 (file)
 
 (defun vc-hg-state (file)
   "Hg-specific version of `vc-state'."
-  (let ((out (vc-hg-internal-status file)))
-    (if (eq 0 (length out)) 'up-to-date
-      (let ((state (aref out 0)))
-        (cond
-         ((eq state ?M) 'edited)
-         ((eq state ?A) 'edited)
-         ((eq state ?P) 'needs-patch)
-        ((eq state ??) nil)
-         (t 'up-to-date))))))
+  (let* 
+      ((status nil)
+       (out
+       (with-output-to-string
+         (with-current-buffer
+             standard-output
+           (setq status
+                 (condition-case nil
+                     ;; Ignore all errors.
+                     (call-process
+                      "hg" nil t nil "--cwd" (file-name-directory file)
+                      "status" (file-name-nondirectory file))
+                   ;; Some problem happened.  E.g. We can't find an `hg'
+                   ;; executable.
+                   (error nil)))))))
+    (when (eq 0 status)
+      (if (eq 0 (length out)) 'up-to-date
+       (let ((state (aref out 0)))
+         (cond
+          ((eq state ?M) 'edited)
+          ((eq state ?A) 'edited)
+          ((eq state ?P) 'needs-patch)
+          ((eq state ??) nil)
+          (t 'up-to-date)))))))
 
 (defun vc-hg-workfile-version (file)
   "Hg-specific version of `vc-workfile-version'."
-  (let ((out (vc-hg-internal-log file)))
-    (if (string-match "changeset: *\\([0-9]*\\)" out)
-        (match-string 1 out)
-      "0")))
+  (let* 
+      ((status nil)
+       (out
+       (with-output-to-string
+         (with-current-buffer
+             standard-output
+           (setq status
+                 (condition-case nil
+                     ;; Ignore all errors.
+                     (call-process
+                      "hg" nil t nil "--cwd" (file-name-directory file)
+                      "log" "-l1" (file-name-nondirectory file))
+                   ;; Some problem happened.  E.g. We can't find an `hg'
+                   ;; executable.
+                   (error nil)))))))
+    (when (eq 0 status)
+      (if (string-match "changeset: *\\([0-9]*\\)" out)
+         (match-string 1 out)
+       "0"))))
 
 ;;; History functions
 
@@ -231,6 +261,11 @@ REV is the revision to check out into WORKFILE."
 (defun vc-hg-checkout-model (file)
   'implicit)
 
+;; Modelled after the similar function in vc-bzr.el
+(defun vc-hg-revert (file &optional contents-done)
+  (unless contents-done
+    (with-temp-buffer (vc-hg-command t nil file "revert"))))
+
 ;;; Internal functions
 
 (defun vc-hg-command (buffer okstatus file &rest flags)
@@ -243,24 +278,6 @@ and that it passes `vc-hg-global-switches' to it before FLAGS."
            (append vc-hg-global-switches
                    flags))))
 
-(defun vc-hg-internal-log (file &optional buffer)
-  "Return log of FILE."
-  (with-output-to-string
-    (with-current-buffer
-        standard-output
-      (call-process
-       "hg" nil t nil "--cwd" (file-name-directory file)
-       "log" "-l1" (file-name-nondirectory file)))))
-
-(defun vc-hg-internal-status(file)
-  "Return status of FILE."
-  (with-output-to-string
-    (with-current-buffer
-        standard-output
-      (call-process
-       "hg" nil t nil "--cwd" (file-name-directory file)
-       "status" (file-name-nondirectory file)))))
-
 (provide 'vc-hg)
 
 ;;; vc-hg.el ends here