diff options
Diffstat (limited to 'lisp/vc/vc-bzr.el')
-rw-r--r-- | lisp/vc/vc-bzr.el | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index f436d300089..4a08403c93e 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -291,7 +291,7 @@ in the repository root directory of FILE." ;;;###autoload (defun vc-bzr-registered (file) ;;;###autoload (if (vc-find-root file vc-bzr-admin-checkout-format-file) ;;;###autoload (progn -;;;###autoload (load "vc-bzr") +;;;###autoload (load "vc-bzr" nil t) ;;;###autoload (vc-bzr-registered file)))) (defun vc-bzr-registered (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." @@ -644,7 +653,7 @@ REV non-nil gets an error." (defun vc-bzr-revert (file &optional contents-done) (unless contents-done - (with-temp-buffer (vc-bzr-command "revert" t 0 file)))) + (with-temp-buffer (vc-bzr-command "revert" t 0 file "--no-backup")))) (defvar log-view-message-re) (defvar log-view-file-re) @@ -685,7 +694,10 @@ REV non-nil gets an error." ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face))))))) (defun vc-bzr-print-log (files buffer &optional shortlog start-revision limit) - "Get bzr change log for FILES into specified BUFFER." + "Print commit log associated with FILES into specified BUFFER. +If SHORTLOG is non-nil, use --line format. +If START-REVISION is non-nil, it is the newest revision to show. +If LIMIT is non-nil, show no more than this many entries." ;; `vc-do-command' creates the buffer, but we need it before running ;; the command. (vc-setup-buffer buffer) @@ -698,8 +710,33 @@ REV non-nil gets an error." (apply 'vc-bzr-command "log" buffer 'async files (append (when shortlog '("--line")) - (when start-revision (list (format "-r..%s" start-revision))) + ;; The extra complications here when start-revision and limit + ;; are set are due to bzr log's --forward argument, which + ;; could be enabled via an alias in bazaar.conf. + ;; Svn, for example, does not have this problem, because + ;; it doesn't have --forward. Instead, you can use + ;; svn --log -r HEAD:0 or -r 0:HEAD as you prefer. + ;; Bzr, however, insists in -r X..Y that X come before Y. + (if start-revision + (list (format + (if (and limit (= limit 1)) + ;; This means we don't have to use --no-aliases. + ;; Is -c any different to -r in this case? + "-r%s" + "-r..%s") start-revision))) (when limit (list "-l" (format "%s" limit))) + ;; There is no sensible way to combine --limit and --forward, + ;; and it breaks the meaning of START-REVISION as the + ;; _newest_ revision. See bug#14168. + ;; Eg bzr log --forward -r ..100 --limit 50 prints + ;; revisions 1-50 rather than 50-100. There + ;; seems no way in general to get bzr to print revisions + ;; 50-100 in --forward order in that case. + ;; FIXME There may be other alias stuff we want to keep. + ;; Is there a way to just suppress --forward? + ;; As of 2013/4 the only caller uses limit = 1, so it does + ;; not matter much. + (and start-revision limit (> limit 1) '("--no-aliases")) (if (stringp vc-bzr-log-switches) (list vc-bzr-log-switches) vc-bzr-log-switches))))) |