|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defvar ucl-o (or (getenv "RCS2LOG_OPTS") "") |
|
"Additional options to pass to rcs2log.") |
|
|
|
|
|
|
|
|
|
(defun ucl-stitch-new-old (new-old &rest ignore) |
|
"In a changelog buffer, remove redundancy around NEW-OLD point. |
|
The new text is before NEW-OLD point, and the old after." |
|
(goto-char new-old) |
|
(or (= new-old (point-max)) |
|
(let ((last-new |
|
(save-excursion |
|
(buffer-substring (re-search-backward "^[0-9]+") new-old)))) |
|
(let ((has-diff (string-match "\n\tdiff.*-r" last-new))) |
|
(and has-diff (setq last-new (substring last-new 0 has-diff)))) |
|
(let ((overlap (search-forward last-new (point-max) t))) |
|
(and overlap (delete-region new-old overlap)))))) |
|
|
|
|
|
(defun ucl-omit-diffs (&rest ignore) |
|
"In a changelog buffer, delete diffs (assumed at end of entry)." |
|
(goto-char (point-min)) |
|
(while (re-search-forward "^\tdiff .*-r" (point-max) t) |
|
(beginning-of-line) |
|
(delete-region (point) |
|
(save-excursion |
|
(if (re-search-forward "^[0-9]+" (point-max)) |
|
(- (point) 4) |
|
(point-max)))))) |
|
|
|
(defun ucl-space-out-entries (&rest ignore) |
|
"In a changelog buffer, ensure proper spacing between entries." |
|
(goto-char (point-max)) |
|
(while (re-search-backward "^[0-9]+" (point-min) t) |
|
(unless (= (point) (point-min)) |
|
(open-line 3) |
|
(delete-blank-lines)))) |
|
|
|
(defun ucl-kill-eol-white-space (&rest ignore) |
|
"In a changelog buffer, delete end-of-line white space." |
|
(goto-char (point-min)) |
|
(while (re-search-forward "[ \t]+$" (point-max) t) |
|
(delete-region |
|
(match-beginning 0) (match-end 0)))) |
|
|
|
(defvar ucl-cleanup-hook '(ucl-stitch-new-old |
|
ucl-omit-diffs |
|
ucl-space-out-entries |
|
ucl-kill-eol-white-space) |
|
"Hook run after combining the new fragment with the old changelog. These |
|
are called with the argument NEW-OLD, which is the buffer position at the |
|
boundary of the two pieces of text. This is suboptimal; we should use a |
|
marker so that munges on the text do not lose this position. The result is |
|
that currently, `ucl-stitch-new-old' must be called first because it depends |
|
on NEW-OLD, while the other cleanup funcs ignore it. (Sigh.)") |
|
|
|
;;;--------------------------------------------------------------------------- |
|
;;; Update functions |
|
|
|
(defun ucl-root () |
|
(let ((lwr (getenv "LOCAL_WORK_ROOT")) |
|
(cr (getenv "CVSROOT"))) |
|
(concat (or lwr |
|
(and cr (progn |
|
(setq ucl-o (concat "-R " ucl-o)) ; hmm |
|
cr)) |
|
(error "Must set env var LOCAL_WORK_ROOT or CVSROOT")) |
|
"/"))) |
|
|
|
(defun ucl-update (filename) |
|
(interactive "fChangeLog: ") |
|
(let* ((ofile (expand-file-name filename)) |
|
(cmd (concat "rcs2log " ucl-o " -c " ofile)) |
|
(obuf "*ucl-work*")) |
|
(when (and (file-exists-p ofile) |
|
(progn |
|
(shell-command cmd obuf) |
|
(get-buffer obuf))) |
|
(save-excursion ; prevent default-directory hosing |
|
(set-buffer obuf) |
|
(unless (= 0 (buffer-size)) |
|
(let ((new-old-boundary (point-max))) |
|
(goto-char new-old-boundary) |
|
(insert-file ofile) |
|
(run-hook-with-args 'ucl-cleanup-hook new-old-boundary)) |
|
(or (= (buffer-size) (nth 7 (file-attributes ofile))) |
|
(let (make-backup-files) ; less clutter |
|
(write-file ofile)))) |
|
(kill-buffer (current-buffer)))))) |
|
|
|
;;;--------------------------------------------------------------------------- |
|
;;; Load-time actions |
|
|
|
(when noninteractive ; only when `-batch' |
|
(or (ucl-update "ChangeLog") |
|
(message "Sorry, could not update ChangeLog in %s" default-directory))) |
|
|
|
(provide 'update-changelog) |
|
|
|
;;; update-changelog.el ends here |
|
|