From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Subject: vc-update for bzr etc.
Date: Sun, 21 Nov 2010 10:43:22 -0500 [thread overview]
Message-ID: <87y68m7kdh.fsf@stupidchicken.com> (raw)
[I sent this yesterday, but the message didn't show up; resending.]
From vc.el:
;; - vc-update/vc-merge should deal with VC systems that don't
;; update/merge on a file basis, but on a whole repository basis.
;; vc-update and vc-merge assume the arguments are always files,
;; they don't deal with directories. Make sure the *vc-dir* buffer
;; is updated after these operations.
;; At least bzr, git and hg should benefit from this.
Here's a quick stab at this. If a backend defines vc-BACK-merge-news
(svn and cvs), vc-update tries a per-file update unless a prefix
argument is supplied. Otherwise, it tries vc-BACK-update-repository, a
new VC backend function. Included is an implementation for bzr,
vc-bzr-update-repository, which runs asynchronously and outputs to a
*vc-update* buffer (currently Fundamental mode, but can be improved).
Thoughts? Any subtleties here that I'm missing?
=== modified file 'lisp/vc/vc-bzr.el'
*** lisp/vc/vc-bzr.el 2010-11-09 20:07:10 +0000
--- lisp/vc/vc-bzr.el 2010-11-21 00:55:37 +0000
***************
*** 236,241 ****
--- 236,253 ----
(when rootdir
(file-relative-name filename* rootdir))))
+ (defun vc-bzr-update-repository ()
+ "Update the current Bzr repository."
+ (let ((buf (get-buffer-create "*vc-update*"))
+ (dir default-directory))
+ (display-buffer buf)
+ (with-current-buffer buf
+ (goto-char (point-max))
+ (unless (eq (point) (point-min))
+ (insert "\f\n"))
+ (insert "Running \"bzr update\" for \"" dir "\"...\n")
+ (vc-bzr-command "update" t 'async nil))))
+
(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-21 01:25:39 +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,2321 ----
(define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1")
;;;###autoload
! (defun vc-update (&optional arg)
! "Update the current fileset or repository.
! If the version control system supports only repository-wide
! updates, update the repository.
!
! Otherwise, if prefix ARG is omitted or nil, 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. If ARG is non-nil, update the entire
! repository instead."
! (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 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)))))
! ;; Otherwise, try updating the entire repository.
! ((or arg (vc-find-backend-function backend 'update-repository))
! (vc-call-backend backend 'update-repository))
! ;; 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 reply other threads:[~2010-11-21 15:43 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-21 15:43 Chong Yidong [this message]
2010-11-21 17:00 ` vc-update for bzr etc 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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y68m7kdh.fsf@stupidchicken.com \
--to=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).