* vc-svn.el donation - attn Stephan Monnier
@ 2003-07-02 14:17 Jeff Bowman
2003-07-03 15:48 ` Richard Stallman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jeff Bowman @ 2003-07-02 14:17 UTC (permalink / raw
I am not a member of this mailing list. I posted a version of
vc-svn.el I wrote to include Subversion support in emacs. My intention
was to donate it to GNU. I am happy to sign any paperwork to assign
copyrights, etc as needed. I was advised there was already a version
of vc-svn.el in CVS and that I should contact Stephan Monnier about
it, however I don't have his email address. If someone could put me in
touch with him (so he doesn't think this is some spammer filling his
inbox :) better yet if Mr. Monnier would contact me, I'd appreciate
it. I was also advised I should post this to emacs-devel where
maintainers hang out so they can evaluate the code for possible
inclusion.
I am including my version of vc-svn.el with this email, hopefully it
will help in someway with the current vc-svn.el development. Also, I'm
interested in helping in anyway with the development of this
module. My company is shortly going to convert to using Subversion, so
this module is important to me. Please let me know if there is
anything further I can contribute.
TIA
Jeff Bowman
--
__
/ / (_)__ __ ____ __
/ /__/ / _ \/ // /\ \/ / . . . t h e c h o i c e o f a
/____/_/_//_/\_,_/ /_/\_\ G N U g e n e r a t i o n . . .
;;;; vc-svn.el starts here
;;; vc-svn.el --- non-resident support for Subversion version-control
;; Copyright (C) 2003 Free Software Foundation, Inc.
;; Author: Jeff Bowman
;; Maintainer: Jeff Bowman <wolfjb@bigfoot.com>
;; Keywords: tools
;; vc-svn is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; vc-svn is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides Emacs VC with support for Subversion version control
;; system. Since Subversion is supposed to replace CVS, I used vc-cvs
;; as a reference while writing this code.
(eval-when-compile
(require 'vc))
(defun vc-svn-registered (file)
"check if FILE is registered with subversion"
(let ((dirname (or (file-name-directory file) ""))
(basename (file-name-nondirectory file))
(case-fold-search nil))
(if (file-readable-p (expand-file-name ".svn/entries" dirname))
(with-temp-buffer
(vc-insert-file (expand-file-name ".svn/entries" dirname))
(goto-char (point-min))
(cond
((and (re-search-forward (regexp-quote basename) nil t)
(progn
(beginning-of-line)
(re-search-forward "name" (line-end-position) t)))
t)
(t nil)))
nil)))
(defun vc-svn-state (file)
"report state of FILE"
(let ((case-fold-search nil)
(state "")
(end))
(with-temp-buffer
(cd (file-name-directory file))
(vc-do-command t nil "svn" file "status" "-u")
(goto-char (point-min))
(cond ((re-search-forward (file-name-nondirectory file) nil t)
(beginning-of-line)
(setq end (match-beginning 0))
(cond ((re-search-forward "^M[[:blank:]A-z0-9]*\\*" end t)
'needs-merge) ;modified locally and on the server
((re-search-forward "^M" end t)
'edited) ;modified locally
((re-search-forward "\*" end t)
'needs-patch) ;modified on the server
((re-search-forward "^[[:blank:]]$" end t)
'up-to-date))) ;not modified anywhere
(t (with-temp-buffer
(vc-do-command t nil "svn" file "status")
(cond
((re-search-forward "^A" nil t)
'locally-added) ;added, but not committed
(t 'edited))))))))
(defun vc-svn-state-heuristic (file)
"Subversion state heuristic"
;; this came from vc-cvs
;; If the file has not changed since checkout, consider it `up-to-date'.
;; Otherwise consider it `edited'.
(let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
(lastmod (nth 5 (file-attributes file))))
(if (equal checkout-time lastmod)
'up-to-date
'edited)))
(defun vc-svn-workfile-version (file)
"get the verion number of the FILE from subversion"
(let ((str "")
(beg 0)
(end 0)
(case-fold-search nil))
(cd (file-name-directory file))
(when (vc-svn-registered file)
(with-temp-buffer
(vc-do-command t nil "svn" file "info")
(goto-char (point-min))
(when (re-search-forward "Revision:" nil t)
(beginning-of-line)
(setq beg (point))
(end-of-line)
(setq end (point))
(setq str (buffer-substring beg end))
(int-to-string (string-to-int (cadr (split-string str ":")))))))))
(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)))
(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)))))
(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))))))
(defun vc-svn-checkin (file rev comment)
"checkin a file by using commit."
;; I'm depending on vc to Do The Right Thing if this fails, which is
;; probably bad. I should probably do something extra here, but I'm
;; not sure what based on my experience with the code. I could use
;; some help from a vc expert type.
;; rev is always ignored.
(vc-do-command t nil "svn" file "commit"
(and comment (string-match "[^\t\n ]" comment)
(concat "-m" comment))))
(defun vc-svn-checkout (file &optional editable rev destfile)
"checkout a verion REV of FILE"
;; all files are editable when checked out, editable will be unused.
;; if DESTFILE is provided, use svn copy instead of svn update since
;; update can't checkout a file to a different name but copy can
(unless destfile
(with-temp-buffer
(get-file-buffer file)
(if (and rev (integerp rev))
(setq rev (int-to-string rev)))
(cond
((stringp rev)
(vc-do-command t nil "svn" file "update" "-r" rev))
(t
(vc-do-command t nil "svn" file "update")))))
(when destfile
(let ((url "")
(beg 0)
(end 0)
(dir (file-name-directory file))
(args "")
(status)
(case-fold-search nil))
(with-temp-buffer
(vc-do-command t nil "svn" file "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 beg end)))))
(when (integerp rev)
(setq rev (int-to-string rev)))
(setq args
(list "copy" "-r" rev url (file-name-nondirectory destfile)))
(setq args (delq nil args))
(with-temp-buffer
(setq status (apply 'call-process "svn" nil 0 nil args))))))
(defun vc-svn-revert (file &optional contents-done)
"revert changes to FILE"
;; svn revert FILE
(cd (file-name-directory file))
(vc-do-command t nil "svn" file "revert"))
(defun vc-svn-merge (file rev1 rev2)
"merge two revisions of FILE"
;; svn merge -r rev1:rev2 FILE
(when (integerp rev1)
(setq rev1 (int-to-string rev1)))
(when (integerp rev2)
(setq rev2 (int-to-string rev2)))
(cd (file-name-directory file))
(vc-do-command t nil "svn" file "merge" "-r" rev1 ":" rev2))
(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"))))
(defun vc-svn-wash-log (file)
;; nothing to do, leave empty to override default implementation
)
(defun vc-svn-diff (file &optional rev1 rev2)
"Get a difference report using Subversion between two versions of FILE"
(if (string= (vc-svn-workfile-version file) "0")
;; This is added but not yet committed
(if (or rev1 rev2)
(error "no revisions of %s exist" file)
(apply (vc-do-command "*vc-diff*" nil "svn" file "diff" "/dev/null"))))
(when (integerp rev1)
(setq rev1 (int-to-string rev1)))
(when (integerp rev2)
(setq rev2 (int-to-string rev2)))
(let ((revs ""))
(cd (file-name-directory file))
(cond
((and (not rev1) (not rev2)) ; rev1 and rev2 are nil so
; check against youngest
(vc-do-command "*vc-diff*" nil "svn" file "diff"))
((or (not rev1) (not rev2)) ; rev1 or rev2 is nil check
; against BASE
(when (and (not rev2) (> (length rev1) 0))
(setq revs (concat rev1 ":BASE")))
(when (and (not rev1) (> (length rev2) 0))
(setq revs (concat "BASE:" rev2)))
(vc-do-command "*vc-diff*" nil "svn" file "diff" "-r" revs))
((and rev1 rev2) ; both rev1 and rev2 are
; provided, use them
(vc-do-command "*vc-diff*" nil "svn" file "diff" "-r"
(concat rev1 ":" rev2))))))
(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)))
(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
(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))))
(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))))))
(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)
(let ((case-fold-search nil)
(beg)
(end)
(url))
(re-search-forward "Url:")
(beginning-of-line)
(setq beg (point))
(end-of-line)
(setq end (point))
;; Url: file:///usr/local/svn (whatever)
(setq url
(cadr (split-string (buffer-substring-no-properties beg end)))))
(cond
(name
(vc-do-command t nil "svn" dir "switch" "-r" name url))
(t (vc-do-command t nil "svn" dir "switch" url)))
(cond
(update
(vc-do-command t nil "svn" dir "update")))))
(defun vc-svn-rename-file (old new)
"renames a file in Subversion from OLD to NEW"
;; This will copy from old to new and leave the result waiting for a
;; commit, but I don't know if I should do a commit here, or use the
;; url syntax to cause the copy to happen on the server.
(vc-do-command t nil "svn" old "move" new))
(provide 'vc-svn)
;;;; vc-svn ends here
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vc-svn.el donation - attn Stephan Monnier
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-04 22:23 ` Stefan Monnier
2 siblings, 0 replies; 7+ messages in thread
From: Richard Stallman @ 2003-07-03 15:48 UTC (permalink / raw
Cc: emacs-devel
I was advised there was already a version
of vc-svn.el in CVS and that I should contact Stephan Monnier about
it, however I don't have his email address.
You can try monnier@cs.yale.edu, but since he is on emacs-devel,
he should see your message anyway.
If someone could put me in
touch with him (so he doesn't think this is some spammer filling his
inbox :)
He would not think a message on emacs-devel is spam when it contains
Lisp code for Emacs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vc-svn.el donation - attn Stephan Monnier
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-04 0:47 ` Stefan Monnier
2003-07-04 22:23 ` Stefan Monnier
2 siblings, 2 replies; 7+ messages in thread
From: Karl Fogel @ 2003-07-03 17:41 UTC (permalink / raw
Cc: emacs-devel
Jeff Bowman <jeff@dvns.com> writes:
> I am not a member of this mailing list. I posted a version of
> vc-svn.el I wrote to include Subversion support in emacs. My intention
> was to donate it to GNU. I am happy to sign any paperwork to assign
> copyrights, etc as needed. I was advised there was already a version
> of vc-svn.el in CVS and that I should contact Stephan Monnier about
> it, however I don't have his email address. If someone could put me in
> touch with him (so he doesn't think this is some spammer filling his
> inbox :) better yet if Mr. Monnier would contact me, I'd appreciate
> it. I was also advised I should post this to emacs-devel where
> maintainers hang out so they can evaluate the code for possible
> inclusion.
>
> I am including my version of vc-svn.el with this email, hopefully it
> will help in someway with the current vc-svn.el development. Also, I'm
> interested in helping in anyway with the development of this
> module. My company is shortly going to convert to using Subversion, so
> this module is important to me. Please let me know if there is
> anything further I can contribute.
Thanks for the contribution, Jeff. This is now the third vc-svn.el
floating around in the world, as far as I'm aware:
1) In the Subversion tree, we have tools/client-side/vc-svn.el.
This one is by Jim Blandy, first posted in July 2002, now
maintained by others. (I guess you didn't know about this
one?)
2) There's Stefan Monnier's lisp/vc-svn.el, in the FSF Emacs
source tree. This one started life as a fork of vc-cvs.el, but
says "Sync'd with Subversion's vc-svn.el as of revision 5801",
which means it's up-to-date w.r.t. the latest version of (1).
3) There's your version, which I gather is an independent fork of
vc-cvs.el and contains no DNA from (1) or (2) :-).
It would be nice to have one canonical edition of vc-svn.el, and for
that edition to live in the Emacs source tree. I'm not the right
person to maintain it, as I don't use it, but Stefan might be. If he
is actively maintaining the one currently in Emacs, and is sure that
the one in the Subversion tree has nothing that's not in his version,
then perhaps our task is as simple as:
a) See if there's anything useful in your version that's missing
from Stefan's, and port those changes over if so, and
b) Remove the one in the Subversion tree, and point people at some
public URL for the one in the Emacs tree.
...Stefan?
-Karl, trying to avoid divergent vc-svn.el's take over the world
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vc-svn.el donation - attn Stephan Monnier
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
1 sibling, 1 reply; 7+ messages in thread
From: Jeff Bowman @ 2003-07-03 22:43 UTC (permalink / raw
Cc: emacs-devel
Karl Fogel <kfogel@floss.red-bean.com> writes:
> Jeff Bowman <jeff@dvns.com> writes:
> > I am not a member of this mailing list. I posted a version of
> > vc-svn.el I wrote to include Subversion support in emacs. My intention
> > was to donate it to GNU. I am happy to sign any paperwork to assign
> > copyrights, etc as needed. I was advised there was already a version
> > of vc-svn.el in CVS and that I should contact Stephan Monnier about
> > it, however I don't have his email address. If someone could put me in
> > touch with him (so he doesn't think this is some spammer filling his
> > inbox :) better yet if Mr. Monnier would contact me, I'd appreciate
> > it. I was also advised I should post this to emacs-devel where
> > maintainers hang out so they can evaluate the code for possible
> > inclusion.
> >
> > I am including my version of vc-svn.el with this email, hopefully it
> > will help in someway with the current vc-svn.el development. Also, I'm
> > interested in helping in anyway with the development of this
> > module. My company is shortly going to convert to using Subversion, so
> > this module is important to me. Please let me know if there is
> > anything further I can contribute.
>
> Thanks for the contribution, Jeff. This is now the third vc-svn.el
> floating around in the world, as far as I'm aware:
>
> 1) In the Subversion tree, we have tools/client-side/vc-svn.el.
> This one is by Jim Blandy, first posted in July 2002, now
> maintained by others. (I guess you didn't know about this
> one?)
>
> 2) There's Stefan Monnier's lisp/vc-svn.el, in the FSF Emacs
> source tree. This one started life as a fork of vc-cvs.el, but
> says "Sync'd with Subversion's vc-svn.el as of revision 5801",
> which means it's up-to-date w.r.t. the latest version of (1).
>
> 3) There's your version, which I gather is an independent fork of
> vc-cvs.el and contains no DNA from (1) or (2) :-).
>
> It would be nice to have one canonical edition of vc-svn.el, and for
> that edition to live in the Emacs source tree. I'm not the right
> person to maintain it, as I don't use it, but Stefan might be. If he
> is actively maintaining the one currently in Emacs, and is sure that
> the one in the Subversion tree has nothing that's not in his version,
> then perhaps our task is as simple as:
>
> a) See if there's anything useful in your version that's missing
> from Stefan's, and port those changes over if so, and
>
> b) Remove the one in the Subversion tree, and point people at some
> public URL for the one in the Emacs tree.
>
> ...Stefan?
>
> -Karl, trying to avoid divergent vc-svn.el's take over the world
Thank you for your email.
All true statements. I didn't know about the one in the Subversion
source tree, but I did look. I must have somehow missed that one. I
then looked at the ell (emacs lisp list) for one, but only found psvn,
which works, but I wanted a version that was well integrated with the
keystrokes I already know and use. So I started my own, and did use
vc-cvs as inspiration, and some cut and paste (which I noted in my
code). But since I didn't find anything else, I thought (hoped
actually) that I was the first one to make a vc-svn.el and that I
could contribute it. :)
I am still interested in helping with this module if help is needed. I
use Subversion on a daily basis and my IDE is emacs. I agree that we
should have a canonical version. My vote is to provide the code with
emacs and maybe also on the ell, which is a good url to point to.
The only real issue I have is that I am not an Official Emacs
Maintainer. So I can't commit to the CVS repository. Not a real big
deal, I could send patches to the appropriate maintainer if that is
what I need to do. I just need advice on what to do.
Thanks
Jeff
--
__
/ / (_)__ __ ____ __
/ /__/ / _ \/ // /\ \/ / . . . t h e c h o i c e o f a
/____/_/_//_/\_,_/ /_/\_\ G N U g e n e r a t i o n . . .
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vc-svn.el donation - attn Stephan Monnier
2003-07-03 22:43 ` Jeff Bowman
@ 2003-07-03 22:58 ` Andre Spiegel
0 siblings, 0 replies; 7+ messages in thread
From: Andre Spiegel @ 2003-07-03 22:58 UTC (permalink / raw
Cc: emacs-devel
On Fri, 2003-07-04 at 00:43, Jeff Bowman wrote:
> The only real issue I have is that I am not an Official Emacs
> Maintainer. So I can't commit to the CVS repository. Not a real big
> deal, I could send patches to the appropriate maintainer if that is
> what I need to do. I just need advice on what to do.
I think Stefan is the right person to maintain vc-svn.el for Emacs. I
myself, although I'm the VC maintainer, can't do it because I'm not a
Subversion user yet and my time is limited. (And this was the reason
for the modular redesign of VC: that other people could maintain
backends.)
Stefan is probably on holiday or something. When he returns, there's no
doubt he will carefully look at your code and see what he can
incorporate into his own stuff.
And of course you're always welcome to submit patches. The one who's
most active in enhancing a package usually gets maintainer status over
time. We'll see how it works out. Thanks for your contribution; let's
first wait until Stefan returns.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vc-svn.el donation - attn Stephan Monnier
2003-07-03 17:41 ` Karl Fogel
2003-07-03 22:43 ` Jeff Bowman
@ 2003-07-04 0:47 ` Stefan Monnier
1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2003-07-04 0:47 UTC (permalink / raw
Cc: emacs-devel
> that edition to live in the Emacs source tree. I'm not the right
> person to maintain it, as I don't use it, but Stefan might be. If he
> is actively maintaining the one currently in Emacs, and is sure that
> the one in the Subversion tree has nothing that's not in his version,
> then perhaps our task is as simple as:
>
> a) See if there's anything useful in your version that's missing
> from Stefan's, and port those changes over if so, and
I'll do that as soon as I catch up with the rest of my mail.
> b) Remove the one in the Subversion tree, and point people at some
> public URL for the one in the Emacs tree.
The one in the Emacs tree is supposed to provide a superset of the
functionality of the one in the Subversion tree, except for the fact
that it does not work with Emacs-21.X.
Whether it does provide a superset or not is actually an open question
because the code is completely different (the sync'ing is "featurewise"
rather than "codewise").
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vc-svn.el donation - attn Stephan Monnier
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-04 22:23 ` Stefan Monnier
2 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2003-07-04 22:23 UTC (permalink / raw
Cc: emacs-devel
> (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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-07-04 22:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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).