Commit 98cfec0d authored by Chong Yidong's avatar Chong Yidong

Backport VC improvements from trunk.

* vc/log-edit.el (log-edit-rewrite-fixes): New var.
(log-edit-author): New dynamic var.
(log-edit-changelog-ours-p, log-edit-insert-changelog-entries):
Use it to return the author if different from committer.
(log-edit-insert-changelog): Use them to add Author: and Fixes headers.

* vc/vc-hooks.el (vc-default-mode-line-string): Doc fix.

* vc/vc.el (vc-deduce-backend): New fun.  Handle diff buffers.
(vc-root-diff, vc-print-root-log, vc-log-incoming)
(vc-log-outgoing): Use it.
(vc-diff-internal): Set diff-vc-backend.

* vc/diff-mode.el (diff-vc-backend): New var.

* vc/vc.el (vc-diff-internal): Set `revert-buffer-function'
buffer-locally to lambda that re-runs the vc diff command.
(Bug#6447)

* vc/log-view.el (log-view-mode-map): Bind revert-buffer.

Make 'g' (AKA revert-buffer) rerun VC log, log-incoming and
log-outgoing commands.
* vc/vc.el (vc-log-internal-common): Add a new argument and use it
to create a buffer local revert-buffer-function variable.
(vc-print-log-internal, vc-log-incoming, vc-log-outgoing): Pass a
revert-buffer-function lambda.

Improve VC create/retrieve tag/branch.
* vc.el (vc-create-tag): Do not read the directory name for VCs
with repository revision granularity.  Adjust the tag/branch
prompt.  Reset VC properties.
(vc-retrieve-tag): Do not read the directory name for VCs
with repository revision granularity.  Reset VC properties.

Add optional support for resetting VC properties.
* vc-dispatcher.el (vc-resynch-window): Add new optional argument,
call vc-file-clearprops when true.
(vc-resynch-buffer): Add new optional argument, pass it down.
(vc-resynch-buffers-in-directory): Likewise.

Improve support for special markup in the VC commit message.
* vc-mtn.el (vc-mtn-checkin): Support Author: and Date: markup.
* vc-hg.el (vc-hg-checkin): Add support for Date:.
* vc-git.el (vc-git-checkin):
* vc-bzr.el (vc-bzr-checkin): Likewise.

Add support for vc-log-incoming, improve vc-log-outgoing for Git.
* vc-git.el (vc-git-log-view-mode): Fix font lock for
incoming/outgoing logs.
(vc-git-log-outgoing, vc-git-log-incoming): New functions.

* vc-git.el (vc-git-log-outgoing): Use the same format as the
short log.
(vc-git-log-incoming): Likewise.  Run "git fetch" before the log
command

Add bindings for vc-log-incoming and vc-log-outgoing.
* vc-hooks.el (vc-prefix-map): Add bindings for vc-log-incoming
and vc-log-outgoing.
* vc-dir.el (vc-dir-menu-map): Add menu bindings for vc-log-incoming
and vc-log-outgoing.

Improve state updating for VC tag commands.
* vc.el (vc-create-tag, vc-retrieve-tag): Call vc-resynch-buffer
to update the state of all buffers in the directory.

* vc-dir.el (vc-dir): Don't pop-up-windows.  (Bug#6204)

* vc.el (vc-checkin, vc-modify-change-comment):
Adjust to new vc-start/finish-logentry.
(vc-find-conflicted-file): New command.
(vc-transfer-file): Adjust to new vc-checkin.
(vc-next-action): Improve scoping.

* vc-git.el (vc-git-checkin): Use log-edit-extract-headers.
(vc-git-commits-coding-system): Rename from git-commits-coding-system.

* vc-dispatcher.el (vc-log-edit): Shorten names for
log-edit-show-files.

* vc-bzr.el (vc-bzr-checkin): Use log-edit-extract-headers.
(vc-bzr-conflicted-files): New function.

* log-edit.el (log-edit-summary, log-edit-header)
(log-edit-unknown-header): New faces.
(log-edit-headers-alist): New var.
(log-edit-header-contents-regexp): New const.
(log-edit-match-to-eoh): New function.
(log-edit-font-lock-keywords): Use them.
(log-edit): Insert a "Summary:" header as default.
(log-edit-mode): Mark font-lock rules as case-insensitive.
(log-edit-done): Cleanup headers.
(log-edit-extract-headers): New function to replace it.

* vc-dispatcher.el (vc-finish-logentry): Don't mess so badly with
the windows/frames.

* vc-bzr.el (vc-bzr-shelve-apply): Don't use *vc-bzr-shelve*.

* vc-dir.el (vc-dir-kill-line): New command.
(vc-dir-mode-map): Bind it to C-k.
(vc-dir-headers): Abbreviate the working dir.

* vc-git.el (vc-git-revision-table): Include remote branches.

New VC methods: vc-log-incoming and vc-log-outgoing.
* vc.el (vc-print-log-setup-buttons, vc-log-internal-common)
(vc-incoming-outgoing-internal, vc-log-incoming, vc-log-outgoing):
New functions.
(vc-print-log-internal): Just call vc-log-internal-common.
(vc-log-view-type): New permanent local variable.

* vc-hooks.el (vc-menu-map): Bind vc-log-incoming and vc-log-outgoing.

* vc-bzr.el (vc-bzr-log-view-mode): Use vc-log-view-type instead
of the dynamic bound vc-short-log.
(vc-bzr-log-incoming, vc-bzr-log-outgoing): New functions.

* vc-git.el (vc-git-log-outgoing): New function.
(vc-git-log-view-mode): Use vc-log-view-type instead
of the dynamic bound vc-short-log.

* vc-hg.el (vc-hg-log-view-mode): Use vc-log-view-type instead of
the dynamic bound vc-short-log.  Highlight the tag.
(vc-hg-log-incoming, vc-hg-log-outgoing): New functions.
(vc-hg-outgoing, vc-hg-incoming, vc-hg-outgoing-mode):
(vc-hg-incoming-mode): Remove.
(vc-hg-extra-menu-map): Do not bind vc-hg-incoming and vc-hg-outgoing.

Fix default-directory for vc-root-diff.
* vc.el (vc-root-diff): Bind default-directory to the root
directory for the diff command.

* vc-hg.el (vc-hg-push, vc-hg-pull): Use `apply' when calling
`vc-hg-command' with a list of flags.

* vc-bzr.el (vc-bzr-log-edit-mode): Add --fixes support to
log-edit-before-checkin-process.

* vc.el (vc-modify-change-comment): Pass MODE to vc-start-logentry.

* vc-bzr.el, vc-hg.el (log-edit-mode): Declare.

* vc-dispatcher.el (vc-start-logentry): Doc fix.
(log-view-process-buffer, log-edit-extra-flags): Declare.

Add special markup processing for commit logs.
* log-edit.el (log-edit): Add new argument MODE.  Use that mode
when non-nil instead of the log-view-mode.

* vc.el (vc-default-log-edit-mode): New function.

* vc-dispatcher.el (vc-log-edit): Add a mode argument, pass it to
log-edit.

Support for shelving snapshots and for showing shelves.
* vc-bzr.el (vc-bzr-shelve-show, vc-bzr-shelve-show-at-point)
(vc-bzr-shelve-apply-and-keep-at-point, vc-bzr-shelve-snapshot):
New functions.
(vc-bzr-shelve-map, vc-bzr-shelve-menu-map)
(vc-bzr-extra-menu-map): Map them.
parent 6aad7ea0
......@@ -34,6 +34,42 @@ alt/option key by customizing the value for ns-right-alternate-modifier.
** The appt-add command takes an optional argument for the warning time.
This can be used in place of the default appt-message-warning-time.
** VC and related modes
*** New VC commands: vc-log-incoming, vc-log-outgoing, vc-find-conflicted-file.
**** vc-log-incoming for Git runs "git fetch" so that the necessary
data is available locally.
**** vc-log-incoming and vc-log-outgoing for Git require version 1.7 (or newer).
*** New key bindings: C-x v I and C-x v O bound to vc-log-incoming and
vc-log-outgoing, respectively.
*** The 'g' key in VC diff, log, log-incoming and log-outgoing buffers
reruns the corresponding VC command to compute an up to date version
of the buffer.
*** vc-dir for Bzr supports viewing shelve contents and shelving snapshots.
*** Special markup can be added to log-edit buffers.
The log-edit buffers are expected to have a format similar to email messages
with headers of the form:
Author: <author of this change>
Summary: <one line summary of this change>
Fixes: <reference to the bug fixed by this change>
Some backends handle some of those headers specially, but any unknown header
is just left as is in the message, so it is not lost.
**** vc-git handles Author: and Date:
**** vc-hg handles Author: and Date:
**** vc-bzr handles Author:, Date: and Fixes:
**** vc-mtn handles Author: and Date:
*** Pressing g in a *vc-diff* buffer reruns vc-diff, so it will
produce an up to date diff.
** Obsolete packages
+++
......
2010-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
* vc/log-edit.el (log-edit-rewrite-fixes): New var.
(log-edit-author): New dynamic var.
(log-edit-changelog-ours-p, log-edit-insert-changelog-entries):
Use it to return the author if different from committer.
(log-edit-insert-changelog): Use them to add Author: and Fixes headers.
2010-10-31 Eli Zaretskii <eliz@gnu.org>
* vc/vc-hooks.el (vc-default-mode-line-string): Doc fix.
2010-10-31 Chong Yidong <cyd@stupidchicken.com>
* vc/vc.el (vc-deduce-backend): New fun. Handle diff buffers.
(vc-root-diff, vc-print-root-log, vc-log-incoming)
(vc-log-outgoing): Use it.
(vc-diff-internal): Set diff-vc-backend.
* vc/diff-mode.el (diff-vc-backend): New var.
2010-10-31 Juri Linkov <juri@jurta.org>
* vc/vc.el (vc-diff-internal): Set `revert-buffer-function'
buffer-locally to lambda that re-runs the vc diff command.
(Bug#6447)
2010-10-31 Dan Nicolaescu <dann@ics.uci.edu>
* vc/log-view.el (log-view-mode-map): Bind revert-buffer.
Make 'g' (AKA revert-buffer) rerun VC log, log-incoming and
log-outgoing commands.
* vc/vc.el (vc-log-internal-common): Add a new argument and use it
to create a buffer local revert-buffer-function variable.
(vc-print-log-internal, vc-log-incoming, vc-log-outgoing): Pass a
revert-buffer-function lambda.
Improve VC create/retrieve tag/branch.
* vc.el (vc-create-tag): Do not read the directory name for VCs
with repository revision granularity. Adjust the tag/branch
prompt. Reset VC properties.
(vc-retrieve-tag): Do not read the directory name for VCs
with repository revision granularity. Reset VC properties.
Add optional support for resetting VC properties.
* vc-dispatcher.el (vc-resynch-window): Add new optional argument,
call vc-file-clearprops when true.
(vc-resynch-buffer): Add new optional argument, pass it down.
(vc-resynch-buffers-in-directory): Likewise.
Improve support for special markup in the VC commit message.
* vc-mtn.el (vc-mtn-checkin): Support Author: and Date: markup.
* vc-hg.el (vc-hg-checkin): Add support for Date:.
* vc-git.el (vc-git-checkin):
* vc-bzr.el (vc-bzr-checkin): Likewise.
Add support for vc-log-incoming, improve vc-log-outgoing for Git.
* vc-git.el (vc-git-log-view-mode): Fix font lock for
incoming/outgoing logs.
(vc-git-log-outgoing, vc-git-log-incoming): New functions.
* vc-git.el (vc-git-log-outgoing): Use the same format as the
short log.
(vc-git-log-incoming): Likewise. Run "git fetch" before the log
command
Add bindings for vc-log-incoming and vc-log-outgoing.
* vc-hooks.el (vc-prefix-map): Add bindings for vc-log-incoming
and vc-log-outgoing.
* vc-dir.el (vc-dir-menu-map): Add menu bindings for vc-log-incoming
and vc-log-outgoing.
Improve state updating for VC tag commands.
* vc.el (vc-create-tag, vc-retrieve-tag): Call vc-resynch-buffer
to update the state of all buffers in the directory.
2010-05-19 Glenn Morris <rgm@gnu.org>
* vc-dir.el (vc-dir): Don't pop-up-windows. (Bug#6204)
2010-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
* vc.el (vc-checkin, vc-modify-change-comment):
Adjust to new vc-start/finish-logentry.
(vc-find-conflicted-file): New command.
(vc-transfer-file): Adjust to new vc-checkin.
(vc-next-action): Improve scoping.
* vc-git.el (vc-git-checkin): Use log-edit-extract-headers.
(vc-git-commits-coding-system): Rename from git-commits-coding-system.
* vc-dispatcher.el (vc-log-edit): Shorten names for
log-edit-show-files.
* vc-bzr.el (vc-bzr-checkin): Use log-edit-extract-headers.
(vc-bzr-conflicted-files): New function.
* log-edit.el (log-edit-summary, log-edit-header)
(log-edit-unknown-header): New faces.
(log-edit-headers-alist): New var.
(log-edit-header-contents-regexp): New const.
(log-edit-match-to-eoh): New function.
(log-edit-font-lock-keywords): Use them.
(log-edit): Insert a "Summary:" header as default.
(log-edit-mode): Mark font-lock rules as case-insensitive.
(log-edit-done): Cleanup headers.
(log-edit-extract-headers): New function to replace it.
* vc-dispatcher.el (vc-finish-logentry): Don't mess so badly with
the windows/frames.
* vc-bzr.el (vc-bzr-shelve-apply): Don't use *vc-bzr-shelve*.
* vc-dir.el (vc-dir-kill-line): New command.
(vc-dir-mode-map): Bind it to C-k.
(vc-dir-headers): Abbreviate the working dir.
* vc-git.el (vc-git-revision-table): Include remote branches.
2010-10-31 Dan Nicolaescu <dann@ics.uci.edu>
New VC methods: vc-log-incoming and vc-log-outgoing.
* vc.el (vc-print-log-setup-buttons, vc-log-internal-common)
(vc-incoming-outgoing-internal, vc-log-incoming, vc-log-outgoing):
New functions.
(vc-print-log-internal): Just call vc-log-internal-common.
(vc-log-view-type): New permanent local variable.
* vc-hooks.el (vc-menu-map): Bind vc-log-incoming and vc-log-outgoing.
* vc-bzr.el (vc-bzr-log-view-mode): Use vc-log-view-type instead
of the dynamic bound vc-short-log.
(vc-bzr-log-incoming, vc-bzr-log-outgoing): New functions.
* vc-git.el (vc-git-log-outgoing): New function.
(vc-git-log-view-mode): Use vc-log-view-type instead
of the dynamic bound vc-short-log.
* vc-hg.el (vc-hg-log-view-mode): Use vc-log-view-type instead of
the dynamic bound vc-short-log. Highlight the tag.
(vc-hg-log-incoming, vc-hg-log-outgoing): New functions.
(vc-hg-outgoing, vc-hg-incoming, vc-hg-outgoing-mode):
(vc-hg-incoming-mode): Remove.
(vc-hg-extra-menu-map): Do not bind vc-hg-incoming and vc-hg-outgoing.
Fix default-directory for vc-root-diff.
* vc.el (vc-root-diff): Bind default-directory to the root
directory for the diff command.
2010-10-31 Sam Steingold <sds@gnu.org>
* vc-hg.el (vc-hg-push, vc-hg-pull): Use `apply' when calling
`vc-hg-command' with a list of flags.
2010-10-31 Glenn Morris <rgm@gnu.org>
* vc-bzr.el (vc-bzr-log-edit-mode): Add --fixes support to
log-edit-before-checkin-process.
* vc.el (vc-modify-change-comment): Pass MODE to vc-start-logentry.
* vc-bzr.el, vc-hg.el (log-edit-mode): Declare.
* vc-dispatcher.el (vc-start-logentry): Doc fix.
(log-view-process-buffer, log-edit-extra-flags): Declare.
2010-10-31 Dan Nicolaescu <dann@ics.uci.edu>
Add special markup processing for commit logs.
* log-edit.el (log-edit): Add new argument MODE. Use that mode
when non-nil instead of the log-view-mode.
* vc.el (vc-default-log-edit-mode): New function.
* vc-dispatcher.el (vc-log-edit): Add a mode argument, pass it to
log-edit.
Support for shelving snapshots and for showing shelves.
* vc-bzr.el (vc-bzr-shelve-show, vc-bzr-shelve-show-at-point)
(vc-bzr-shelve-apply-and-keep-at-point, vc-bzr-shelve-snapshot):
New functions.
(vc-bzr-shelve-map, vc-bzr-shelve-menu-map)
(vc-bzr-extra-menu-map): Map them.
2010-10-30 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-handle-insert-file-contents): For root,
......
......@@ -97,6 +97,9 @@ when editing big diffs)."
:options '(diff-delete-empty-files diff-make-unified)
:group 'diff-mode)
(defvar diff-vc-backend nil
"The VC backend that created the current Diff buffer, if any.")
(defvar diff-outline-regexp
"\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")
......@@ -138,6 +141,7 @@ when editing big diffs)."
;; Standard M-r is useful, so don't change M-r or M-R.
;;("r" . diff-restrict-view)
;;("R" . diff-reverse-direction)
("g" . revert-buffer)
("q" . quit-window))
"Basic keymap for `diff-mode', bound to various prefix keys.")
......
......@@ -125,6 +125,7 @@ If SETUP is 'force, this variable has no effect."
:type 'boolean)
(defcustom log-edit-hook '(log-edit-insert-cvs-template
log-edit-show-files
log-edit-insert-changelog)
"Hook run at the end of `log-edit'."
:group 'log-edit
......@@ -188,6 +189,7 @@ when this variable is set to nil.")
(defvar log-edit-callback nil)
(defvar log-edit-diff-function nil)
(defvar log-edit-listfun nil)
(defvar log-edit-parent-buffer nil)
;;; Originally taken from VC-Log mode
......@@ -312,15 +314,59 @@ automatically."
;;; Actual code
;;;
(defface log-edit-summary '((t :inherit font-lock-function-name-face))
"Face for the summary in `log-edit-mode' buffers.")
(defface log-edit-header '((t :inherit font-lock-keyword-face))
"Face for the headers in `log-edit-mode' buffers.")
(defface log-edit-unknown-header '((t :inherit font-lock-comment-face))
"Face for unknown headers in `log-edit-mode' buffers.")
(defvar log-edit-headers-alist '(("Summary" . log-edit-summary)
("Fixes") ("Author"))
"AList of known headers and the face to use to highlight them.")
(defconst log-edit-header-contents-regexp
"[ \t]*\\(.*\\(\n[ \t].*\\)*\\)\n?")
(defun log-edit-match-to-eoh (limit)
;; FIXME: copied from message-match-to-eoh.
(let ((start (point)))
(rfc822-goto-eoh)
;; Typical situation: some temporary change causes the header to be
;; incorrect, so EOH comes earlier than intended: the last lines of the
;; intended headers are now not considered part of the header any more,
;; so they don't have the multiline property set. When the change is
;; completed and the header has its correct shape again, the lack of the
;; multiline property means we won't rehighlight the last lines of
;; the header.
(if (< (point) start)
nil ;No header within start..limit.
;; Here we disregard LIMIT so that we may extend the area again.
(set-match-data (list start (point)))
(point))))
(defvar log-edit-font-lock-keywords
'(("\\`\\(Summary:\\)\\(.*\\)"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))))
;; Copied/inspired by message-font-lock-keywords.
`((log-edit-match-to-eoh
(,(concat "^\\(\\([a-z]+\\):\\)" log-edit-header-contents-regexp
"\\|\\(.*\\)")
(progn (goto-char (match-beginning 0)) (match-end 0)) nil
(1 (if (assoc (match-string 2) log-edit-headers-alist)
'log-edit-header
'log-edit-unknown-header)
nil lax)
(3 (or (cdr (assoc (match-string 2) log-edit-headers-alist))
'log-edit-header)
nil lax)
(4 font-lock-warning-face)))))
;;;###autoload
(defun log-edit (callback &optional setup params buffer &rest ignore)
(defun log-edit (callback &optional setup params buffer mode &rest ignore)
"Setup a buffer to enter a log message.
\\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
\\<log-edit-mode-map>The buffer will be put in mode MODE or `log-edit-mode'
if MODE is nil.
If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
Mark and point will be set around the entire contents of the buffer so
that it is easy to kill the contents of the buffer with \\[kill-region].
......@@ -340,8 +386,13 @@ uses the current buffer."
(if buffer (pop-to-buffer buffer))
(when (and log-edit-setup-invert (not (eq setup 'force)))
(setq setup (not setup)))
(when setup (erase-buffer))
(log-edit-mode)
(when setup
(erase-buffer)
(insert "Summary: ")
(save-excursion (insert "\n\n")))
(if mode
(funcall mode)
(log-edit-mode))
(set (make-local-variable 'log-edit-callback) callback)
(if (listp params)
(dolist (crt params)
......@@ -367,7 +418,7 @@ commands (under C-x v for VC, for example).
\\{log-edit-mode-map}"
(set (make-local-variable 'font-lock-defaults)
'(log-edit-font-lock-keywords t))
'(log-edit-font-lock-keywords t t))
(make-local-variable 'log-edit-comment-ring-index))
(defun log-edit-hide-buf (&optional buf where)
......@@ -380,6 +431,17 @@ commands (under C-x v for VC, for example).
"Finish editing the log message and commit the files.
If you want to abort the commit, simply delete the buffer."
(interactive)
;; Clean up empty headers.
(goto-char (point-min))
(while (looking-at (concat "^[a-z]*:" log-edit-header-contents-regexp))
(let ((beg (match-beginning 0)))
(goto-char (match-end 0))
(if (string-match "\\`[ \n\t]*\\'" (match-string 1))
(delete-region beg (point)))))
;; Get rid of leading empty lines.
(goto-char (point-min))
(when (looking-at "\\([ \t]*\n\\)+")
(delete-region (match-beginning 0) (match-end 0)))
;; Get rid of trailing empty lines
(goto-char (point-max))
(skip-syntax-backward " ")
......@@ -437,12 +499,13 @@ If you want to abort the commit, simply delete the buffer."
"(Un)Indent the current buffer rigidly to `log-edit-common-indent'."
(save-excursion
(let ((common (point-max)))
(goto-char (point-min))
(rfc822-goto-eoh)
(while (< (point) (point-max))
(if (not (looking-at "^[ \t]*$"))
(setq common (min common (current-indentation))))
(forward-line 1))
(indent-rigidly (point-min) (point-max)
(rfc822-goto-eoh)
(indent-rigidly (point) (point-max)
(- log-edit-common-indent common)))))
(defun log-edit-show-diff ()
......@@ -508,6 +571,16 @@ can thus take some time."
(log-edit-comment-to-change-log)))))
(defvar log-edit-changelog-use-first nil)
(defvar log-edit-rewrite-fixes nil
"Rule to rewrite bug numbers into Fixes: headers.
The value should be of the form (REGEXP . REPLACEMENT)
where REGEXP should match the expression referring to a bug number
in the text, and REPLACEMENT is an expression to pass to `replace-match'
to build the Fixes: header.")
(put 'log-edit-rewrite-fixes 'safe-local-variable
(lambda (v) (and (stringp (car-safe v)) (stringp (cdr v)))))
(defun log-edit-insert-changelog (&optional use-first)
"Insert a log message by looking at the ChangeLog.
The idea is to write your ChangeLog entries first, and then use this
......@@ -525,18 +598,38 @@ If the optional prefix arg USE-FIRST is given (via \\[universal-argument]),
or if the command is repeated a second time in a row, use the first log entry
regardless of user name or time."
(interactive "P")
(let ((log-edit-changelog-use-first
(or use-first (eq last-command 'log-edit-insert-changelog))))
(log-edit-insert-changelog-entries (log-edit-files)))
(log-edit-set-common-indentation)
(goto-char (point-min))
(when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+"))
(forward-line 1)
(when (not (re-search-forward "^\\*\\s-+" nil t))
(goto-char (point-min))
(skip-chars-forward "^():")
(skip-chars-forward ": ")
(delete-region (point-min) (point)))))
(let ((eoh (save-excursion (rfc822-goto-eoh) (point))))
(when (<= (point) eoh)
(goto-char eoh)
(if (looking-at "\n") (forward-char 1))))
(let ((author
(let ((log-edit-changelog-use-first
(or use-first (eq last-command 'log-edit-insert-changelog))))
(log-edit-insert-changelog-entries (log-edit-files)))))
(log-edit-set-common-indentation)
;; Add an Author: field if appropriate.
(when author
(rfc822-goto-eoh)
(insert "Author: " author "\n" (if (looking-at "\n") "" "\n")))
;; Add a Fixes: field if applicable.
(when (consp log-edit-rewrite-fixes)
(rfc822-goto-eoh)
(when (re-search-forward (car log-edit-rewrite-fixes) nil t)
(let ((start (match-beginning 0))
(end (match-end 0))
(fixes (match-substitute-replacement
(cdr log-edit-rewrite-fixes))))
(delete-region start end)
(rfc822-goto-eoh)
(insert "Fixes: " fixes "\n" (if (looking-at "\n") "" "\n")))))
(goto-char (point-min))
(when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+"))
(forward-line 1)
(when (not (re-search-forward "^\\*\\s-+" nil t))
(goto-char (point-min))
(skip-chars-forward "^():")
(skip-chars-forward ": ")
(delete-region (point-min) (point))))))
;;;;
;;;; functions for getting commit message from ChangeLog a file...
......@@ -602,6 +695,9 @@ for more details."
(defvar user-full-name)
(defvar user-mail-address)
(defvar log-edit-author) ;Dynamically scoped.
(defun log-edit-changelog-ours-p ()
"See if ChangeLog entry at point is for the current user, today.
Return non-nil if it is."
......@@ -616,14 +712,28 @@ Return non-nil if it is."
(functionp add-log-time-format)
(funcall add-log-time-format))
(format-time-string "%Y-%m-%d"))))
(looking-at (if log-edit-changelog-use-first
"[^ \t]"
(regexp-quote (format "%s %s <%s>" time name mail))))))
(if (null log-edit-changelog-use-first)
(looking-at (regexp-quote (format "%s %s <%s>" time name mail)))
;; Check the author, to potentially add it as a "Author: " header.
(when (looking-at "[^ \t]")
(when (and (boundp 'log-edit-author)
(not (looking-at (format ".+ .+ <%s>"
(regexp-quote mail))))
(looking-at ".+ \\(.+ <.+>\\)"))
(let ((author (replace-regexp-in-string " " " "
(match-string 1))))
(unless (and log-edit-author
(string-match (regexp-quote author) log-edit-author))
(setq log-edit-author
(if log-edit-author
(concat log-edit-author ", " author)
author)))))
t))))
(defun log-edit-changelog-entries (file)
"Return the ChangeLog entries for FILE, and the ChangeLog they came from.
The return value looks like this:
(LOGBUFFER (ENTRYSTART . ENTRYEND) ...)
(LOGBUFFER (ENTRYSTART ENTRYEND) ...)
where LOGBUFFER is the name of the ChangeLog buffer, and each
\(ENTRYSTART . ENTRYEND\) pair is a buffer region."
(let ((changelog-file-name
......@@ -681,34 +791,87 @@ where LOGBUFFER is the name of the ChangeLog buffer, and each
(cons (current-buffer) texts))))))))
(defun log-edit-changelog-insert-entries (buffer regions)
"Insert those regions in BUFFER specified in REGIONS.
Sort REGIONS front-to-back first."
(let ((regions (sort regions 'car-less-than-car))
(last))
(dolist (region regions)
(when (and last (< last (car region))) (newline))
(setq last (elt region 1))
(apply 'insert-buffer-substring buffer region))))
(defun log-edit-changelog-insert-entries (buffer beg end &rest files)
"Insert the text from BUFFER between BEG and END.
Rename relative filenames in the ChangeLog entry as FILES."
(let ((opoint (point))
(log-name (buffer-file-name buffer))
(case-fold-search nil)
bound)
(insert-buffer-substring buffer beg end)
(setq bound (point-marker))
(when log-name
(dolist (f files)
(save-excursion
(goto-char opoint)
(when (re-search-forward
(concat "\\(^\\|[ \t]\\)\\("
(file-relative-name f (file-name-directory log-name))
"\\)[, :\n]")
bound t)
(replace-match f t t nil 2)))))
;; Eliminate tabs at the beginning of the line.
(save-excursion
(goto-char opoint)
(while (re-search-forward "^\\(\t+\\)" bound t)
(replace-match "")))))
(defun log-edit-insert-changelog-entries (files)
"Given a list of files FILES, insert the ChangeLog entries for them."
(let ((buffer-entries nil))
;; Add each buffer to buffer-entries, and associate it with the list
;; of entries we want from that file.
(let ((log-entries nil)
(log-edit-author nil))
;; Note that any ChangeLog entry can apply to more than one file.
;; Here we construct a log-entries list with elements of the form
;; ((LOGBUFFER ENTRYSTART ENTRYEND) FILE1 FILE2...)
(dolist (file files)
(let* ((entries (log-edit-changelog-entries file))
(pair (assq (car entries) buffer-entries)))
(if pair
(setcdr pair (cvs-union (cdr pair) (cdr entries)))
(push entries buffer-entries))))
;; Now map over each buffer in buffer-entries, sort the entries for
;; each buffer, and extract them as strings.
(dolist (buffer-entry buffer-entries)
(log-edit-changelog-insert-entries (car buffer-entry) (cdr buffer-entry))
(when (cdr buffer-entry) (newline)))))
(buf (car entries))
key entry)
(dolist (region (cdr entries))
(setq key (cons buf region))
(if (setq entry (assoc key log-entries))
(setcdr entry (append (cdr entry) (list file)))
(push (list key file) log-entries)))))
;; Now map over log-entries, and extract the strings.
(dolist (log-entry (nreverse log-entries))
(apply 'log-edit-changelog-insert-entries
(append (car log-entry) (cdr log-entry)))
(insert "\n"))
log-edit-author))
(defun log-edit-extract-headers (headers comment)
"Extract headers from COMMENT to form command line arguments.
HEADERS should be an alist with elements of the form (HEADER . CMDARG)
associating header names to the corresponding cmdline option name and the
result is then a list of the form (MSG CMDARG1 HDRTEXT1 CMDARG2 HDRTEXT2...).
where MSG is the remaining text from STRING.
If \"Summary\" is not in HEADERS, then the \"Summary\" header is extracted
anyway and put back as the first line of MSG."
(with-temp-buffer
(insert comment)
(rfc822-goto-eoh)
(narrow-to-region (point-min) (point))
(let ((case-fold-search t)
(summary ())
(res ()))
(dolist (header (if (assoc "Summary" headers) headers
(cons '("Summary" . t) headers)))
(goto-char (point-min))
(while (re-search-forward (concat "^" (car header)
":" log-edit-header-contents-regexp)
nil t)
(if (eq t (cdr header))
(setq summary (match-string 1))
(push (match-string 1) res)
(push (or (cdr header) (car header)) res))
(replace-match "" t t)))
;; Remove header separator if the header is empty.
(widen)
(goto-char (point-min))
(when (looking-at "\\([ \t]*\n\\)+")
(delete-region (match-beginning 0) (match-end 0)))
(if summary (insert summary "\n"))
(cons (buffer-string) res))))
(provide 'log-edit)
......
......@@ -128,6 +128,7 @@
(easy-mmode-defmap log-view-mode-map
'(("z" . kill-this-buffer)
("q" . quit-window)
("g" . revert-buffer)
("m" . log-view-toggle-mark-entry)
("e" . log-view-modify-change-comment)
("d" . log-view-diff)
......
......@@ -254,8 +254,7 @@ Only the value `maybe' can be trusted :-(."
(buffer-substring (point-min) (1- (point-max)))))))))
(defun vc-arch-workfile-unchanged-p (file)
"Check if FILE is unchanged by diffing against the master version.
Return non-nil if FILE is unchanged."
"Stub: arch workfiles are always considered to be in a changed state,"
nil)
(defun vc-arch-state (file)
......
......@@ -451,11 +451,17 @@ or a superior directory.")
"Unregister FILE from bzr."
(vc-bzr-command "remove" nil 0 file "--keep"))