* lisp/vc/vc-bzr.el (vc-bzr--sanitize-header): New function.

(vc-bzr-checkin): Use it.
* lisp/vc/log-edit.el (log-edit-extract-headers): Don't presume FUNCTION
will preserve match-data.

Fixes: debbugs:13307
This commit is contained in:
Stefan Monnier 2013-01-11 22:15:14 -05:00
parent fbc9ce11fa
commit a07846093f
3 changed files with 29 additions and 12 deletions

View file

@ -1,3 +1,10 @@
2013-01-12 Stefan Monnier <monnier@iro.umontreal.ca>
* vc/vc-bzr.el (vc-bzr--sanitize-header): New function (bug#13307).
(vc-bzr-checkin): Use it.
* vc/log-edit.el (log-edit-extract-headers): Don't presume FUNCTION
will preserve match-data.
2013-01-11 Felix H. Dahlke <fhd@ubercode.de>
* progmodes/js.el: Fix multiline declarations's indentation (bug#8576).

View file

@ -953,13 +953,14 @@ line of MSG."
(while (re-search-forward (concat "^" (car header)
":" log-edit-header-contents-regexp)
nil t)
(if (eq t (cdr header))
(setq summary (match-string 1))
(if (functionp (cdr header))
(setq res (nconc res (funcall (cdr header) (match-string 1))))
(push (match-string 1) res)
(push (or (cdr header) (car header)) res)))
(replace-match "" t t)))
(let ((txt (match-string 1)))
(replace-match "" t t)
(if (eq t (cdr header))
(setq summary txt)
(if (functionp (cdr header))
(setq res (nconc res (funcall (cdr header) txt)))
(push txt res)
(push (or (cdr header) (car header)) res))))))
;; Remove header separator if the header is empty.
(widen)
(goto-char (point-min))

View file

@ -620,15 +620,24 @@ or a superior directory.")
(declare-function log-edit-extract-headers "log-edit" (headers string))
(defun vc-bzr--sanitize-header (arg)
;; Newlines in --fixes (and probably other fields as well) trigger a nasty
;; Bazaar bug; see https://bugs.launchpad.net/bzr/+bug/1094180.
(lambda (str) (list arg
(replace-regexp-in-string "\\`[ \t]+\\|[ \t]+\\'"
"" (replace-regexp-in-string
"\n[ \t]?" " " str)))))
(defun vc-bzr-checkin (files rev comment)
"Check FILES in to bzr with log message COMMENT.
REV non-nil gets an error."
(if rev (error "Can't check in a specific revision with bzr"))
(apply 'vc-bzr-command "commit" nil 0
files (cons "-m" (log-edit-extract-headers '(("Author" . "--author")
("Date" . "--commit-time")
("Fixes" . "--fixes"))
comment))))
(apply 'vc-bzr-command "commit" nil 0 files
(cons "-m" (log-edit-extract-headers
`(("Author" . ,(vc-bzr--sanitize-header "--author"))
("Date" . ,(vc-bzr--sanitize-header "--commit-time"))
("Fixes" . ,(vc-bzr--sanitize-header "--fixes")))
comment))))
(defun vc-bzr-find-revision (file rev buffer)
"Fetch revision REV of file FILE and put it into BUFFER."