aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-06-21 05:44:54 +0000
committerDan Nicolaescu2007-06-21 05:44:54 +0000
commitcdaf01cce1ef3efe4a6198eda484a28a1ee9534b (patch)
tree0a59a52d65170ce5ff4515efdb13a3fab4868b3d
parent8bb0cac213bc4c54f4d00c9c8d33e472d7c4769a (diff)
downloademacs-cdaf01cce1ef3efe4a6198eda484a28a1ee9534b.tar.gz
emacs-cdaf01cce1ef3efe4a6198eda484a28a1ee9534b.zip
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.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/vc-hg.el64
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 @@
12007-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
12007-06-20 Jay Belanger <jay.p.belanger@gmail.com> 102007-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.
133Optional 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.
124COMMENT is ignored." 165COMMENT 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'.
170REV 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.