aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2009-09-22 18:16:48 +0000
committerSam Steingold2009-09-22 18:16:48 +0000
commit72169e55e34c84dbd3931990f4ba5e0914cbac57 (patch)
tree13beb24df9fc785cf07e8a7ea8ad4fcb39963ee7
parentb0459dec62fdcb8f9329f963fe629c98217a9077 (diff)
downloademacs-72169e55e34c84dbd3931990f4ba5e0914cbac57.tar.gz
emacs-72169e55e34c84dbd3931990f4ba5e0914cbac57.zip
(vc-hg-print-log): Fix shortlog arg passing.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/vc-hg.el299
2 files changed, 154 insertions, 149 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2383aac9d96..dfb3d544456 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12009-09-22 Sam Steingold <sds@gnu.org>
2
3 * vc-hg.el (vc-hg-print-log): Fix shortlog arg passing.
4
12009-09-22 Stefan Monnier <monnier@iro.umontreal.ca> 52009-09-22 Stefan Monnier <monnier@iro.umontreal.ca>
2 6
3 * textmodes/fill.el: Convert to utf-8 encoding. 7 * textmodes/fill.el: Convert to utf-8 encoding.
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el
index 4a81ffb232f..597d807e7e7 100644
--- a/lisp/vc-hg.el
+++ b/lisp/vc-hg.el
@@ -127,9 +127,9 @@
127 "String or list of strings specifying switches for Hg diff under VC. 127 "String or list of strings specifying switches for Hg diff under VC.
128If nil, use the value of `vc-diff-switches'. If t, use no switches." 128If nil, use the value of `vc-diff-switches'. If t, use no switches."
129 :type '(choice (const :tag "Unspecified" nil) 129 :type '(choice (const :tag "Unspecified" nil)
130 (const :tag "None" t) 130 (const :tag "None" t)
131 (string :tag "Argument String") 131 (string :tag "Argument String")
132 (repeat :tag "Argument List" :value ("") string)) 132 (repeat :tag "Argument List" :value ("") string))
133 :version "23.1" 133 :version "23.1"
134 :group 'vc) 134 :group 'vc)
135 135
@@ -160,53 +160,53 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
160 (let* 160 (let*
161 ((status nil) 161 ((status nil)
162 (out 162 (out
163 (with-output-to-string 163 (with-output-to-string
164 (with-current-buffer 164 (with-current-buffer
165 standard-output 165 standard-output
166 (setq status 166 (setq status
167 (condition-case nil 167 (condition-case nil
168 ;; Ignore all errors. 168 ;; Ignore all errors.
169 (call-process 169 (call-process
170 "hg" nil t nil "--cwd" (file-name-directory file) 170 "hg" nil t nil "--cwd" (file-name-directory file)
171 "status" "-A" (file-name-nondirectory file)) 171 "status" "-A" (file-name-nondirectory file))
172 ;; Some problem happened. E.g. We can't find an `hg' 172 ;; Some problem happened. E.g. We can't find an `hg'
173 ;; executable. 173 ;; executable.
174 (error nil))))))) 174 (error nil)))))))
175 (when (eq 0 status) 175 (when (eq 0 status)
176 (when (null (string-match ".*: No such file or directory$" out)) 176 (when (null (string-match ".*: No such file or directory$" out))
177 (let ((state (aref out 0))) 177 (let ((state (aref out 0)))
178 (cond 178 (cond
179 ((eq state ?=) 'up-to-date) 179 ((eq state ?=) 'up-to-date)
180 ((eq state ?A) 'added) 180 ((eq state ?A) 'added)
181 ((eq state ?M) 'edited) 181 ((eq state ?M) 'edited)
182 ((eq state ?I) 'ignored) 182 ((eq state ?I) 'ignored)
183 ((eq state ?R) 'removed) 183 ((eq state ?R) 'removed)
184 ((eq state ?!) 'missing) 184 ((eq state ?!) 'missing)
185 ((eq state ??) 'unregistered) 185 ((eq state ??) 'unregistered)
186 ((eq state ?C) 'up-to-date) ;; Older mercurials use this 186 ((eq state ?C) 'up-to-date) ;; Older mercurials use this
187 (t 'up-to-date))))))) 187 (t 'up-to-date)))))))
188 188
189(defun vc-hg-working-revision (file) 189(defun vc-hg-working-revision (file)
190 "Hg-specific version of `vc-working-revision'." 190 "Hg-specific version of `vc-working-revision'."
191 (let* 191 (let*
192 ((status nil) 192 ((status nil)
193 (out 193 (out
194 (with-output-to-string 194 (with-output-to-string
195 (with-current-buffer 195 (with-current-buffer
196 standard-output 196 standard-output
197 (setq status 197 (setq status
198 (condition-case nil 198 (condition-case nil
199 ;; Ignore all errors. 199 ;; Ignore all errors.
200 (call-process 200 (call-process
201 "hg" nil t nil "--cwd" (file-name-directory file) 201 "hg" nil t nil "--cwd" (file-name-directory file)
202 "log" "-l1" (file-name-nondirectory file)) 202 "log" "-l1" (file-name-nondirectory file))
203 ;; Some problem happened. E.g. We can't find an `hg' 203 ;; Some problem happened. E.g. We can't find an `hg'
204 ;; executable. 204 ;; executable.
205 (error nil))))))) 205 (error nil)))))))
206 (when (eq 0 status) 206 (when (eq 0 status)
207 (if (string-match "changeset: *\\([0-9]*\\)" out) 207 (if (string-match "changeset: *\\([0-9]*\\)" out)
208 (match-string 1 out) 208 (match-string 1 out)
209 "0")))) 209 "0"))))
210 210
211;;; History functions 211;;; History functions
212 212
@@ -232,8 +232,9 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
232 (with-current-buffer 232 (with-current-buffer
233 buffer 233 buffer
234 (apply 'vc-hg-command buffer 0 files "log" 234 (apply 'vc-hg-command buffer 0 files "log"
235 (if shortlog '("--style" "compact")) 235 (if shortlog
236 vc-hg-log-switches)))) 236 (append '("--style" "compact") vc-hg-log-switches)
237 vc-hg-log-switches)))))
237 238
238(defvar log-view-message-re) 239(defvar log-view-message-re)
239(defvar log-view-file-re) 240(defvar log-view-file-re)
@@ -247,52 +248,52 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
247 (set (make-local-variable 'log-view-per-file-logs) nil) 248 (set (make-local-variable 'log-view-per-file-logs) nil)
248 (set (make-local-variable 'log-view-message-re) 249 (set (make-local-variable 'log-view-message-re)
249 (if vc-short-log 250 (if vc-short-log
250 "^\\([0-9]+\\)\\(?:\\[.*\\]\\)? +\\([0-9a-z]\\{12\\}\\) +\\(\\(?:[0-9]+\\)-\\(?:[0-9]+\\)-\\(?:[0-9]+\\) \\(?:[0-9]+\\):\\(?:[0-9]+\\) \\(?:[-+0-9]+\\)\\) +\\(.*\\)$" 251 "^\\([0-9]+\\)\\(?:\\[.*\\]\\)? +\\([0-9a-z]\\{12\\}\\) +\\(\\(?:[0-9]+\\)-\\(?:[0-9]+\\)-\\(?:[0-9]+\\) \\(?:[0-9]+\\):\\(?:[0-9]+\\) \\(?:[-+0-9]+\\)\\) +\\(.*\\)$"
251 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)")) 252 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)"))
252 (set (make-local-variable 'log-view-font-lock-keywords) 253 (set (make-local-variable 'log-view-font-lock-keywords)
253 (if vc-short-log 254 (if vc-short-log
254 (append `((,log-view-message-re 255 (append `((,log-view-message-re
255 (1 'log-view-message-face) 256 (1 'log-view-message-face)
256 (2 'log-view-message-face) 257 (2 'log-view-message-face)
257 (3 'change-log-date) 258 (3 'change-log-date)
258 (4 'change-log-name)))) 259 (4 'change-log-name))))
259 (append 260 (append
260 log-view-font-lock-keywords 261 log-view-font-lock-keywords
261 '( 262 '(
262 ;; Handle the case: 263 ;; Handle the case:
263 ;; user: FirstName LastName <foo@bar> 264 ;; user: FirstName LastName <foo@bar>
264 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" 265 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
265 (1 'change-log-name) 266 (1 'change-log-name)
266 (2 'change-log-email)) 267 (2 'change-log-email))
267 ;; Handle the cases: 268 ;; Handle the cases:
268 ;; user: foo@bar 269 ;; user: foo@bar
269 ;; and 270 ;; and
270 ;; user: foo 271 ;; user: foo
271 ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)" 272 ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
272 (1 'change-log-email)) 273 (1 'change-log-email))
273 ("^date: \\(.+\\)" (1 'change-log-date)) 274 ("^date: \\(.+\\)" (1 'change-log-date))
274 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))) 275 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
275 276
276(defun vc-hg-diff (files &optional oldvers newvers buffer) 277(defun vc-hg-diff (files &optional oldvers newvers buffer)
277 "Get a difference report using hg between two revisions of FILES." 278 "Get a difference report using hg between two revisions of FILES."
278 (let* ((firstfile (car files)) 279 (let* ((firstfile (car files))
279 (cwd (if firstfile (file-name-directory firstfile) 280 (cwd (if firstfile (file-name-directory firstfile)
280 (expand-file-name default-directory))) 281 (expand-file-name default-directory)))
281 (working (and firstfile (vc-working-revision firstfile)))) 282 (working (and firstfile (vc-working-revision firstfile))))
282 (when (and (equal oldvers working) (not newvers)) 283 (when (and (equal oldvers working) (not newvers))
283 (setq oldvers nil)) 284 (setq oldvers nil))
284 (when (and (not oldvers) newvers) 285 (when (and (not oldvers) newvers)
285 (setq oldvers working)) 286 (setq oldvers working))
286 (apply #'vc-hg-command (or buffer "*vc-diff*") nil 287 (apply #'vc-hg-command (or buffer "*vc-diff*") nil
287 (mapcar (lambda (file) (file-relative-name file cwd)) files) 288 (mapcar (lambda (file) (file-relative-name file cwd)) files)
288 "--cwd" cwd 289 "--cwd" cwd
289 "diff" 290 "diff"
290 (append 291 (append
291 (vc-switches 'hg 'diff) 292 (vc-switches 'hg 'diff)
292 (when oldvers 293 (when oldvers
293 (if newvers 294 (if newvers
294 (list "-r" oldvers "-r" newvers) 295 (list "-r" oldvers "-r" newvers)
295 (list "-r" oldvers))))))) 296 (list "-r" oldvers)))))))
296 297
297(defun vc-hg-revision-table (files) 298(defun vc-hg-revision-table (files)
298 (let ((default-directory (file-name-directory (car files)))) 299 (let ((default-directory (file-name-directory (car files))))
@@ -313,7 +314,7 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
313 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. 314 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
314Optional arg REVISION is a revision to annotate from." 315Optional arg REVISION is a revision to annotate from."
315 (vc-hg-command buffer 0 file "annotate" "-d" "-n" 316 (vc-hg-command buffer 0 file "annotate" "-d" "-n"
316 (when revision (concat "-r" revision))) 317 (when revision (concat "-r" revision)))
317 (with-current-buffer buffer 318 (with-current-buffer buffer
318 (goto-char (point-min)) 319 (goto-char (point-min))
319 (re-search-forward "^[ \t]*[0-9]") 320 (re-search-forward "^[ \t]*[0-9]")
@@ -348,12 +349,12 @@ Optional arg REVISION is a revision to annotate from."
348 349
349(defun vc-hg-next-revision (file rev) 350(defun vc-hg-next-revision (file rev)
350 (let ((newrev (1+ (string-to-number rev))) 351 (let ((newrev (1+ (string-to-number rev)))
351 (tip-revision 352 (tip-revision
352 (with-temp-buffer 353 (with-temp-buffer
353 (vc-hg-command t 0 nil "tip") 354 (vc-hg-command t 0 nil "tip")
354 (goto-char (point-min)) 355 (goto-char (point-min))
355 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") 356 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
356 (string-to-number (match-string-no-properties 1))))) 357 (string-to-number (match-string-no-properties 1)))))
357 ;; We don't want to exceed the maximum possible revision number, ie 358 ;; We don't want to exceed the maximum possible revision number, ie
358 ;; the tip revision. 359 ;; the tip revision.
359 (when (<= newrev tip-revision) 360 (when (<= newrev tip-revision)
@@ -409,7 +410,7 @@ REV is ignored."
409 (let ((coding-system-for-read 'binary) 410 (let ((coding-system-for-read 'binary)
410 (coding-system-for-write 'binary)) 411 (coding-system-for-write 'binary))
411 (if rev 412 (if rev
412 (vc-hg-command buffer 0 file "cat" "-r" rev) 413 (vc-hg-command buffer 0 file "cat" "-r" rev)
413 (vc-hg-command buffer 0 file "cat")))) 414 (vc-hg-command buffer 0 file "cat"))))
414 415
415;; Modeled after the similar function in vc-bzr.el 416;; Modeled after the similar function in vc-bzr.el
@@ -464,64 +465,64 @@ REV is the revision to check out into WORKFILE."
464 (vc-default-dir-printer 'Hg info) 465 (vc-default-dir-printer 'Hg info)
465 (when extra 466 (when extra
466 (insert (propertize 467 (insert (propertize
467 (format " (%s %s)" 468 (format " (%s %s)"
468 (case (vc-hg-extra-fileinfo->rename-state extra) 469 (case (vc-hg-extra-fileinfo->rename-state extra)
469 ('copied "copied from") 470 ('copied "copied from")
470 ('renamed-from "renamed from") 471 ('renamed-from "renamed from")
471 ('renamed-to "renamed to")) 472 ('renamed-to "renamed to"))
472 (vc-hg-extra-fileinfo->extra-name extra)) 473 (vc-hg-extra-fileinfo->extra-name extra))
473 'face 'font-lock-comment-face))))) 474 'face 'font-lock-comment-face)))))
474 475
475(defun vc-hg-after-dir-status (update-function) 476(defun vc-hg-after-dir-status (update-function)
476 (let ((status-char nil) 477 (let ((status-char nil)
477 (file nil) 478 (file nil)
478 (translation '((?= . up-to-date) 479 (translation '((?= . up-to-date)
479 (?C . up-to-date) 480 (?C . up-to-date)
480 (?A . added) 481 (?A . added)
481 (?R . removed) 482 (?R . removed)
482 (?M . edited) 483 (?M . edited)
483 (?I . ignored) 484 (?I . ignored)
484 (?! . missing) 485 (?! . missing)
485 (? . copy-rename-line) 486 (? . copy-rename-line)
486 (?? . unregistered))) 487 (?? . unregistered)))
487 (translated nil) 488 (translated nil)
488 (result nil) 489 (result nil)
489 (last-added nil) 490 (last-added nil)
490 (last-line-copy nil)) 491 (last-line-copy nil))
491 (goto-char (point-min)) 492 (goto-char (point-min))
492 (while (not (eobp)) 493 (while (not (eobp))
493 (setq translated (cdr (assoc (char-after) translation))) 494 (setq translated (cdr (assoc (char-after) translation)))
494 (setq file 495 (setq file
495 (buffer-substring-no-properties (+ (point) 2) 496 (buffer-substring-no-properties (+ (point) 2)
496 (line-end-position))) 497 (line-end-position)))
497 (cond ((not translated) 498 (cond ((not translated)
498 (setq last-line-copy nil)) 499 (setq last-line-copy nil))
499 ((eq translated 'up-to-date) 500 ((eq translated 'up-to-date)
500 (setq last-line-copy nil)) 501 (setq last-line-copy nil))
501 ((eq translated 'copy-rename-line) 502 ((eq translated 'copy-rename-line)
502 ;; For copied files the output looks like this: 503 ;; For copied files the output looks like this:
503 ;; A COPIED_FILE_NAME 504 ;; A COPIED_FILE_NAME
504 ;; ORIGINAL_FILE_NAME 505 ;; ORIGINAL_FILE_NAME
505 (setf (nth 2 last-added) 506 (setf (nth 2 last-added)
506 (vc-hg-create-extra-fileinfo 'copied file)) 507 (vc-hg-create-extra-fileinfo 'copied file))
507 (setq last-line-copy t)) 508 (setq last-line-copy t))
508 ((and last-line-copy (eq translated 'removed)) 509 ((and last-line-copy (eq translated 'removed))
509 ;; For renamed files the output looks like this: 510 ;; For renamed files the output looks like this:
510 ;; A NEW_FILE_NAME 511 ;; A NEW_FILE_NAME
511 ;; ORIGINAL_FILE_NAME 512 ;; ORIGINAL_FILE_NAME
512 ;; R ORIGINAL_FILE_NAME 513 ;; R ORIGINAL_FILE_NAME
513 ;; We need to adjust the previous entry to not think it is a copy. 514 ;; We need to adjust the previous entry to not think it is a copy.
514 (setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added)) 515 (setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added))
515 'renamed-from) 516 'renamed-from)
516 (push (list file translated 517 (push (list file translated
517 (vc-hg-create-extra-fileinfo 518 (vc-hg-create-extra-fileinfo
518 'renamed-to (nth 0 last-added))) result) 519 'renamed-to (nth 0 last-added))) result)
519 (setq last-line-copy nil)) 520 (setq last-line-copy nil))
520 (t 521 (t
521 (setq last-added (list file translated nil)) 522 (setq last-added (list file translated nil))
522 (push last-added result) 523 (push last-added result)
523 (setq last-line-copy nil))) 524 (setq last-line-copy nil)))
524 (forward-line)) 525 (forward-line))
525 (funcall update-function result))) 526 (funcall update-function result)))
526 527
527(defun vc-hg-dir-status (dir update-function) 528(defun vc-hg-dir-status (dir update-function)
@@ -587,22 +588,22 @@ REV is the revision to check out into WORKFILE."
587 (interactive) 588 (interactive)
588 (let ((marked-list (log-view-get-marked))) 589 (let ((marked-list (log-view-get-marked)))
589 (if marked-list 590 (if marked-list
590 (vc-hg-command 591 (vc-hg-command
591 nil 0 nil 592 nil 0 nil
592 (cons "push" 593 (cons "push"
593 (apply 'nconc 594 (apply 'nconc
594 (mapcar (lambda (arg) (list "-r" arg)) marked-list)))) 595 (mapcar (lambda (arg) (list "-r" arg)) marked-list))))
595 (error "No log entries selected for push")))) 596 (error "No log entries selected for push"))))
596 597
597(defun vc-hg-pull () 598(defun vc-hg-pull ()
598 (interactive) 599 (interactive)
599 (let ((marked-list (log-view-get-marked))) 600 (let ((marked-list (log-view-get-marked)))
600 (if marked-list 601 (if marked-list
601 (vc-hg-command 602 (vc-hg-command
602 nil 0 nil 603 nil 0 nil
603 (cons "pull" 604 (cons "pull"
604 (apply 'nconc 605 (apply 'nconc
605 (mapcar (lambda (arg) (list "-r" arg)) marked-list)))) 606 (mapcar (lambda (arg) (list "-r" arg)) marked-list))))
606 (error "No log entries selected for pull")))) 607 (error "No log entries selected for pull"))))
607 608
608;;; Internal functions 609;;; Internal functions