[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#881: patch for bug #881
From: |
Dan Nicolaescu |
Subject: |
Re: bug#881: patch for bug #881 |
Date: |
Sun, 17 Jan 2010 01:38:26 -0800 (PST) |
Chong Yidong <address@hidden> writes:
> Juanma Barranquero <address@hidden> writes:
>
> > On Sat, Jan 16, 2010 at 22:50, Chong Yidong <address@hidden> wrote:
> >
> >> I don't think we should require --author until VC supports it.
> >> It's a major inconvenience.
> >
> > I think giving proper credit and keeping logs honest trumps over
> > inconvenience. But that's just MHO, of course.
>
> Our acknowledgements are generated from the ChangeLogs, so I don't think
> that's the issue. Sure, it would be nice to use the --author flag,
> because that's what the flag is intended for. But it is too
> inconvenient unless VC can handle it.
I have a patch to add that functionality to VC.
Writing:
Author: The Real Author <address@hidden>
in the log edit buffer
will pass the right flag to "bzr commit".
Maybe an interactive function to ask the author information could be
added later.
Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.746
diff -u -3 -p -r1.746 vc.el
--- vc.el 7 Dec 2009 09:02:16 -0000 1.746
+++ vc.el 17 Jan 2010 09:22:23 -0000
@@ -261,7 +261,7 @@
;; Unregister FILE from this backend. This is only needed if this
;; backend may be used as a "more local" backend for temporary editing.
;;
-;; * checkin (files rev comment)
+;; * checkin (files rev comment &optional extra-args)
;;
;; Commit changes in FILES to this backend. If REV is non-nil, that
;; should become the new revision number (not all backends do
@@ -269,6 +269,7 @@
;; implementation should pass the value of vc-checkin-switches to
;; the backend command. (Note: in older versions of VC, this
;; command took a single file argument and not a list.)
+;; EXTRA-ARGS should be passed to the backend command.
;;
;; * find-revision (file rev buffer)
;;
@@ -477,6 +478,12 @@
;; Return the revision number that follows REV for FILE, or nil if no such
;; revision exists.
;;
+;; - log-edit-mode ()
+;;
+;; Turn on the mode used for editing the check in log. This
+;; defaults to `log-edit-mode'. If changed, it should use a mode
+;; derived from`log-edit-mode'.
+;;
;; - check-headers ()
;;
;; Return non-nil if the current buffer contains any version headers.
@@ -1348,7 +1365,9 @@ Runs the normal hooks `vc-before-checkin
files rev comment initial-contents
"Enter a change comment."
"*VC-log*"
- (lambda (files rev comment)
+ (lambda ()
+ (vc-call-backend backend 'log-edit-mode))
+ (lambda (files rev comment extra-flags)
(message "Checking in %s..." (vc-delistify files))
;; "This log message intentionally left almost blank".
;; RCS 5.7 gripes about white-space-only comments too.
@@ -1359,7 +1378,7 @@ Runs the normal hooks `vc-before-checkin
;; We used to change buffers to get local value of vc-checkin-switches,
;; but 'the' local buffer is not a well-defined concept for filesets.
(progn
- (vc-call-backend backend 'checkin files rev comment)
+ (vc-call-backend backend 'checkin files rev comment extra-flags)
(mapc 'vc-delete-automatic-version-backups files))
`((vc-state . up-to-date)
(vc-checkout-time . ,(nth 5 (file-attributes file)))
@@ -1729,7 +1748,7 @@ The headers are reset to their non-expan
files rev oldcomment t
"Enter a replacement change comment."
"*VC-log*"
- (lambda (files rev comment)
+ (lambda (files rev comment ignored)
(vc-call-backend
;; Less of a kluge than it looks like; log-view mode only passes
;; this function a singleton list. Arguments left in this form in
@@ -2414,6 +2433,8 @@ to provide the `find-revision' operation
(defalias 'vc-default-check-headers 'ignore)
+(defun vc-default-log-edit-mode (backend) (log-edit-mode))
+
(defun vc-default-log-view-mode (backend) (log-view-mode))
(defun vc-default-show-log-entry (backend rev)
Index: vc-dispatcher.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-dispatcher.el,v
retrieving revision 1.71
diff -u -3 -p -r1.71 vc-dispatcher.el
--- vc-dispatcher.el 1 Oct 2009 03:32:27 -0000 1.71
+++ vc-dispatcher.el 17 Jan 2010 09:22:23 -0000
@@ -519,20 +519,22 @@ NOT-URGENT means it is ok to continue if
;; Set up key bindings for use while editing log messages
-(defun vc-log-edit (fileset)
+(defun vc-log-edit (fileset mode)
"Set up `log-edit' for use on FILE."
(setq default-directory
(with-current-buffer vc-parent-buffer default-directory))
(log-edit 'vc-finish-logentry
nil
`((log-edit-listfun . (lambda () ',fileset))
- (log-edit-diff-function . (lambda () (vc-diff nil)))))
+ (log-edit-diff-function . (lambda () (vc-diff nil))))
+ nil
+ mode)
(set (make-local-variable 'vc-log-fileset) fileset)
(make-local-variable 'vc-log-extra)
(set-buffer-modified-p nil)
(setq buffer-file-name nil))
-(defun vc-start-logentry (files extra comment initial-contents msg logbuf
action &optional after-hook)
+(defun vc-start-logentry (files extra comment initial-contents msg logbuf mode
action &optional after-hook)
"Accept a comment for an operation on FILES with extra data EXTRA.
If COMMENT is nil, pop up a LOGBUF buffer, emit MSG, and set the
action on close to ACTION. If COMMENT is a string and
@@ -557,7 +559,7 @@ for `vc-log-after-operation-hook'."
(set (make-local-variable 'vc-parent-buffer) parent)
(set (make-local-variable 'vc-parent-buffer-name)
(concat " from " (buffer-name vc-parent-buffer)))
- (vc-log-edit files)
+ (vc-log-edit files mode)
(make-local-variable 'vc-log-after-operation-hook)
(when after-hook
(setq vc-log-after-operation-hook after-hook))
@@ -587,12 +589,16 @@ the buffer contents as a comment."
(or (vc-dispatcher-browsing) (vc-buffer-sync)))
(unless vc-log-operation
(error "No log operation is pending"))
+
+ (log-view-process-buffer)
+
;; save the parameters held in buffer-local variables
(let ((logbuf (current-buffer))
(log-operation vc-log-operation)
(log-fileset vc-log-fileset)
(log-extra vc-log-extra)
(log-entry (buffer-string))
+ (extra-flags log-edit-extra-flags)
(after-hook vc-log-after-operation-hook)
(tmp-vc-parent-buffer vc-parent-buffer))
(pop-to-buffer vc-parent-buffer)
@@ -601,7 +607,9 @@ the buffer contents as a comment."
(funcall log-operation
log-fileset
log-extra
- log-entry))
+ log-entry
+ extra-flags
+ ))
;; Remove checkin window (after the checkin so that if that fails
;; we don't zap the log buffer and the typing therein).
;; -- IMO this should be replaced with quit-window
Index: log-edit.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/log-edit.el,v
retrieving revision 1.56
diff -u -3 -p -r1.56 log-edit.el
--- log-edit.el 2 Oct 2009 03:48:41 -0000 1.56
+++ log-edit.el 17 Jan 2010 09:22:24 -0000
@@ -185,6 +185,25 @@ 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-extra-flags nil
+ "List of extra flags to pass to the check in command.")
+(defvar log-edit-before-checkin-process nil
+ "Alist that contains instructions for processing the commit message before
check in.
+
+The format is: (REGEXP . INSTRUCTIONS).
+
+All lines matching REGEXP are removed.
+
+For example:
+
+(\"^#.*\" . nil)
+means: just remove all lines starting with #. This can be used
+to insert lines in the commit buffer that contain, for example, the
+list of files to be committed.
+
+(\"Author: \\(.*\\)\" . (list \"--author\" (match-string 1)))
+means: append (list \"--author\" (match-string 1)) to
+`log-edit-extra-flags'.")
(defvar log-edit-parent-buffer nil)
;;; Originally taken from VC-Log mode
@@ -315,9 +334,10 @@ automatically."
(2 font-lock-function-name-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].
@@ -338,7 +358,9 @@ uses the current buffer."
(when (and log-edit-setup-invert (not (eq setup 'force)))
(setq setup (not setup)))
(when setup (erase-buffer))
- (log-edit-mode)
+ (if mode
+ (funcall mode)
+ (log-edit-mode))
(set (make-local-variable 'log-edit-callback) callback)
(if (listp params)
(dolist (crt params)
@@ -707,6 +729,17 @@ Sort REGIONS front-to-back first."
(log-edit-changelog-insert-entries (car buffer-entry) (cdr buffer-entry))
(when (cdr buffer-entry) (newline)))))
+(defun log-view-process-buffer ()
+ (when log-edit-before-checkin-process
+ (dolist (crt log-edit-before-checkin-process)
+ ;; Remove all lines matching (car crt)
+ ;; Append to `log-edit-extra-flags' the results of (cdr crt).
+ (goto-char (point-min))
+ (while (re-search-forward (car crt) nil t)
+ (when (cdr crt)
+ (setq log-edit-extra-flags (append log-edit-extra-flags (eval (cdr
crt)))))
+ (replace-match "" nil t)))))
+
(provide 'log-edit)
;; arch-tag: 8089b39c-983b-4e83-93cd-ed0a64c7fdcc
Index: vc-bzr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-bzr.el,v
retrieving revision 1.94
diff -u -3 -p -r1.94 vc-bzr.el
--- vc-bzr.el 9 Dec 2009 06:04:12 -0000 1.94
+++ vc-bzr.el 17 Jan 2010 09:22:24 -0000
@@ -426,11 +445,11 @@ or a superior directory.")
"Unregister FILE from bzr."
(vc-bzr-command "remove" nil 0 file "--keep"))
-(defun vc-bzr-checkin (files rev comment)
+(defun vc-bzr-checkin (files rev comment &optional extra-args)
"Check FILE 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"))
- (vc-bzr-command "commit" nil 0 files "-m" comment))
+ (apply 'vc-bzr-command "commit" nil 0 files (append (list "-m" comment)
extra-args)))
(defun vc-bzr-find-revision (file rev buffer)
"Fetch revision REV of file FILE and put it into BUFFER."
@@ -520,6 +540,12 @@ REV non-nil gets an error."
(goto-char (point-min)))
found)))
+(define-derived-mode vc-bzr-log-edit-mode log-edit-mode "Bzr-Log-Edit"
+ (set (make-local-variable 'log-edit-extra-flags) nil)
+ (set (make-local-variable 'log-edit-before-checkin-process)
+ '(("^Author:[ \t]+\\(.*\\)[ \t]*$" . (list "--author" (match-string
1))))))
+
+
(defun vc-bzr-diff (files &optional rev1 rev2 buffer)
"VC bzr backend for diff."
;; `bzr diff' exits with code 1 if diff is non-empty.
@@ -722,7 +760,9 @@ stream. Standard error output is discar
(define-key map "\C-k" 'vc-bzr-shelve-delete-at-point)
;; (define-key map "=" 'vc-bzr-shelve-show-at-point)
;; (define-key map "\C-m" 'vc-bzr-shelve-show-at-point)
- (define-key map "A" 'vc-bzr-shelve-apply-at-point)
+ (define-key map "A" 'vc-bzr-shelve-apply-and-keep-at-point)
+ (define-key map "P" 'vc-bzr-shelve-apply-at-point)
+ (define-key map "S" 'vc-bzr-shelve-snapshot)
map))
(defvar vc-bzr-shelve-menu-map
@@ -731,8 +771,11 @@ stream. Standard error output is discar
'(menu-item "Delete shelf" vc-bzr-shelve-delete-at-point
:help "Delete the current shelf"))
(define-key map [ap]
- '(menu-item "Apply shelf" vc-bzr-shelve-apply-at-point
- :help "Apply the current shelf"))
+ '(menu-item "Apply and keep shelf" vc-bzr-shelve-apply-and-keep-at-point
+ :help "Apply the current shelf and keep it"))
+ (define-key map [po]
+ '(menu-item "Apply and remove shelf (pop)" vc-bzr-shelve-apply-at-point
+ :help "Apply the current shelf and remove it"))
;; (define-key map [sh]
;; '(menu-item "Show shelve" vc-bzr-shelve-show-at-point
;; :help "Show the contents of the current shelve"))
@@ -740,6 +783,9 @@ stream. Standard error output is discar
(defvar vc-bzr-extra-menu-map
(let ((map (make-sparse-keymap)))
+ (define-key map [bzr-sn]
+ '(menu-item "Shelve a snapshot" vc-bzr-shelve-snapshot
+ :help "Shelve the current state of the tree and keep the
current state"))
(define-key map [bzr-sh]
'(menu-item "Shelve..." vc-bzr-shelve
:help "Shelve changes"))
@@ -790,7 +836,7 @@ stream. Standard error output is discar
(propertize x
'face 'font-lock-variable-name-face
'mouse-face 'highlight
- 'help-echo "mouse-3: Show shelve menu\nA: Apply
shelf\nC-k: Delete shelf"
+ 'help-echo "mouse-3: Show shelve menu\nA: Apply and
keep shelf\nP: Apply and remove shelf (pop)\nS: Snapshot to a shelf\nC-k:
Delete shelf"
'keymap vc-bzr-shelve-map))
shelve "\n"))
(concat
@@ -820,11 +866,28 @@ stream. Standard error output is discar
;; (pop-to-buffer (current-buffer)))
(defun vc-bzr-shelve-apply (name)
- "Apply shelve NAME."
- (interactive "sApply shelf: ")
+ "Apply shelve NAME and remove it afterwards."
+ (interactive "sApply (and remove) shelf: ")
(vc-bzr-command "unshelve" "*vc-bzr-shelve*" 0 nil "--apply" name)
(vc-resynch-buffer (vc-bzr-root default-directory) t t))
+(defun vc-bzr-shelve-apply-and-keep (name)
+ "Apply shelve NAME and keep it afterwards."
+ (interactive "sApply (and keep) shelf: ")
+ (vc-bzr-command "unshelve" "*vc-bzr-shelve*" 0 nil "--apply" "--keep" name)
+ (vc-resynch-buffer (vc-bzr-root default-directory) t t))
+
+(defun vc-bzr-shelve-snapshot ()
+ "Create a stash with the current tree state."
+ (interactive)
+ (vc-bzr-command "shelve" nil 0 nil "--all" "-m"
+ (let ((ct (current-time)))
+ (concat
+ (format-time-string "Snapshot on %Y-%m-%d" ct)
+ (format-time-string " at %H:%M" ct))))
+ (vc-bzr-command "unshelve" "*vc-bzr-shelve*" 0 nil "--apply" "--keep")
+ (vc-resynch-buffer (vc-bzr-root default-directory) t t))
+
(defun vc-bzr-shelve-list ()
(with-temp-buffer
(vc-bzr-command "shelve" (current-buffer) 1 nil "--list" "-q")
@@ -857,6 +920,10 @@ stream. Standard error output is discar
(interactive)
(vc-bzr-shelve-apply (vc-bzr-shelve-get-at-point (point))))
+(defun vc-bzr-shelve-apply-and-keep-at-point ()
+ (interactive)
+ (vc-bzr-shelve-apply-and-keep (vc-bzr-shelve-get-at-point (point))))
+
(defun vc-bzr-shelve-menu (e)
(interactive "e")
(vc-dir-at-event e (popup-menu vc-bzr-shelve-menu-map e)))
- bzr --fixes [was Re: bug#881: patch for bug #881], (continued)
- bzr --fixes [was Re: bug#881: patch for bug #881], Glenn Morris, 2010/01/07
- Re: bzr --fixes [was Re: bug#881: patch for bug #881], Juanma Barranquero, 2010/01/07
- Re: bzr --fixes, Glenn Morris, 2010/01/07
- Re: bzr --fixes, Juanma Barranquero, 2010/01/07
- Re: bzr --fixes, Eli Zaretskii, 2010/01/08
- Re: bzr --fixes, Eli Zaretskii, 2010/01/08
- Committing other people's changes (was: bug#881: patch for bug #881), Reiner Steib, 2010/01/06
- Re: bug#881: patch for bug #881, Chong Yidong, 2010/01/16