From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: vc-svn.el donation - attn Stephan Monnier Date: Fri, 04 Jul 2003 18:23:39 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200307042223.h64MNdot025052@rum.cs.yale.edu> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1057357550 12205 80.91.224.249 (4 Jul 2003 22:25:50 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 4 Jul 2003 22:25:50 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Jul 05 00:25:47 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19YYzz-0003Ag-00 for ; Sat, 05 Jul 2003 00:25:47 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19YZ8a-000582-00 for ; Sat, 05 Jul 2003 00:34:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19YYz0-0006AS-HI for emacs-devel@quimby.gnus.org; Fri, 04 Jul 2003 18:24:46 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19YYyL-00053c-1e for emacs-devel@gnu.org; Fri, 04 Jul 2003 18:24:05 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19YYy8-0004Gz-IJ for emacs-devel@gnu.org; Fri, 04 Jul 2003 18:23:56 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19YYxy-0003x8-RI for emacs-devel@gnu.org; Fri, 04 Jul 2003 18:23:42 -0400 Original-Received: from rum.cs.yale.edu (localhost [127.0.0.1]) by rum.cs.yale.edu (8.12.8/8.12.8) with ESMTP id h64MNeHl025054; Fri, 4 Jul 2003 18:23:40 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.12.8/8.12.8/Submit) id h64MNdot025052; Fri, 4 Jul 2003 18:23:39 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Jeff Bowman Original-cc: Karl Fogel X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:15381 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:15381 > (defun vc-svn-checkout-model (file) > "return checkout model for FILE" > ;; Subversion files are always editable, so if FILE is registered, > ;; return 'implit otherwise nil > (cond ((vc-svn-registered file) 'implicit) > (t nil))) There's no need to verify that FILE is indeed under Subversion control. > (defun vc-svn-mode-line-string (file) > "Return string for placement into the modeline for FILE. > Compared to the default implementation, this function handles the > special case of a SVN file that is added but not yet committed." > ;; cut and paste directly from vc-cvs.el, changed CVS to SVN > ;; everywhere > (let ((state (vc-state file)) > (rev (if (stringp (vc-workfile-version file)) > (vc-workfile-version file) > (int-to-string (vc-workfile-version file))))) > (cond ((string= rev "0") > ;; A file that is added but not yet committed. > "SVN @@") > ((or (eq state 'up-to-date) > (eq state 'needs-patch)) > (concat "SVN-" rev)) > ((stringp state) > (concat "SVN:" state ":" rev)) > (t > ;; Not just for the 'edited state, but also a fallback > ;; for all other states. Think about different symbols > ;; for 'needs-patch and 'needs-merge. > (concat "SVN:" rev))))) Emacs' vc-svn.el does not have this function because the default behavior already provides all the relevant info. > (defun vc-svn-register (file &optional rev comment) > "register a FILE with subversion with COMMENT if appropriate" > ;; rev is always ignored (svn add does not support a revision for > ;; this operation) > (if (not (vc-svn-registered file)) > (with-temp-buffer > (vc-do-command t nil "svn" file "add" > (and comment (string-match "[^\t\n ]" comment) > (concat "-m" comment)))))) `svn add' does not accept the -m argument. > (list "copy" "-r" rev url (file-name-nondirectory destfile))) I don't think you want to do `copy' but `cat' instead. > (defun vc-svn-print-log (file) > "get change log associated with FILE" > ;; do svn log twice to get the youngest revision in order to reverse > ;; the output and put the most current log information at the bottom > ;; of the output, which is visibile first. The log will be in > ;; ascending order from top to bottom > (let ((beg) > (end) > (str) > (rev)) > (with-temp-buffer > (vc-do-command t nil "svn" file "log") > (goto-char (point-max)) > (re-search-backward "^rev") > (beginning-of-line) > (setq beg (point)) > (end-of-line) > (setq end (point)) > (setq str (buffer-substring-no-properties beg end)) > (setq rev (string-to-int (car (cdr (split-string str)))))) > (vc-do-command nil nil "svn" file "log" "-r" > (concat (int-to-string rev) ":HEAD")))) Could explain why you call `svn log' twice? I don't understand the comment. > (defun vc-svn-wash-log (file) > ;; nothing to do, leave empty to override default implementation > ) Did the default implementation create problems for you ? > (when (integerp rev1) > (setq rev1 (int-to-string rev1))) > (when (integerp rev2) > (setq rev2 (int-to-string rev2))) Are the revs ever integers ? > (defun vc-svn-diff-tree (dir &optional rev1 rev2) > "Get the difference report using Subversion between two versions of DIR" > ;; same as vc-svn-diff only pass DIR instead of FILE > ;; need to make sure dir has ending / so that > ;; vc-svn-workfile-version (used in vc-svn-diff) will return the > ;; approprate thing > (if (string= (file-name-directory dir) dir) > (vc-svn-diff dir rev1 rev2) > (unless (string= (file-name-directory dir) dir) > (setq dir (concat dir "/"))) > (vc-svn-diff dir rev1 rev2))) That's much better than what was in Emacs' code. I've changed it to use something similar (tho simpler). > (defun vc-svn-create-snapshot (dir name branchp) > "create a branch in Subversion called NAME" > ;; branchp is irrelevant, branches are just copies in subversion > > ;; creates a copy of the file from repository based on the URL found > ;; from (essentially) `svn info DIR | grep Url:` Note that > ;; uncommitted work in this directory won't be in the repository > ;; when the copy is made. > (unless name > (vc-do-command t nil "svn" dir "copy")) > (when name It's better to use (if name ) then using first `unless name' and then `when name'. > (let ((beg 0) > (end 0) > (url "") > (args)) > (with-temp-buffer > (vc-do-command "svn" dir "info") > (goto-char (point-min)) > (re-search-forward "Url:" nil t) > (beginning-of-line) > (setq beg (point)) > (end-of-line) > (setq end (point)) > (setq url > (cadr (split-string (buffer-substring-no-properties beg end)))) I'd recommend you use something like (and (re-search-forward "^URL: \\(.*\\)" nil t) (match-string 1))) which is shorter, faster, simpler, easier, better. > (when (integerp rev) > (setq rev (int-to-string rev))) > (setq args (list "copy" "-r" rev url > (file-name-nondirectory destfile))) > (with-temp-buffer > (apply 'call-process "svn" nil 0 nil args)))))) Emacs' code does not have an implementation of vc-svn-create-snapshot but the above code doesn't work for me. `rev' and `destfile' are not bound, `name' is unused (other than being checked for nil which is unnecessary). I've installed a simple implementation of create-snapshot which just assumes that NAME is a URL. > (defun vc-svn-retrieve-snapshot (dir name update) > "moves working directory DIR to branch NAME and updates files if > UPDATE is non-nil" > (with-temp-buffer > (cd dir) > (vc-do-command t nil "svn" info dir) I think you meant (vc-do-command t nil "svn" dir "info") Stefan