From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: vc-update for bzr etc. Date: Sun, 21 Nov 2010 10:43:22 -0500 Message-ID: <87y68m7kdh.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1290354240 19378 80.91.229.12 (21 Nov 2010 15:44:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 21 Nov 2010 15:44:00 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 21 16:43:54 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.69) (envelope-from ) id 1PKC53-00037P-P7 for ged-emacs-devel@m.gmane.org; Sun, 21 Nov 2010 16:43:54 +0100 Original-Received: from localhost ([127.0.0.1]:43905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKC53-0001aO-1n for ged-emacs-devel@m.gmane.org; Sun, 21 Nov 2010 10:43:53 -0500 Original-Received: from [140.186.70.92] (port=51599 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKC4b-0001Pw-Fk for emacs-devel@gnu.org; Sun, 21 Nov 2010 10:43:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKC4a-0008Gc-8t for emacs-devel@gnu.org; Sun, 21 Nov 2010 10:43:25 -0500 Original-Received: from pantheon-po16.its.yale.edu ([130.132.50.72]:44920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKC4a-0008GV-5r for emacs-devel@gnu.org; Sun, 21 Nov 2010 10:43:24 -0500 Original-Received: from furball (dhcp128036226124.central.yale.edu [128.36.226.124]) (authenticated bits=0) by pantheon-po16.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id oALFhMfB015740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 21 Nov 2010 10:43:23 -0500 Original-Received: by furball (Postfix, from userid 1000) id F1AEB160AC8; Sun, 21 Nov 2010 10:43:22 -0500 (EST) X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 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:132957 Archived-At: [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 " \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.