You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Martin Pool <mb...@sourcefrog.net> on 2003/03/27 01:14:26 UTC

[PATCH] vc-svn: Enable vc-merge, avoid "svn status -uv"

Hello,

Following is a patch to improve vc-svn.  It does not fix every outstanding
issue, but after testing and discussion on the list I think it is an
improvement.  Please apply.

Log entry:

* tools/client-side/vc-svn.el (vc-svn-state): Avoid running "svn
  status -uv" to check the status of a file, because this causes
  network delays and is not really necessary, and also does not work
  on newly-added files in some releases of Subversion (issue #1042).

* tools/client-side/vc-svn.el: Describe how to get svn support
  autoloaded by emacs.  Document work that should be done to bring
  this up to the same standard as emacs vc-cvs support.
 
* tools/client-side/vc-svn.el (vc-svn-merge-news): Implement vc-merge
  for Subversion.  After merging updates, if any, cause vc to reload
  the file's base revision.

Thanks
Martin

Index: tools/client-side/vc-svn.el
===================================================================
--- tools/client-side/vc-svn.el	(revision 5449)
+++ tools/client-side/vc-svn.el	(working copy)
@@ -11,17 +11,51 @@
 ;;; VC patches.
 
 
+;;; To make this file load on demand, put this line into a startup file:
+;;;
+;;;     (add-to-list 'vc-handled-backends 'SVN)
+
+
 ;;; To do here:
 ;;; Provide more of the optional VC backend functions: 
 ;;; - dir-state
 ;;; - mode-line-string, to show newly added files, modified props?
 ;;;   see vc-cvs-mode-line-string
+;;; - merge across arbitrary revisions
+;;; - allow getting read-only copies for vc-version-other-window etc
 ;;;
 ;;; VC passes the vc-svn-register function a COMMENT argument, which
 ;;; is like the file description in CVS and RCS.  Could we store the
 ;;; COMMENT as a Subversion property?  Would that show up in fancy DAV
 ;;; web folder displays, or would it just languish in obscurity, the
 ;;; way CVS and RCS descriptions do?
+;;;
+;;; After manual merging, need some way to run `svn resolve'.  Perhaps
+;;; we should just prompt for approval when somebody tries to commit a
+;;; conflicted file?
+;;;
+;;; vc-svn ought to handle more gracefully an attempted commit that
+;;; fails with "Transaction is out of date".  Probably the best
+;;; approach is to ask "file is not up-to-date; do you want to merge
+;;; now?"  I think vc-cvs does this.
+;;;
+;;; Perhaps show the "conflicted" marker in the modeline?
+;;;
+;;; If conflicted, before committing or merging, ask the user if they
+;;; want to mark the file as resolved.
+;;;
+;;; Won't searching for strings in svn output cause trouble if the
+;;; locale language is not English?
+;;;
+;;; After merging news, need to recheck our idea of which workfile
+;;; version we have.  Reverting the file does this but we need to
+;;; force it.  Note that this can be necessary even if the file has
+;;; not changed.
+;;;
+;;; Does everything work properly if we're rolled back to an old
+;;; revision?
+;;;
+;;; Perhaps need to implement vc-svn-latest-on-branch-p?
 
 
 ;;; To do in VC:
@@ -38,7 +72,18 @@
 ;;;
 ;;; Should vc-BACKEND-checkout really have to set the workfile version
 ;;; itself?
+;;;
+;;; Fix smerge for svn conflict markers.
+;;;
+;;; We can have files which are not editable for reasons other than
+;;; needing to be checked out.  For example, they might be a read-only
+;;; view of an old revision opened with [C-x v ~].  (See vc-merge)
+;;;
+;;; Would be nice if there was a way to mark a file as
+;;; just-checked-out, aside from updating the checkout-time property
+;;; which in theory is not to be changed by backends.
 
+
 (add-to-list 'vc-handled-backends 'SVN)
 
 (defcustom vc-svn-program-name "svn"
@@ -181,15 +226,26 @@
    (t 'edited)))
 
 
+;;; Is it really safe not to check for updates?  I haven't seen any
+;;; cases where failing to check causes a problem that is not caught
+;;; in some other way.  However, there *are* cases where checking
+;;; needlessly causes network delay, such as C-x v v.  The common case
+;;; is for the commit to be OK; we can handle errors if they occur. -- mbp
 (defun vc-svn-state (file)
   "Return the current version control state of FILE.
 For a list of possible return values, see `vc-state'.
+
 This function should do a full and reliable state computation; it is
 usually called immediately after `C-x v v'.  `vc-svn-state-heuristic'
-provides a faster heuristic when visiting a file."
-  (car (vc-svn-run-status file 'update)))
+provides a faster heuristic when visiting a file.
 
+For svn this does *not* check for updates in the repository, because
+that needlessly slows down vc when the repository is remote.  Instead,
+we rely on Subversion to trap situations such as needing a merge
+before commit."
+  (car (vc-svn-run-status file)))
 
+
 (defun vc-svn-state-heuristic (file)
   "Estimate the version control state of FILE at visiting time.
 For a list of possible values, see the doc string of `vc-state'.
@@ -255,6 +311,33 @@
   (vc-do-command nil 0 vc-svn-program-name file "revert"))
 
 
+(defun vc-svn-merge-news (file)
+  "Merge recent changes into FILE.
+
+This calls `svn update'.  In the case of conflicts, Subversion puts
+conflict markers into the file and leaves additional temporary files
+containing the `ancestor', `mine', and `other' files.
+
+You may need to run `svn resolve' by hand once these conflicts have
+been resolved.  
+
+Returns a vc status, which is used to determine whether conflicts need
+to be merged."
+  (prog1
+      (vc-do-command nil 0 vc-svn-program-name file "update")
+    
+    ;; This file may not have changed in the revisions which were
+    ;; merged, which means that its mtime on disk will not have been
+    ;; updated.  However, the workfile version may still have been
+    ;; updated, and we want that to be shown correctly in the
+    ;; modeline.
+
+    ;; vc-cvs does something like this
+    (vc-file-setprop file 'vc-checkout-time 0)
+    (vc-file-setprop file 'vc-workfile-version
+		     (vc-svn-workfile-version file))))
+
+
 (defun vc-svn-print-log (file)
   "Insert the revision log of FILE into the *vc* buffer."
   (vc-do-command nil 'async vc-svn-program-name file "log"))

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] vc-svn: Enable vc-merge, avoid "svn status -uv"

Posted by Branko Čibej <br...@xbc.nu>.
Martin Pool wrote:

>On 27 Mar 2003, Branko ??ibej <br...@xbc.nu> wrote:
>  
>
>>Couldn't we add an option here to run emerge for conflict resolution,
>>instead of leaving the user to stew in their own juice?
>>    
>>
>
>Yes, I think that would be an excellent idea, and I intend to write it
>when I can.  Because Subversion provides the files for a 3-way merge
>it should work well, although we can also give the user the option to
>use smerge or something else.
>
>I think this patch doesn't make the situation any worse than it was
>before: at least now you can merge nonconflicting changes, and newly
>added files don't break.  Are you happy to commit it?  I'd like to
>keep working on vc-svn and psvn.
>  
>

O.K., just as long as you have this option in mind, I'm happy. :-)

The patch looks O.K. to me, but I'm not competent to comment on elisp
code; I haven't doen enought of that. Luckily, there are people here who
have. Karl?

-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] vc-svn: Enable vc-merge, avoid "svn status -uv"

Posted by Martin Pool <mb...@sourcefrog.net>.
On 27 Mar 2003, Branko ??ibej <br...@xbc.nu> wrote:
> Couldn't we add an option here to run emerge for conflict resolution,
> instead of leaving the user to stew in their own juice?

Yes, I think that would be an excellent idea, and I intend to write it
when I can.  Because Subversion provides the files for a 3-way merge
it should work well, although we can also give the user the option to
use smerge or something else.

I think this patch doesn't make the situation any worse than it was
before: at least now you can merge nonconflicting changes, and newly
added files don't break.  Are you happy to commit it?  I'd like to
keep working on vc-svn and psvn.

-- 
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] vc-svn: Enable vc-merge, avoid "svn status -uv"

Posted by Branko Čibej <br...@xbc.nu>.
Martin Pool wrote:

>Hello,
>
>Following is a patch to improve vc-svn.  It does not fix every outstanding
>issue, but after testing and discussion on the list I think it is an
>improvement.  Please apply.
>
>Log entry:
>
>* tools/client-side/vc-svn.el (vc-svn-state): Avoid running "svn
>  status -uv" to check the status of a file, because this causes
>  network delays and is not really necessary, and also does not work
>  on newly-added files in some releases of Subversion (issue #1042).
>
>* tools/client-side/vc-svn.el: Describe how to get svn support
>  autoloaded by emacs.  Document work that should be done to bring
>  this up to the same standard as emacs vc-cvs support.
> 
>* tools/client-side/vc-svn.el (vc-svn-merge-news): Implement vc-merge
>  for Subversion.  After merging updates, if any, cause vc to reload
>  the file's base revision.
>

[snip]

>+(defun vc-svn-merge-news (file)
>+  "Merge recent changes into FILE.
>+
>+This calls `svn update'.  In the case of conflicts, Subversion puts
>+conflict markers into the file and leaves additional temporary files
>+containing the `ancestor', `mine', and `other' files.
>+
>+You may need to run `svn resolve' by hand once these conflicts have
>+been resolved.  
>+
>+Returns a vc status, which is used to determine whether conflicts need
>+to be merged."
>+  (prog1
>+      (vc-do-command nil 0 vc-svn-program-name file "update")
>
Couldn't we add an option here to run emerge for conflict resolution,
instead of leaving the user to stew in their own juice?

-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] vc-svn: Enable vc-merge, avoid "svn status -uv"

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Martin Pool <mb...@sourcefrog.net> writes:
> * tools/client-side/vc-svn.el (vc-svn-state): Avoid running "svn
>   status -uv" to check the status of a file, because this causes
>   network delays and is not really necessary, and also does not work
>   on newly-added files in some releases of Subversion (issue #1042).
> 
> * tools/client-side/vc-svn.el: Describe how to get svn support
>   autoloaded by emacs.  Document work that should be done to bring
>   this up to the same standard as emacs vc-cvs support.
>  
> * tools/client-side/vc-svn.el (vc-svn-merge-news): Implement vc-merge
>   for Subversion.  After merging updates, if any, cause vc to reload
>   the file's base revision.

No need to list the same file three times.  I rewrote the log message
thusly:

 .----------------------------------------------------------------------.
 | Patch from Martin Pool <mb...@sourcefrog.net>:                         |
 |                                                                      |
 | Enable vc-merge in vc-svn.el, and avoid "svn status -uv".            |
 |                                                                      |
 | * tools/client-side/vc-svn.el:                                       |
 |   (vc-svn-state): Avoid running "svn status -uv" to check the status |
 |     of a file, because this causes network delays and is not really  |
 |     necessary, and also does not work on newly-added files in some   |
 |     releases of Subversion [see issue #1042].                        |
 |   (vc-svn-merge-news): Implement vc-merge for Subversion.  After     |
 |     merging updates, if any, cause vc to reload the file's base      |
 |     revision.                                                        |
 |                                                                      |
 |   Also, describe how to get svn support autoloaded by emacs, and     |
 |   document work that should be done to bring this up to the same     |
 |   standard as emacs vc-cvs support.                                  |
 `----------------------------------------------------------------------'

> Index: tools/client-side/vc-svn.el
> ===================================================================
> --- tools/client-side/vc-svn.el	(revision 5449)
> +++ tools/client-side/vc-svn.el	(working copy)
> @@ -11,17 +11,51 @@
>  ;;; VC patches.
>  
>  
> +;;; To make this file load on demand, put this line into a startup file:
> +;;;
> +;;;     (add-to-list 'vc-handled-backends 'SVN)
> +
> +

This won't do any good if the file is not in the user's `load-path'
(in fact, it will cause an error when bringing svn-controlled files
into Emacs! :-) ).  I'll amend the instructions when I apply the
patch.

Otherwise, looks good, I'm applying now.

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] vc-svn: Enable vc-merge, avoid "svn status -uv"

Posted by Sander Roobol <ph...@wanadoo.nl>.
Filed as issue #1218.

Sander

On Thu, Mar 27, 2003 at 12:14:26PM +1100, Martin Pool wrote:
> Hello,
> 
> Following is a patch to improve vc-svn.  It does not fix every outstanding
> issue, but after testing and discussion on the list I think it is an
> improvement.  Please apply.
> 
> Log entry:
> 
> * tools/client-side/vc-svn.el (vc-svn-state): Avoid running "svn
>   status -uv" to check the status of a file, because this causes
>   network delays and is not really necessary, and also does not work
>   on newly-added files in some releases of Subversion (issue #1042).
> 
> * tools/client-side/vc-svn.el: Describe how to get svn support
>   autoloaded by emacs.  Document work that should be done to bring
>   this up to the same standard as emacs vc-cvs support.
>  
> * tools/client-side/vc-svn.el (vc-svn-merge-news): Implement vc-merge
>   for Subversion.  After merging updates, if any, cause vc to reload
>   the file's base revision.
> 
> Thanks
> Martin
> [snip]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org