Handle HG MQ from non-root directory.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Fri, 17 Oct 2014 21:08:29 +0300
changeset 1163 e7728b2522b2
parent 1162 aadda3d1653c
child 1165 51cebd6ff0ac
Handle HG MQ from non-root directory.
.emacs-my
--- a/.emacs-my	Fri Oct 17 20:47:53 2014 +0300
+++ b/.emacs-my	Fri Oct 17 21:08:29 2014 +0300
@@ -2114,14 +2114,19 @@
   "Same as `vc-root-diff' but for Hg with C-u show latest MQ patch and
 with C-u C-u show MQ patch and local changes."
   (interactive "P")
-  (if (and prefix (eq (vc-deduce-backend) 'Hg) (eq (vc-hg-command nil t "." "log" "-r" "qparent") 0))
-      (let* ( (rootdir (vc-call-backend 'Hg 'root default-directory)) (default-directory rootdir) )
-        (cond
-         ((equal prefix '(4))
-          (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" "qtip"))
-         ((equal prefix '(16))
-          (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" nil)) ))
-    (call-interactively 'vc-root-diff nil)))
+  (when (eq 'non-hg-mq
+            (catch 'break
+              (unless (and prefix (eq (vc-deduce-backend) 'Hg))
+                (throw 'break 'non-hg-mq))
+              (let* ( (rootdir (vc-call-backend 'Hg 'root default-directory)) (default-directory rootdir) )
+                (unless (eq (vc-hg-command nil t rootdir "log" "-r" "qtip") 0)
+                  (throw 'break 'non-hg-mq))
+                (cond
+                 ((equal prefix '(4))
+                  (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" "qtip"))
+                 ((equal prefix '(16))
+                  (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" nil)) ))))
+    (call-interactively 'vc-root-diff nil) ))
 
 (global-set-key (kbd "C-x v D") 'my-vc-root-diff)