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: Re: vc-update for bzr etc. Date: Sun, 21 Nov 2010 23:35:35 -0500 Message-ID: <87tyjauga0.fsf@stupidchicken.com> References: <87y68m7kdh.fsf@stupidchicken.com> <87lj4mk2e5.fsf@stupidchicken.com> <87mxp2bd12.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1290400552 3836 80.91.229.12 (22 Nov 2010 04:35:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Nov 2010 04:35:52 +0000 (UTC) Cc: Dan Nicolaescu , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 22 05:35:45 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 1PKO7z-0007JG-7j for ged-emacs-devel@m.gmane.org; Mon, 22 Nov 2010 05:35:43 +0100 Original-Received: from localhost ([127.0.0.1]:56169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKO7y-0001bA-LC for ged-emacs-devel@m.gmane.org; Sun, 21 Nov 2010 23:35:42 -0500 Original-Received: from [140.186.70.92] (port=49535 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKO7t-0001b5-Io for emacs-devel@gnu.org; Sun, 21 Nov 2010 23:35:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKO7s-0007iF-1V for emacs-devel@gnu.org; Sun, 21 Nov 2010 23:35:37 -0500 Original-Received: from pantheon-po41.its.yale.edu ([130.132.50.98]:39188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKO7r-0007iB-UZ; Sun, 21 Nov 2010 23:35:36 -0500 Original-Received: from furball (dhcp128036014014.central.yale.edu [128.36.14.14]) (authenticated bits=0) by pantheon-po41.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id oAM4ZYbC013279 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 21 Nov 2010 23:35:34 -0500 Original-Received: by furball (Postfix, from userid 1000) id 417A4160AD0; Sun, 21 Nov 2010 23:35:35 -0500 (EST) In-Reply-To: (Stefan Monnier's message of "Sun, 21 Nov 2010 21:04:28 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) 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:132991 Archived-At: Stefan Monnier 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 " \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.