From: "Stefan Monnier" <monnier+gnu/emacs@cs.yale.edu>
Cc: emacs-devel@gnu.org
Subject: Re: vc-svn.el donation - attn Stephan Monnier
Date: Fri, 04 Jul 2003 18:23:39 -0400 [thread overview]
Message-ID: <200307042223.h64MNdot025052@rum.cs.yale.edu> (raw)
In-Reply-To: lz4r25ovwl.fsf@zarquon.dvns.com
> (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 <bla1> <bla2>) 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
prev parent reply other threads:[~2003-07-04 22:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-02 14:17 vc-svn.el donation - attn Stephan Monnier Jeff Bowman
2003-07-03 15:48 ` Richard Stallman
2003-07-03 17:41 ` Karl Fogel
2003-07-03 22:43 ` Jeff Bowman
2003-07-03 22:58 ` Andre Spiegel
2003-07-04 0:47 ` Stefan Monnier
2003-07-04 22:23 ` Stefan Monnier [this message]
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=200307042223.h64MNdot025052@rum.cs.yale.edu \
--to=monnier+gnu/emacs@cs.yale.edu \
--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).