You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by e....@gmx.net on 2003/08/30 21:58:19 UTC

[PATCH] Kludge to make vc-svn.el work with Ediff (compare file with revision)

Hi All,

For my current work on the test suite I needed Ediff to be able to compare
between a working copy and a revision of a file. Ediff does that by asking the
vc support to check out a file under a different name. svn does not support
this. Neither does svn support read-only files. Ediff uses both the read-only
flag and the destination file when requesting a file.

So I added support to vc-svn.el for what Ediff wants. Others might be
interested, so I decided to submit. There might be cleaner ways to do this though.
Please comment.


Log:
[[[
Add support to vc-svn.el for Ediff diff of working copy against 
revision.

 * contrib/client-side/vc-svn.el
   vc-svn-checkout: added support for operation
      'read-only to different file' as requested by Ediff
]]]



Index: contrib/client-side/vc-svn.el
===================================================================
--- contrib/client-side/vc-svn.el	(revision 6924)
+++ contrib/client-side/vc-svn.el	(working copy)
@@ -294,15 +294,24 @@
 passing nil.
 If optional arg DESTFILE is given, it is an alternate filename to
 write the contents to; we raise an error."
-  (unless editable
+  (when (or (not rev) (equal rev ""))
+    (setq rev "head"))
+  (cond
+   ((and (not editable) destfile) 
+    (let ((buffer (create-file-buffer destfile)))
+      (set-buffer buffer)
+      (erase-buffer)
+      (vc-svn-find-version file rev buffer)
+      (write-file destfile nil)
+      (kill-buffer buffer)))
+   (editable
     (error "VC asked Subversion to check out a read-only copy of file"))
-  (when destfile
+   (destfile
     (error "VC asked Subversion to check out a file under another name"))
-  (when (equal rev "")
-    (setq rev nil))
-  (apply 'vc-do-command nil 0 vc-svn-program-name file
-         "update" (if rev (list "-r" rev) '()))
-  (vc-file-setprop file 'vc-workfile-version nil))
+   (t
+    (apply 'vc-do-command nil 0 vc-svn-program-name file
+	   "update" (list "-r" rev))
+    (vc-file-setprop file 'vc-workfile-version nil))))
 
 
 (defun vc-svn-revert (file &optional contents-done)

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post


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

Re: [PATCH] Kludge to make vc-svn.el work with Ediff (compare file with revision)

Posted by Sander Roobol <ph...@wanadoo.nl>.
On Sat, Aug 30, 2003 at 11:58:19PM +0200, e.huelsmann@gmx.net wrote:
> Hi All,
> 
> For my current work on the test suite I needed Ediff to be able to compare
> between a working copy and a revision of a file. Ediff does that by asking the
> vc support to check out a file under a different name. svn does not support
> this. Neither does svn support read-only files. Ediff uses both the read-only
> flag and the destination file when requesting a file.
> 
> So I added support to vc-svn.el for what Ediff wants. Others might be
> interested, so I decided to submit. There might be cleaner ways to do this though.
> Please comment.

Filed as issue #1512.

Sander

> 
> 
> Log:
> [[[
> Add support to vc-svn.el for Ediff diff of working copy against 
> revision.
> 
>  * contrib/client-side/vc-svn.el
>    vc-svn-checkout: added support for operation
>       'read-only to different file' as requested by Ediff
> ]]]
> 
> 
> 
> Index: contrib/client-side/vc-svn.el
> ===================================================================
> --- contrib/client-side/vc-svn.el	(revision 6924)
> +++ contrib/client-side/vc-svn.el	(working copy)
> @@ -294,15 +294,24 @@
>  passing nil.
>  If optional arg DESTFILE is given, it is an alternate filename to
>  write the contents to; we raise an error."
> -  (unless editable
> +  (when (or (not rev) (equal rev ""))
> +    (setq rev "head"))
> +  (cond
> +   ((and (not editable) destfile) 
> +    (let ((buffer (create-file-buffer destfile)))
> +      (set-buffer buffer)
> +      (erase-buffer)
> +      (vc-svn-find-version file rev buffer)
> +      (write-file destfile nil)
> +      (kill-buffer buffer)))
> +   (editable
>      (error "VC asked Subversion to check out a read-only copy of file"))
> -  (when destfile
> +   (destfile
>      (error "VC asked Subversion to check out a file under another name"))
> -  (when (equal rev "")
> -    (setq rev nil))
> -  (apply 'vc-do-command nil 0 vc-svn-program-name file
> -         "update" (if rev (list "-r" rev) '()))
> -  (vc-file-setprop file 'vc-workfile-version nil))
> +   (t
> +    (apply 'vc-do-command nil 0 vc-svn-program-name file
> +	   "update" (list "-r" rev))
> +    (vc-file-setprop file 'vc-workfile-version nil))))
>  
>  
>  (defun vc-svn-revert (file &optional contents-done)
> 
> -- 
> COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
> --------------------------------------------------
> 1. GMX TopMail - Platz 1 und Testsieger!
> 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
> 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
> 
> 

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

Re: [PATCH] Kludge to make vc-svn.el work with Ediff (compare file with revision)

Posted by Julian Foad <ju...@btopenworld.com>.
e.huelsmann@gmx.net wrote:
> BTW the solution in elisp that I coded does almost what you describe,
> but hidden to the user.

Oh, that's good then.  That is what I meant.

- Julian


>>Sure I can run 'svn cat -r #### file >new-name; chmod -w new-name', but when
>>I ask ediff to diff between a working copy file and a revision it issues the
>>vc-svn-checkout command to retrieve the revision. When diffing between two
>>files, this problem does not exist since I would have to create my own
>>filenames.
>>
>>Where you commenting about the vc-svn.el code or the fact that I even tried
>>to modify it?

I meant "can you make the e-lisp code do the equivalent of "svn cat ... chmod -w ...".


>>>Can you use "svn cat -r#### file > new-name; chmod -w new-name"?
>>>
>>>- Julian


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

Re: [PATCH] Kludge to make vc-svn.el work with Ediff (compare file with revision)

Posted by e....@gmx.net.
BTW the solution in elisp that I coded does almost what you describe,
but hidden to the user.

bye,

Erik.


> Hi Julian,
> 
> Sure I can run 'svn cat -r #### file >new-name; chmod -w new-name', but
> when
> I ask ediff to diff between a working copy file and a revision it issues
> the
> vc-svn-checkout command to retrieve the revision. When diffing between two
> files, this problem does not exist since I would have to create my own
> filenames.
> 
> Where you commenting about the vc-svn.el code or the fact that I even
> tried
> to modify it?
> 
> bye,
> 
> Erik.
> 
> 
> 
> > e.huelsmann@gmx.net wrote:
> > > 
> > > For my current work on the test suite I needed Ediff to be able to
> > compare
> > > between a working copy and a revision of a file. Ediff does that by
> > asking the
> > > vc support to check out a file under a different name. svn does not
> > support
> > > this. Neither does svn support read-only files. Ediff uses both the
> > read-only
> > > flag and the destination file when requesting a file.
> > 
> > Can you use "svn cat -r#### file > new-name; chmod -w new-name"?
> > 
> > - Julian
> > 
> 
> -- 
> COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
> --------------------------------------------------
> 1. GMX TopMail - Platz 1 und Testsieger!
> 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
> 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8.
> e-Post
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
> 

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post


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

Re: [PATCH] Kludge to make vc-svn.el work with Ediff (compare file with revision)

Posted by e....@gmx.net.
Hi Julian,

Sure I can run 'svn cat -r #### file >new-name; chmod -w new-name', but when
I ask ediff to diff between a working copy file and a revision it issues the
vc-svn-checkout command to retrieve the revision. When diffing between two
files, this problem does not exist since I would have to create my own
filenames.

Where you commenting about the vc-svn.el code or the fact that I even tried
to modify it?

bye,

Erik.



> e.huelsmann@gmx.net wrote:
> > 
> > For my current work on the test suite I needed Ediff to be able to
> compare
> > between a working copy and a revision of a file. Ediff does that by
> asking the
> > vc support to check out a file under a different name. svn does not
> support
> > this. Neither does svn support read-only files. Ediff uses both the
> read-only
> > flag and the destination file when requesting a file.
> 
> Can you use "svn cat -r#### file > new-name; chmod -w new-name"?
> 
> - Julian
> 

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post


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

Re: [PATCH] Kludge to make vc-svn.el work with Ediff (compare file with revision)

Posted by Julian Foad <ju...@btopenworld.com>.
e.huelsmann@gmx.net wrote:
> 
> For my current work on the test suite I needed Ediff to be able to compare
> between a working copy and a revision of a file. Ediff does that by asking the
> vc support to check out a file under a different name. svn does not support
> this. Neither does svn support read-only files. Ediff uses both the read-only
> flag and the destination file when requesting a file.

Can you use "svn cat -r#### file > new-name; chmod -w new-name"?

- Julian


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