diff options
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/vc-hg.el | 64 |
2 files changed, 64 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c2d25f1ca30..5df52f8f0b8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2007-06-21 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc-hg.el: Add to do items. | ||
| 4 | (vc-hg-diff): Add support for comparing different revisions. | ||
| 5 | (vc-hg-diff, vc-hg-annotate-command, vc-hg-annotate-time) | ||
| 6 | (vc-hg-annotate-extract-revision-at-line) | ||
| 7 | (vc-hg-previous-version, vc-hg-checkin): New functions. | ||
| 8 | (vc-hg-annotate-re): New constant. | ||
| 9 | |||
| 1 | 2007-06-20 Jay Belanger <jay.p.belanger@gmail.com> | 10 | 2007-06-20 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 11 | ||
| 3 | * calc/calc.el (math-standard-ops): Fix precedence of | 12 | * calc/calc.el (math-standard-ops): Fix precedence of |
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 @@ | |||
| 35 | 35 | ||
| 36 | ;;; Todo: | 36 | ;;; Todo: |
| 37 | 37 | ||
| 38 | ;; Implement the rest of the vc interface | 38 | ;; Implement the rest of the vc interface: |
| 39 | ;; - regexps for log-view to understand the "hg log" output | ||
| 40 | ;; - dired | ||
| 41 | ;; - snapshot? | ||
| 39 | 42 | ||
| 40 | ;; Implement Stefan Monnier's advice: | 43 | ;; Implement Stefan Monnier's advice: |
| 41 | ;; vc-hg-registered and vc-hg-state | 44 | ;; vc-hg-registered and vc-hg-state |
| @@ -108,15 +111,53 @@ | |||
| 108 | (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) | 111 | (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) |
| 109 | file "log")) | 112 | file "log")) |
| 110 | 113 | ||
| 111 | (defun vc-hg-diff (file &optional oldvers newvers buffers) | 114 | (defun vc-hg-diff (file &optional oldvers newvers buffer) |
| 112 | "Get a difference report using hg between two versions of FILE." | 115 | "Get a difference report using hg between two versions of FILE." |
| 113 | (when buffers (message buffers)) | 116 | (let ((working (vc-workfile-version file))) |
| 114 | (unless buffers (setq buffers "*vc-diff*")) | 117 | (if (and (equal oldvers working) (not newvers)) |
| 115 | (when oldvers (message oldvers)) | 118 | (setq oldvers nil)) |
| 116 | (when newvers (message newvers)) | 119 | (if (and (not oldvers) newvers) |
| 117 | (call-process "hg" nil buffers nil | 120 | (setq oldvers working)) |
| 118 | "--cwd" (file-name-directory file) | 121 | (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil |
| 119 | "diff" (file-name-nondirectory file))) | 122 | "--cwd" (file-name-directory file) "diff" |
| 123 | (append | ||
| 124 | (if oldvers | ||
| 125 | (if newvers | ||
| 126 | (list "-r" oldvers "-r" newvers) | ||
| 127 | (list "-r" oldvers)) | ||
| 128 | (list "")) | ||
| 129 | (list (file-name-nondirectory file)))))) | ||
| 130 | |||
| 131 | (defun vc-hg-annotate-command (file buffer &optional version) | ||
| 132 | "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. | ||
| 133 | Optional arg VERSION is a version to annotate from." | ||
| 134 | (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if version (concat "-r" version))) | ||
| 135 | (with-current-buffer buffer | ||
| 136 | (goto-char (point-min)) | ||
| 137 | (re-search-forward "^[0-9]") | ||
| 138 | (delete-region (point-min) (1- (point))))) | ||
| 139 | |||
| 140 | |||
| 141 | ;;; The format for one line output by "hg annotate -d -n" looks like this: | ||
| 142 | ;;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS | ||
| 143 | ;;; i.e: VERSION_NUMBER DATE: CONTENTS | ||
| 144 | (defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ") | ||
| 145 | |||
| 146 | (defun vc-hg-annotate-time () | ||
| 147 | (when (looking-at vc-hg-annotate-re) | ||
| 148 | (goto-char (match-end 0)) | ||
| 149 | (vc-annotate-convert-time | ||
| 150 | (date-to-time (match-string-no-properties 2))))) | ||
| 151 | |||
| 152 | (defun vc-hg-annotate-extract-revision-at-line () | ||
| 153 | (save-excursion | ||
| 154 | (beginning-of-line) | ||
| 155 | (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1)))) | ||
| 156 | |||
| 157 | (defun vc-hg-previous-version (file rev) | ||
| 158 | (let ((newrev (1- (string-to-number rev)))) | ||
| 159 | (when (>= newrev 0) | ||
| 160 | (number-to-string newrev)))) | ||
| 120 | 161 | ||
| 121 | (defun vc-hg-register (file &optional rev comment) | 162 | (defun vc-hg-register (file &optional rev comment) |
| 122 | "Register FILE under hg. | 163 | "Register FILE under hg. |
| @@ -124,6 +165,11 @@ REV is ignored. | |||
| 124 | COMMENT is ignored." | 165 | COMMENT is ignored." |
| 125 | (vc-hg-command nil nil file "add")) | 166 | (vc-hg-command nil nil file "add")) |
| 126 | 167 | ||
| 168 | (defun vc-hg-checkin (file rev comment) | ||
| 169 | "HG-specific version of `vc-backend-checkin'. | ||
| 170 | REV is ignored." | ||
| 171 | (vc-hg-command nil nil file "commit" "-m" comment)) | ||
| 172 | |||
| 127 | ;;; Modelled after the similar function in vc-bzr.el | 173 | ;;; Modelled after the similar function in vc-bzr.el |
| 128 | (defun vc-hg-checkout (file &optional editable rev workfile) | 174 | (defun vc-hg-checkout (file &optional editable rev workfile) |
| 129 | "Retrieve a revision of FILE into a WORKFILE. | 175 | "Retrieve a revision of FILE into a WORKFILE. |