[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vc-svn.el donation - attn Stephan Monnier

From: Stefan Monnier
Subject: Re: vc-svn.el donation - attn Stephan Monnier
Date: Fri, 04 Jul 2003 18:23:39 -0400

> (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
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")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]