Hi Vincent! Nice to see a new contributor for DVC! We can apply your patches if you are willing to sign papers for the inclusion in emacs.
> Hi, > > Please find below a patch that allows bzr to commit only selected > files in a diff or status buffer. > > First, feel free to comment on everything in this mail (including > subject line) and even on the process used (should I have used > another way to submit that patch ?). > > Now some comments on the why and how of this patch : > > * I add a buffer-local variable to dvc-log buffers to record the > source buffer which have created it. This is done in an ad-hoc > way copied/pasted from tla-edit-log. There may be better ways > (like encapsulations done in dvc-diff-edit-log). I would rather reuse dvc-partner-buffer instead of the new variable you introduced. > * I tried to insert the file list into the buffer itself as done > by dvc-log-insert-commit-file-list, but the format of the file > list seems a bit tied to xhg (Mercurial) and > xhg-dvc-files-to-commit run a command to obtain the file list > which address a different purpose than this patch. So I gave > up. I will implement that functionality for bzr in the next days. As soon as I find some time... > * I corrected some typos in doc strings which need review (the > corrections :). > > Vincent > > > * looking for [EMAIL PROTECTED] to compare with > * comparing to [EMAIL PROTECTED]: ..... done. > > > M lisp/bzr.el > M lisp/dvc-defs.el > M lisp/dvc-lisp.el > M lisp/dvc-log.el > M lisp/dvc-register.el > > > * modified files > > --- orig/lisp/bzr.el > +++ mod/lisp/bzr.el > @@ -192,7 +192,15 @@ > (let ((buffer (find-file-noselect (dvc-log-edit-file-name)))) > (save-buffer buffer) > (dvc-run-dvc-async > - 'bzr (list "commit" "--verbose" "--file" (dvc-log-edit-file-name)) > + 'bzr > + (append > + (list "commit" "--verbose" "--file" (dvc-log-edit-file-name)) > + ;; Get marked files to do a selected file commit. Nil > + ;; otherwise (which means commit all files). > + (when (buffer-live-p dvc-log-source-buffer) > + (with-current-buffer dvc-log-source-buffer > + dvc-buffer-marked-file-list) > + )) > :finished (dvc-capturing-lambda > (output error status arguments) > (dvc-show-error-buffer output 'commit) > > > --- orig/lisp/dvc-defs.el > +++ mod/lisp/dvc-defs.el > @@ -349,11 +349,15 @@ > :group 'dvc) > > (defvar dvc-buffer-marked-file-list nil > - "List of marked and not hidden files in the current buffer.") > + "List of marked and not hidden files in the current buffer. > + > +This variable is buffer-local.") > (defvar dvc-buffer-all-marked-file-list nil > "List of marked files, including hidden ones, in the current buffer. > > -`dvc-buffer-marked-file-list' is a subset of this one.") > +`dvc-buffer-marked-file-list' is a subset of this one. > + > +This variable is buffer-local") > > ;; > ;; Executable location > > > --- orig/lisp/dvc-lisp.el > +++ mod/lisp/dvc-lisp.el > @@ -67,14 +67,15 @@ > Values to be captured should be surrounded by (capture ...). > For example: > > - (let* ((y 'lexical-y) > + (let* ((x 'lexical-x) > + (y 'lexical-y) > (l (dvc-capturing-lambda (arg) > (list x (capture y) arg)))) > (let ((y 'dynamic-y) > (x 'dynamic-x)) > - (funcall l 'dyn-arg))) > + (funcall l 'arg))) > > - => (dynamic-x lexical-y) > + => (dynamic-x lexical-y 'arg) > " > (let ((captured-values '())) > (let ((body (dvc-capturing-lambda-helper body))) I don't know that function in detail. So I have no idea, if your changes are correct. Comments from someone else? > --- orig/lisp/dvc-log.el > +++ mod/lisp/dvc-log.el > @@ -48,6 +48,12 @@ > > (defvar dvc-log-edit-flush-prefix "## ") > > +(defvar dvc-log-source-buffer nil > + "Buffer from which the edit-log command was called. > +Used to obtain the files to commit. > + > +This variable is buffer-local.") > + > ;; > -------------------------------------------------------------------------------- > ;; Menus > ;; > -------------------------------------------------------------------------------- > @@ -63,6 +69,7 @@ > (dvc-install-buffer-menu) > (set (make-local-variable 'font-lock-defaults) > '(dvc-log-edit-font-lock-keywords t)) > + (make-local-variable 'dvc-log-source-buffer) > (setq fill-column 73) > (run-hooks 'dvc-log-edit-mode-hook)) > > @@ -86,18 +93,31 @@ > > ;;;###autoload > (defun dvc-dvc-log-edit () > - (interactive) > + "Edit the log file before a commit. > + > +If invoked from a buffer containing marked files, only those > +files will be taken into account when you will commit with > +\<dvc-log-edit-mode-map>\[dvc-log-edit-done] (dvc-log-edit-done)." > + (interactive "P") > (setq dvc-pre-commit-window-configuration > - (current-window-configuration)) > + (current-window-configuration)) > (dvc-switch-to-buffer (dvc-get-buffer-create (dvc-current-active-dvc) > 'log-edit)) > (let ((buffer-name (buffer-name)) > - (file-name (dvc-log-edit-file-name))) > + (file-name (dvc-log-edit-file-name))) > (set-visited-file-name file-name t t) > (when (and (= (point-min) (point-max)) (file-readable-p file-name)) > (insert-file-contents file-name) > (set-buffer-modified-p nil)) > (rename-buffer buffer-name)) > - (dvc-log-edit-mode)) > + (dvc-log-edit-mode) > + ;; Get source buffer from a presumed origin (first the diff > + ;; buffer from which the command was invoked (presumably), then > + ;; from the status buffer the command was invoked > + ;; (presumably). It may be better to explicitly call with > + ;; source-buffer as a param from these buffers... > + (setq dvc-log-source-buffer > + (or (dvc-get-buffer (dvc-current-active-dvc) 'diff) > + (dvc-get-buffer (dvc-current-active-dvc) 'status)))) Your comment seems valid. I would use (setq dvc-partner-buffer (current-buffer)) One comment about the indendation: Please don't use tabs! > (defun dvc-log-edit-abort () > "Abort the current log edit." > > > --- orig/lisp/dvc-register.el > +++ mod/lisp/dvc-register.el > @@ -60,7 +60,7 @@ > "Return the function for DVC backend concatenated with POSTFIX. > > To be used with `apply' or `funcall'. If NODEFAULT is nil and no > -function is available for this backend, use dvc-<prefix> > +function is available for this backend, use dvc-<postfix> > instead." > (let ((res (dvc-intern-symbol-name dvc postfix))) > (if (or nodefault (fboundp res)) res o.k. Stefan.
