From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: bug#881: patch for bug #881 Date: Sun, 17 Jan 2010 01:38:26 -0800 (PST) Message-ID: <201001170938.o0H9cQZa013402@godzilla.ics.uci.edu> References: <87wrzwp5gd.fsf@stupidchicken.com> <87y6jxk9cw.fsf@stupidchicken.com> <87r5ppfzsu.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1263721242 13890 80.91.229.12 (17 Jan 2010 09:40:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jan 2010 09:40:42 +0000 (UTC) Cc: Juanma Barranquero , Stefan Monnier , Emacs developers To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 17 10:40:33 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NWRcW-00047I-TF for ged-emacs-devel@m.gmane.org; Sun, 17 Jan 2010 10:40:33 +0100 Original-Received: from localhost ([127.0.0.1]:60165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWRcX-0003j1-Bg for ged-emacs-devel@m.gmane.org; Sun, 17 Jan 2010 04:40:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWRcC-0003dx-IT for emacs-devel@gnu.org; Sun, 17 Jan 2010 04:40:12 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWRc7-0003dZ-OS for emacs-devel@gnu.org; Sun, 17 Jan 2010 04:40:11 -0500 Original-Received: from [199.232.76.173] (port=44178 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWRc7-0003dW-CL for emacs-devel@gnu.org; Sun, 17 Jan 2010 04:40:07 -0500 Original-Received: from paul-mcgann-v0.ics.uci.edu ([128.195.1.147]:49268) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NWRc6-0003Lq-Po for emacs-devel@gnu.org; Sun, 17 Jan 2010 04:40:07 -0500 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by paul-mcgann-v0.ics.uci.edu (8.13.8/8.13.8) with ESMTP id o0H9cRQQ023071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 17 Jan 2010 01:38:27 -0800 Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id o0H9cQZa013402; Sun, 17 Jan 2010 01:38:26 -0800 (PST) In-Reply-To: <87r5ppfzsu.fsf@stupidchicken.com> (Chong Yidong's message of "Sat, 16 Jan 2010 17:30:25 -0500") Original-Lines: 365 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: o0H9cRQQ023071 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.263, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FM_MULTI_ODD2 1.10, TW_BZ 0.08) X-ICS-MailScanner-From: dann@godzilla.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:120139 Archived-At: Chong Yidong writes: > Juanma Barranquero writes: > > > On Sat, Jan 16, 2010 at 22:50, Chong Yidong 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 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. -\\The buffer will be put in `log-edit-mode'. +\\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)))