From: Chong Yidong <cyd@stupidchicken.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Dan Nicolaescu <dann@gnu.org>, emacs-devel@gnu.org
Subject: Re: vc-update for bzr etc.
Date: Sun, 21 Nov 2010 23:35:35 -0500 [thread overview]
Message-ID: <87tyjauga0.fsf@stupidchicken.com> (raw)
In-Reply-To: <jwv7hg6unct.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 21 Nov 2010 21:04:28 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> VC tries to present a uniform UI and that is good, but trying to impose
> a uniform semantics to all commands is asking too much. So I think it's
> perfectly OK for vc-pull/update to do "bzr pull" for Bzr and
> "git pull" for Git, even if they don't do exactly the same thing.
Fair enough. Here's an updated patch. I renamed the new operation
vc-BACKEND-update-branch, and vc-update uses it preferentially if it
exists (falling back on the old merge-news operation if not). For
vc-bzr-update-branch, it calls "bzr update" for bound branchs and
"bzr pull" for other branches. Passing a prefix arg to vc-update causes
it to prompt for arguments to bzr.
WDYT?
*** lisp/vc/vc-bzr.el 2010-11-09 20:07:10 +0000
--- lisp/vc/vc-bzr.el 2010-11-22 04:29:26 +0000
***************
*** 236,241 ****
--- 236,280 ----
(when rootdir
(file-relative-name filename* rootdir))))
+ (defun vc-bzr-update-branch (prompt)
+ "Update the current Bzr branch.
+ If it is a bound branch, run \"bzr update\".
+ Otherwise, run \"bzr pull\"."
+ (let* ((rootdir (vc-bzr-root default-directory))
+ (bound ;; Whether the branch is bound.
+ (with-temp-buffer
+ (insert-file-contents
+ (expand-file-name ".bzr/branch/branch.conf" rootdir))
+ (goto-char (point-min))
+ (re-search-forward "bound *= *True" nil t)))
+ (command (if bound "update" "pull"))
+ (vc-bzr-program vc-bzr-program)
+ (args nil)
+ buf)
+ ;; If PROMPT is given, ask the user for the exact command.
+ (when prompt
+ (setq args
+ (split-string
+ (read-shell-command
+ "Run bzr (like this): "
+ (concat vc-bzr-program " " command))
+ " " t))
+ (if (< (length args) 2)
+ (error "Invalid bzr command")
+ (setq vc-bzr-program (car args)
+ command (nth 1 args)
+ args (cddr args))))
+ ;; Run asynchronously, ouputting to *vc-update* buffer.
+ (setq buf (get-buffer-create "*vc-update*"))
+ (with-current-buffer buf
+ (goto-char (point-max))
+ (unless (eq (point) (point-min))
+ (insert "\f\n"))
+ (insert (format "Running \"%s %s\" for \"%s\"...\n"
+ vc-bzr-program command rootdir))
+ (vc-bzr-command command t 'async nil args))
+ (display-buffer buf)))
+
(defun vc-bzr-status (file)
"Return FILE status according to Bzr.
Return value is a cons (STATUS . WARNING), where WARNING is a
=== modified file 'lisp/vc/vc.el'
*** lisp/vc/vc.el 2010-11-12 13:44:46 +0000
--- lisp/vc/vc.el 2010-11-22 03:56:27 +0000
***************
*** 2274,2308 ****
(define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1")
;;;###autoload
! (defun vc-update ()
! "Update the current fileset's files to their tip revisions.
! For each one that contains no changes, and is not locked, then this simply
! replaces the work file with the latest revision on its branch. If the file
! contains changes, and the backend supports merging news, then any recent
! changes from the current branch are merged into the working file."
! (interactive)
! (let* ((vc-fileset (vc-deduce-fileset))
(backend (car vc-fileset))
(files (cadr vc-fileset)))
! (save-some-buffers ; save buffers visiting files
! nil (lambda ()
! (and (buffer-modified-p)
! (let ((file (buffer-file-name)))
! (and file (member file files))))))
! (dolist (file files)
! (if (vc-up-to-date-p file)
! (vc-checkout file nil t)
! (if (eq (vc-checkout-model backend (list file)) 'locking)
! (if (eq (vc-state file) 'edited)
! (error "%s"
! (substitute-command-keys
! "File is locked--type \\[vc-revert] to discard changes"))
! (error "Unexpected file state (%s) -- type %s"
! (vc-state file)
! (substitute-command-keys
! "\\[vc-next-action] to correct")))
! (vc-maybe-resolve-conflicts
! file (vc-call-backend backend 'merge-news file)))))))
(defun vc-version-backup-file (file &optional rev)
"Return name of backup file for revision REV of FILE.
--- 2274,2320 ----
(define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1")
;;;###autoload
! (defun vc-update (&optional arg)
! "Update the current fileset or branch.
! On distributed version control systems, this updates the branch.
! With prefix ARG, prompt for an argument list for the command.
!
! On all other version control systems, update the files in the
! current fileset to their tip revisions. For each file that
! contains no changes, and is not locked, then this simply replaces
! the work file with the latest revision on its branch. If the
! file contains changes, and the backend supports merging news,
! then any recent changes from the current branch are merged into
! the working file."
! (interactive "P")
! (when buffer-file-name (vc-buffer-sync t))
! (let* ((vc-fileset (vc-deduce-fileset t))
(backend (car vc-fileset))
(files (cadr vc-fileset)))
! (cond
! ;; If an update-branch operation is defined, use it.
! ((or arg (vc-find-backend-function backend 'update-branch))
! (vc-call-backend backend 'update-branch arg))
! ;; If VCS has `merge-news' functionality (CVS and SVN), use it.
! ((and (vc-find-backend-function backend 'merge-news)
! (not arg))
! (save-some-buffers ; save buffers visiting files
! nil (lambda ()
! (and (buffer-modified-p)
! (let ((file (buffer-file-name)))
! (and file (member file files))))))
! (dolist (file files)
! (if (vc-up-to-date-p file)
! (vc-checkout file nil t)
! (vc-maybe-resolve-conflicts
! file (vc-call-backend backend 'merge-news file)))))
! ;; For a locking VCS, check out each file.
! ((eq (vc-checkout-model backend files) 'locking)
! (dolist (file files)
! (if (vc-up-to-date-p file)
! (vc-checkout file nil t))))
! (t
! (error "VC update is unsupported for `%s'" backend)))))
(defun vc-version-backup-file (file &optional rev)
"Return name of backup file for revision REV of FILE.
next prev parent reply other threads:[~2010-11-22 4:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-21 15:43 vc-update for bzr etc Chong Yidong
2010-11-21 17:00 ` Andreas Schwab
2010-11-21 17:09 ` Dan Nicolaescu
2010-11-21 17:33 ` Chong Yidong
2010-11-21 20:20 ` Stefan Monnier
2010-11-21 21:08 ` Chong Yidong
2010-11-22 2:04 ` Stefan Monnier
2010-11-22 4:31 ` Stephen J. Turnbull
2010-11-22 8:40 ` Thien-Thi Nguyen
2010-11-22 11:04 ` Stephen J. Turnbull
2010-11-22 14:39 ` Stefan Monnier
2010-11-22 17:29 ` Chong Yidong
2010-11-23 15:37 ` Stephen J. Turnbull
2010-11-23 16:20 ` Stefan Monnier
2010-11-22 4:35 ` Chong Yidong [this message]
2010-11-22 6:52 ` Dan Nicolaescu
2010-11-22 14:42 ` Stefan Monnier
2010-11-22 10:54 ` Eli Zaretskii
2010-11-22 14:41 ` Stefan Monnier
2010-11-23 1:40 ` Chong Yidong
2010-11-23 14:27 ` Stefan Monnier
2010-11-23 16:08 ` Chong Yidong
2010-11-23 17:03 ` Dan Nicolaescu
2010-11-23 17:02 ` Dan Nicolaescu
2010-11-23 19:29 ` Chong Yidong
2010-11-23 22:05 ` Stefan Monnier
2010-11-23 22:34 ` Dan Nicolaescu
2010-11-24 17:19 ` Chong Yidong
2010-11-22 16:57 ` Chong Yidong
2010-11-22 17:59 ` Eli Zaretskii
2010-11-21 19:03 ` Stefan Monnier
2010-11-21 19:34 ` Chong Yidong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tyjauga0.fsf@stupidchicken.com \
--to=cyd@stupidchicken.com \
--cc=dann@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.