summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2015-04-11 07:09:28 +0300
committerDmitry Gutov <dgutov@yandex.ru>2015-04-11 07:09:56 +0300
commit878058df46b593dd2afaad2086d8ff10bff367c2 (patch)
tree4ab8a61eac7833a14c08595247d58d5c73e67065
parente3ee455d2992f4adddcd27196b47273f6cacb4e1 (diff)
downloademacs-878058df46b593dd2afaad2086d8ff10bff367c2.tar.gz
Extract ChangeLog entries when committing a directory
* lisp/vc/vc-dispatcher.el (vc-log-edit): Update FIXME comment. * lisp/vc/log-edit.el (log-edit-changelog-insert-entries): Add a FIXME comment. (log-edit-changelog-entries): Extract from `log-edit-changelog-entries', handle FILE being a directory (http://lists.gnu.org/archive/html/emacs-devel/2015-04/msg00555.html).
-rw-r--r--lisp/vc/log-edit.el38
-rw-r--r--lisp/vc/vc-dispatcher.el10
2 files changed, 30 insertions, 18 deletions
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index e74ca7267c5..f82c7e9052e 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -917,21 +917,8 @@ where LOGBUFFER is the name of the ChangeLog buffer, and each
(log-edit-narrow-changelog)
(goto-char (point-min))
- ;; Search for the name of FILE relative to the ChangeLog. If that
- ;; doesn't occur anywhere, they're not using full relative
- ;; filenames in the ChangeLog, so just look for FILE; we'll accept
- ;; some false positives.
- (let ((pattern (file-relative-name
- file (file-name-directory changelog-file-name))))
- (if (or (string= pattern "")
- (not (save-excursion
- (search-forward pattern nil t))))
- (setq pattern (file-name-nondirectory file)))
-
- (setq pattern (concat "\\(^\\|[^[:alnum:]]\\)"
- (regexp-quote pattern)
- "\\($\\|[^[:alnum:]]\\)"))
-
+ (let ((pattern (log-edit-changelog--pattern file
+ changelog-file-name)))
(let (texts
(pos (point)))
(while (and (not (eobp)) (re-search-forward pattern nil t))
@@ -946,6 +933,25 @@ where LOGBUFFER is the name of the ChangeLog buffer, and each
(cons (current-buffer) texts)))))))))
+(defun log-edit-changelog--pattern (file changelog-file-name)
+ (if (eq (aref file (1- (length file))) ?/)
+ ;; Match any files inside this directory.
+ (concat "^\t\\* " (unless (string= file "./") file))
+ ;; Search for the name of FILE relative to the ChangeLog. If that
+ ;; doesn't occur anywhere, they're not using full relative
+ ;; filenames in the ChangeLog, so just look for FILE; we'll accept
+ ;; some false positives.
+ (let ((pattern (file-relative-name
+ file (file-name-directory changelog-file-name))))
+ ;; FIXME: When can the above return an empty string?
+ (if (or (string= pattern "")
+ (not (save-excursion
+ (search-forward pattern nil t))))
+ (setq pattern (file-name-nondirectory file)))
+ (setq pattern (concat "\\(^\\|[^[:alnum:]]\\)"
+ (regexp-quote pattern)
+ "\\($\\|[^[:alnum:]]\\)")))))
+
(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."
@@ -957,6 +963,8 @@ Rename relative filenames in the ChangeLog entry as FILES."
(setq bound (point-marker))
(when log-name
(dolist (f files)
+ ;; FIXME: f can be a directory, a (possibly indirect) parent
+ ;; of the ChangeLog file.
(save-excursion
(goto-char opoint)
(when (re-search-forward
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index 8b3e888f700..a2c1cba5fde 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -606,9 +606,13 @@ NOT-URGENT means it is ok to continue if the user says not to save."
(not (equal vc-log-fileset fileset))))
`((log-edit-listfun
. (lambda ()
- ;; FIXME: Should expand the list for directories.
- ;; Is the above still relevant? If so, it needs a
- ;; better explanation. -- dgutov
+ ;; FIXME: When fileset includes directories, and
+ ;; there are relevant ChangeLog files inside their
+ ;; children, we don't find them. Either handle it
+ ;; in `log-edit-insert-changelog-entries' by
+ ;; walking down the file trees, or somehow pass
+ ;; `fileset-only-files' from `vc-next-action'
+ ;; through to this function.
(let ((root (vc-root-dir)))
;; Returns paths relative to the root, so that
;; `log-edit-changelog-insert-entries'