]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/vc-bzr.el (vc-bzr--sanitize-header): New function.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 12 Jan 2013 03:15:14 +0000 (22:15 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 12 Jan 2013 03:15:14 +0000 (22:15 -0500)
(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
lisp/ChangeLog
lisp/vc/log-edit.el
lisp/vc/vc-bzr.el

index c600e37570f9f4a569ddcffef22dea700cd8f59c..b90a5ecd11e16522b7ec7feb2959ac11aeeb5691 100644 (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).
index f8e753772e45b2981805c5982f5d97547d0cb5e7..dfc7eee81a657c265927d2599c10014d45ce8941 100644 (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))
index f436d300089f038744752b5c0643aa16c1346242..0968c83ae5f1186f9addd7cf445b3767cb6afc95 100644 (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."