diff options
author | Leo Liu <sdl.web@gmail.com> | 2012-03-13 18:40:29 +0800 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2012-03-13 18:40:29 +0800 |
commit | 9e345a01ba5163f66b636d08ec4927c012b35405 (patch) | |
tree | 230034a0519a13d365f9b59ef67601faf99285bc /lisp | |
parent | 6ea7151ba66df966974060711512b49b9059566e (diff) | |
download | emacs-9e345a01ba5163f66b636d08ec4927c012b35405.tar.gz |
* lisp/vc/vc-hg.el (vc-hg-working-revision): Rework to work with both
directory and file as argument.
Fixes: debbugs:10822
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/vc/vc-hg.el | 47 |
2 files changed, 13 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bd0e6f865cd..0109376a50d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-03-13 Leo Liu <sdl.web@gmail.com> + + * vc/vc-hg.el (vc-hg-working-revision): Rework to work with both + directory and file as argument (Bug#10822). + 2012-03-13 Kaushik Srenevasan <ksrenevasan@gmail.com> (tiny change) * progmodes/gdb-mi.el (gdb-invalidate-disassembly): diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index f3ba009b8c2..52e8051342d 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -226,45 +226,14 @@ highlighting the Log View buffer." (defun vc-hg-working-revision (file) "Hg-specific version of `vc-working-revision'." - (let* - ((status nil) - (default-directory (file-name-directory file)) - ;; Avoid localization of messages so we can parse the output. - (avoid-local-env (append (list "TERM=dumb" "LANGUAGE=C") - process-environment)) - (out - (with-output-to-string - (with-current-buffer - standard-output - (setq status - (condition-case nil - (let ((process-environment avoid-local-env)) - ;; Ignore all errors. - (process-file - vc-hg-program nil t nil - "--config" "alias.parents=parents" - "--config" "defaults.parents=" - "parents" "--template" "{rev}" (file-relative-name file))) - ;; Some problem happened. E.g. We can't find an `hg' - ;; executable. - (error nil))))))) - (if (eq 0 status) - out - ;; Check if the file is in the 'added state, the above hg - ;; command does not distinguish between 'added and 'unregistered. - (setq status - (condition-case nil - (let ((process-environment avoid-local-env)) - (process-file - vc-hg-program nil nil nil - ;; We use "log" here, if there's a faster command - ;; that returns true for an 'added file and false - ;; for an 'unregistered one, we could use that. - "log" "-l1" (file-relative-name file))) - ;; Some problem happened. E.g. We can't find an `hg' - ;; executable. - (error nil))) - (when (eq 0 status) "0")))) + (let ((default-directory (if (file-directory-p file) + (file-name-as-directory file) + (file-name-directory file)))) + (ignore-errors + (with-output-to-string + (process-file vc-hg-program nil standard-output nil + "log" "-l" "1" "--template" "{rev}" + (file-relative-name file)))))) ;;; History functions |