diff options
author | Dan Nicolaescu <dann@ics.uci.edu> | 2007-06-21 05:44:54 +0000 |
---|---|---|
committer | Dan Nicolaescu <dann@ics.uci.edu> | 2007-06-21 05:44:54 +0000 |
commit | cdaf01cce1ef3efe4a6198eda484a28a1ee9534b (patch) | |
tree | 0a59a52d65170ce5ff4515efdb13a3fab4868b3d /lisp/vc-hg.el | |
parent | 8bb0cac213bc4c54f4d00c9c8d33e472d7c4769a (diff) | |
download | emacs-cdaf01cce1ef3efe4a6198eda484a28a1ee9534b.tar.gz |
Add to do items.
(vc-hg-diff): Add support for comparing different revisions.
(vc-hg-diff, vc-hg-annotate-command, vc-hg-annotate-time)
(vc-hg-annotate-extract-revision-at-line)
(vc-hg-previous-version, vc-hg-checkin): New functions.
(vc-hg-annotate-re): New constant.
Diffstat (limited to 'lisp/vc-hg.el')
-rw-r--r-- | lisp/vc-hg.el | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el index d1ad447b9b9..c7bcda7ebc5 100644 --- a/lisp/vc-hg.el +++ b/lisp/vc-hg.el @@ -35,7 +35,10 @@ ;;; Todo: -;; Implement the rest of the vc interface +;; Implement the rest of the vc interface: +;; - regexps for log-view to understand the "hg log" output +;; - dired +;; - snapshot? ;; Implement Stefan Monnier's advice: ;; vc-hg-registered and vc-hg-state @@ -108,15 +111,53 @@ (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) file "log")) -(defun vc-hg-diff (file &optional oldvers newvers buffers) +(defun vc-hg-diff (file &optional oldvers newvers buffer) "Get a difference report using hg between two versions of FILE." - (when buffers (message buffers)) - (unless buffers (setq buffers "*vc-diff*")) - (when oldvers (message oldvers)) - (when newvers (message newvers)) - (call-process "hg" nil buffers nil - "--cwd" (file-name-directory file) - "diff" (file-name-nondirectory file))) + (let ((working (vc-workfile-version file))) + (if (and (equal oldvers working) (not newvers)) + (setq oldvers nil)) + (if (and (not oldvers) newvers) + (setq oldvers working)) + (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil + "--cwd" (file-name-directory file) "diff" + (append + (if oldvers + (if newvers + (list "-r" oldvers "-r" newvers) + (list "-r" oldvers)) + (list "")) + (list (file-name-nondirectory file)))))) + +(defun vc-hg-annotate-command (file buffer &optional version) + "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. +Optional arg VERSION is a version to annotate from." + (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if version (concat "-r" version))) + (with-current-buffer buffer + (goto-char (point-min)) + (re-search-forward "^[0-9]") + (delete-region (point-min) (1- (point))))) + + +;;; The format for one line output by "hg annotate -d -n" looks like this: +;;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS +;;; i.e: VERSION_NUMBER DATE: CONTENTS +(defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ") + +(defun vc-hg-annotate-time () + (when (looking-at vc-hg-annotate-re) + (goto-char (match-end 0)) + (vc-annotate-convert-time + (date-to-time (match-string-no-properties 2))))) + +(defun vc-hg-annotate-extract-revision-at-line () + (save-excursion + (beginning-of-line) + (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1)))) + +(defun vc-hg-previous-version (file rev) + (let ((newrev (1- (string-to-number rev)))) + (when (>= newrev 0) + (number-to-string newrev)))) (defun vc-hg-register (file &optional rev comment) "Register FILE under hg. @@ -124,6 +165,11 @@ REV is ignored. COMMENT is ignored." (vc-hg-command nil nil file "add")) +(defun vc-hg-checkin (file rev comment) + "HG-specific version of `vc-backend-checkin'. +REV is ignored." + (vc-hg-command nil nil file "commit" "-m" comment)) + ;;; Modelled after the similar function in vc-bzr.el (defun vc-hg-checkout (file &optional editable rev workfile) "Retrieve a revision of FILE into a WORKFILE. |