aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2013-01-11 22:15:14 -0500
committerStefan Monnier <[email protected]>2013-01-11 22:15:14 -0500
commita07846093f1d91ab7d6c0e86a29aee357685292f (patch)
tree104d4f4f03e23e9aae01b63403b53ca8153a7b2f /lisp/vc
parentfbc9ce11fa593f2fb87a8a0ea5f1b7a78bd13425 (diff)
* 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
Diffstat (limited to 'lisp/vc')
-rw-r--r--lisp/vc/log-edit.el15
-rw-r--r--lisp/vc/vc-bzr.el19
2 files changed, 22 insertions, 12 deletions
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index f8e753772e..dfc7eee81a 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -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))
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index f436d30008..0968c83ae5 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -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."