You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Garrett Rooney <ro...@electricjellyfish.net> on 2002/09/07 02:29:51 UTC

[PATCH] svn url command

A while back, there was a discussion concerning how to get the url for 
a given versioned resource in the working copy.  The current way to do 
this is something like 'svn info FOO | grep ^Url', which is fine on 
UNIX, but is less than ideal on windows.  It also requires a fair 
amount of massaging of the data if one only wants the URL, and doesn't 
want the rest of the information printed out.

One of the suggested solutions to the problem was an 'svn url' command. 
  I can't recall if there was a consensus on this or not, but on the off 
chance that we do want it, here's a patch that implements it.  If 
nobody objects, I'll commit it sometime tomorrow.

-garrett

(ok, i hope this doesn't come out mangled, since Mail.app seems to have 
some odd reactions to embedded ^L's, and I can't tell if this whole 
patch is here or not, but hey, let's roll the dice and see what 
happens...)

Index: subversion/clients/cmdline/cl.h
===================================================================
--- subversion/clients/cmdline/cl.h
+++ subversion/clients/cmdline/cl.h	Fri Sep  6 21:38:25 2002
@@ -141,7 +141,8 @@
    svn_cl__resolve,
    svn_cl__status,
    svn_cl__switch,
-  svn_cl__update;
+  svn_cl__update,
+  svn_cl__url;


  /* Print a generic (non-command-specific) usage message. */
Index: subversion/clients/cmdline/url-cmd.c
===================================================================
--- subversion/clients/cmdline/url-cmd.c
+++ subversion/clients/cmdline/url-cmd.c	Fri Sep  6 21:54:36 2002
@@ -0,0 +1,76 @@
+/*
+ * url-cmd.c -- Display a resource's url
+ *
+ * ====================================================================
+ * Copyright (c) 2000-2002 CollabNet.  All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals.  For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ */
+
+/* 
==================================================================== */
+
+
+
+/*** Includes. ***/
+
+#include "svn_wc.h"
+#include "svn_error.h"
+#include "svn_utf.h"
+#include "cl.h"
+
+
+/*** Code. ***/
+
+svn_error_t *
+svn_cl__url (apr_getopt_t *os,
+             svn_cl__opt_state_t *opt_state,
+             apr_pool_t *pool)
+{
+  apr_array_header_t *targets;
+  const char *native;
+  int i;
+
+  SVN_ERR (svn_cl__args_to_target_array (&targets, os, opt_state,
+                                         FALSE, pool));
+
+  /* Add "." if user passed 0 arguments. */
+  svn_cl__push_implicit_dot_target (targets, pool);
+
+  for (i = 0; i < targets->nelts; i++)
+    {
+      const char *target = ((const char **) (targets->elts))[i];
+      svn_wc_entry_t *entry;
+
+      svn_wc_entry (&entry, target, FALSE, pool);
+      if (! entry)
+        {
+          SVN_ERR (svn_utf_cstring_from_utf8 (&native, target, pool));
+
+          printf ("%s:  (Not a versioned resource)\n", native);
+        }
+      else if (entry->url)
+        {
+          SVN_ERR (svn_utf_cstring_from_utf8 (&native, entry->url, 
pool));
+
+          printf ("%s\n", native);
+        }
+    }
+
+  return SVN_NO_ERROR;
+}
+
+
+/*
+ * local variables:
+ * eval: (load-file "../../../tools/dev/svn-dev.el")
+ * end:
+ */
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/main.c
+++ subversion/clients/cmdline/main.c	Fri Sep  6 21:43:06 2002
@@ -423,6 +423,11 @@
       svn_cl__auth_password_opt, svn_cl__no_auth_cache_opt,
       svn_cl__xml_file_opt} },

+  { "url", svn_cl__url, {0},
+    "Display a resource's url.\n"
+    "usage: url [PATH1 [PATH2 ...]\n",
+    {0} },
+
    { NULL, NULL, {0}, NULL, {0} }
  };

Index: 
subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout
===================================================================
--- subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout
+++ 
subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout	Fri 
Sep  6 22:14:02 2002
@@ -33,6 +33,7 @@
     status (stat, st)
     switch (sw)
     update (up)
+   url

  Subversion is a tool for revision control.
  For additional information, see http://subversion.tigris.org
Index: 
subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout
===================================================================
--- subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout
+++ 
subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout	Fri 
Sep  6 22:14:21 2002
@@ -33,6 +33,7 @@
     status (stat, st)
     switch (sw)
     update (up)
+   url

  Subversion is a tool for revision control.
  For additional information, see http://subversion.tigris.org
Index: doc/handbook/client.texi
===================================================================
--- doc/handbook/client.texi
+++ doc/handbook/.svn/tmp/client.texi.63104.00001.tmp	Fri Sep  6 
22:23:32 2002
@@ -1745,6 +1745,19 @@
  Again, this is a form of immediate commit, so some sort of log message
  is required.

+@subheading @samp{svn url}
+
+This is a convenience command which prints out the URL associated with
+a given versioned resource.  This information is also available from 
the
+@samp{svn info} command, but it is also provided here so that it can be
+obtained in scripts without having to filter the output through some 
other
+command.
+
+@example
+$ svn url README
+http://svn.collab.net/repos/svn/trunk/README
+@end example
+

  @c ------------------------------------------------------------------
  @node Run-time Configuration

-- 
garrett rooney                    Remember, any design flaw you're
rooneg@electricjellyfish.net      sufficiently snide about becomes
http://electricjellyfish.net/     a feature.       -- Dan Sugalski

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

Re: [PATCH] svn url command

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On Sunday, September 8, 2002, at 04:32 AM, Sander Striker wrote:

>> From: Garrett Rooney [mailto:rooneg@electricjellyfish.net]
>> Sent: 08 September 2002 03:50
>
>> On Saturday, September 7, 2002, at 09:33 PM, Greg Stein wrote:
>>
>>> On Fri, Sep 06, 2002 at 10:29:51PM -0400, Garrett Rooney wrote:
>>>> ...
>>>> One of the suggested solutions to the problem was an 'svn url'
>>>> command.
>>>>   I can't recall if there was a consensus on this or not, but on the
>>>> off
>>>> chance that we do want it, here's a patch that implements it.  If
>>>> nobody objects, I'll commit it sometime tomorrow.
>>>
>>> I would rather not see Yet Another Subcommand. Since this information
>>> is
>>> readily available with just the tiniest processing, then I don't 
>>> think
>>> we
>>> need to bulk up SVN's user experience for it.
>>>
>>> Put me at a -0.9 for this. (read: not a veto, but big dislike :-)
>>
>> given the fact that none of the people who were clamoring for this
>> command back when the thread first happened have said anything, and
>> that someone has given a way to do the equivalent of 'svn info | grep'
>> for windows, i'm not about to commit it any time soon.  but if the
>> people who wanted it pop up and we decide we want it, then at least
>> it's here.
>
> Wasn't there an issue on this in the issue tracker?  If so, you can 
> attach
> your patch so it doesn't get lost.

i didn't see one in the 'bite sized tasks' area, and i can't imagine 
one would get filed without being classified as a bite sized task...  
in any case, it literally took like 5 minutes to do, so if it slips 
through the cracks i'm not going to lose much sleep over it ;-)

-garrett

-- 
garrett rooney                    Remember, any design flaw you're
rooneg@electricjellyfish.net      sufficiently snide about becomes
http://electricjellyfish.net/     a feature.       -- Dan Sugalski


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

RE: [PATCH] svn url command

Posted by Sander Striker <st...@apache.org>.
> From: Garrett Rooney [mailto:rooneg@electricjellyfish.net]
> Sent: 08 September 2002 03:50

> On Saturday, September 7, 2002, at 09:33 PM, Greg Stein wrote:
> 
> > On Fri, Sep 06, 2002 at 10:29:51PM -0400, Garrett Rooney wrote:
> >> ...
> >> One of the suggested solutions to the problem was an 'svn url' 
> >> command.
> >>   I can't recall if there was a consensus on this or not, but on the 
> >> off
> >> chance that we do want it, here's a patch that implements it.  If
> >> nobody objects, I'll commit it sometime tomorrow.
> >
> > I would rather not see Yet Another Subcommand. Since this information 
> > is
> > readily available with just the tiniest processing, then I don't think 
> > we
> > need to bulk up SVN's user experience for it.
> >
> > Put me at a -0.9 for this. (read: not a veto, but big dislike :-)
> 
> given the fact that none of the people who were clamoring for this 
> command back when the thread first happened have said anything, and 
> that someone has given a way to do the equivalent of 'svn info | grep' 
> for windows, i'm not about to commit it any time soon.  but if the 
> people who wanted it pop up and we decide we want it, then at least 
> it's here.

Wasn't there an issue on this in the issue tracker?  If so, you can attach
your patch so it doesn't get lost.

Sander


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

Re: [PATCH] svn url command

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On Saturday, September 7, 2002, at 09:33 PM, Greg Stein wrote:

> On Fri, Sep 06, 2002 at 10:29:51PM -0400, Garrett Rooney wrote:
>> ...
>> One of the suggested solutions to the problem was an 'svn url' 
>> command.
>>   I can't recall if there was a consensus on this or not, but on the 
>> off
>> chance that we do want it, here's a patch that implements it.  If
>> nobody objects, I'll commit it sometime tomorrow.
>
> I would rather not see Yet Another Subcommand. Since this information 
> is
> readily available with just the tiniest processing, then I don't think 
> we
> need to bulk up SVN's user experience for it.
>
> Put me at a -0.9 for this. (read: not a veto, but big dislike :-)

given the fact that none of the people who were clamoring for this 
command back when the thread first happened have said anything, and 
that someone has given a way to do the equivalent of 'svn info | grep' 
for windows, i'm not about to commit it any time soon.  but if the 
people who wanted it pop up and we decide we want it, then at least 
it's here.

-garrett

-- 
garrett rooney                    Remember, any design flaw you're
rooneg@electricjellyfish.net      sufficiently snide about becomes
http://electricjellyfish.net/     a feature.       -- Dan Sugalski


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

Re: [PATCH] svn url command

Posted by Greg Stein <gs...@lyra.org>.
On Fri, Sep 06, 2002 at 10:29:51PM -0400, Garrett Rooney wrote:
>...
> One of the suggested solutions to the problem was an 'svn url' command. 
>   I can't recall if there was a consensus on this or not, but on the off 
> chance that we do want it, here's a patch that implements it.  If 
> nobody objects, I'll commit it sometime tomorrow.

I would rather not see Yet Another Subcommand. Since this information is
readily available with just the tiniest processing, then I don't think we
need to bulk up SVN's user experience for it.

Put me at a -0.9 for this. (read: not a veto, but big dislike :-)

Oh, and if you have the Python SWIG bindings laying around, then you have
/tools/examples/geturl.py to print files' and dirs' URLs :-)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

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

RE: [PATCH] svn url command

Posted by Barry Scott <ba...@ntlworld.com>.
> well, we can't do that because we've decided not to allow subcommand 
> specific flags (for good reason, it complicates the user interface, see 
> the mailing list archives for details).  off the top of my head, i 
> can't think of a good way to design this interface without that...  
> perhaps something like:
> 
> $ svn info -x 'url revision last-change-author' FOO
> 
> (perhaps -x is not correct...  that's what we use to pass flags to diff 
> though, and this is /sort of/ similar...)
> 
> but then it just feels like we're /really/ trying to fake have 
> subcommand specific flags...

O.k. I understand.

> 
> anyway, i'd prefer not to get into a protracted discussion on this, 
> since i don't personally have a huge need for this anyway.  i know that 
> some of the windows people had wanted this functionality, so i knocked 
> a patch together since it was pretty simple.  for my own personal use, 
> i live in an operating system where i have tools to let me get this 
> from 'svn info', so i'll be happy doing:
> 
> $ svn info | grep ^[Url|Revision]

Well at least on Windows NT and later the tools are also available.
Not as nice as the Unix tools, but available. From the CMD prompt
see the help for SET, FOR and FINDSTR, you may be surprised at what's
hidden away in the CMD tools. (Shocked might be better then suprised
when you see the syntax!) I've not seen any docs accept the built in
help, so it hit or miss if someone find the features they have need.

The NT equivalent of your command is:

svn info | findstr "^Url ^Revision"

Maybe the solution is a FAQ entry.

Q: How do I get the URL from svn info for use in a windows batch file?

A1: svn info | findstr "^Url:"

A2: The commands will place the Url: value into the variable URL

-------------- url.cmd -----------------
@for /f "usebackq tokens=1, 2*" %%i in (`svn info`) do @if "%%i" == "Url:" @set URL=%%j
@echo The URL is %URL%
----------------------------------------

	BArry



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

Re: [PATCH] svn url command

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On Saturday, September 7, 2002, at 09:13 AM, Barry Scott wrote:

> I like the idea of being able to get selected parts of the info.
> But why limit the mechamism to just the url, why not provide access
> to the revision, last change author, etc?
>
> Which would mean that the svn url command is a poor choice for
> extension to the other info items.
>
> Why not extend the info command to show only the item requested?
>
> svn info --query url
> svn info --query revision
> svn info --query last-change-author

well, we can't do that because we've decided not to allow subcommand 
specific flags (for good reason, it complicates the user interface, see 
the mailing list archives for details).  off the top of my head, i 
can't think of a good way to design this interface without that...  
perhaps something like:

$ svn info -x 'url revision last-change-author' FOO

(perhaps -x is not correct...  that's what we use to pass flags to diff 
though, and this is /sort of/ similar...)

but then it just feels like we're /really/ trying to fake have 
subcommand specific flags...

anyway, i'd prefer not to get into a protracted discussion on this, 
since i don't personally have a huge need for this anyway.  i know that 
some of the windows people had wanted this functionality, so i knocked 
a patch together since it was pretty simple.  for my own personal use, 
i live in an operating system where i have tools to let me get this 
from 'svn info', so i'll be happy doing:

$ svn info | grep ^[Url|Revision]

;-)

-garrett

-- 
garrett rooney                    Remember, any design flaw you're
rooneg@electricjellyfish.net      sufficiently snide about becomes
http://electricjellyfish.net/     a feature.       -- Dan Sugalski


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

RE: [PATCH] svn url command

Posted by Barry Scott <ba...@ntlworld.com>.
I like the idea of being able to get selected parts of the info.
But why limit the mechamism to just the url, why not provide access
to the revision, last change author, etc?

Which would mean that the svn url command is a poor choice for
extension to the other info items.

Why not extend the info command to show only the item requested?

svn info --query url
svn info --query revision
svn info --query last-change-author

"Last changed author" is poor english, isn't "Last change author"
better?

		BArry

> -----Original Message-----
> From: Garrett Rooney [mailto:rooneg@electricjellyfish.net]
> Sent: 07 September 2002 03:30
> To: dev@subversion.tigris.org
> Subject: [PATCH] svn url command
>
>
> A while back, there was a discussion concerning how to get the url for
> a given versioned resource in the working copy.  The current way to do
> this is something like 'svn info FOO | grep ^Url', which is fine on
> UNIX, but is less than ideal on windows.  It also requires a fair
> amount of massaging of the data if one only wants the URL, and doesn't
> want the rest of the information printed out.
>
> One of the suggested solutions to the problem was an 'svn url' command.
>   I can't recall if there was a consensus on this or not, but on the off
> chance that we do want it, here's a patch that implements it.  If
> nobody objects, I'll commit it sometime tomorrow.
>
> -garrett
>
> (ok, i hope this doesn't come out mangled, since Mail.app seems to have
> some odd reactions to embedded ^L's, and I can't tell if this whole
> patch is here or not, but hey, let's roll the dice and see what
> happens...)
>
> Index: subversion/clients/cmdline/cl.h
> ===================================================================
> --- subversion/clients/cmdline/cl.h
> +++ subversion/clients/cmdline/cl.h	Fri Sep  6 21:38:25 2002
> @@ -141,7 +141,8 @@
>     svn_cl__resolve,
>     svn_cl__status,
>     svn_cl__switch,
> -  svn_cl__update;
> +  svn_cl__update,
> +  svn_cl__url;
>
>
>   /* Print a generic (non-command-specific) usage message. */
> Index: subversion/clients/cmdline/url-cmd.c
> ===================================================================
> --- subversion/clients/cmdline/url-cmd.c
> +++ subversion/clients/cmdline/url-cmd.c	Fri Sep  6 21:54:36 2002
> @@ -0,0 +1,76 @@
> +/*
> + * url-cmd.c -- Display a resource's url
> + *
> + * ====================================================================
> + * Copyright (c) 2000-2002 CollabNet.  All rights reserved.
> + *
> + * This software is licensed as described in the file COPYING, which
> + * you should have received as part of this distribution.  The terms
> + * are also available at http://subversion.tigris.org/license-1.html.
> + * If newer versions of this license are posted there, you may use a
> + * newer version instead, at your option.
> + *
> + * This software consists of voluntary contributions made by many
> + * individuals.  For exact contribution history, see the revision
> + * history and logs, available at http://subversion.tigris.org/.
> + * ====================================================================
> + */
> +
> +/*
> ==================================================================== */
> +
> +
> +>
> +/*** Includes. ***/
> +
> +#include "svn_wc.h"
> +#include "svn_error.h"
> +#include "svn_utf.h"
> +#include "cl.h"
> +
> +>
> +/*** Code. ***/
> +
> +svn_error_t *
> +svn_cl__url (apr_getopt_t *os,
> +             svn_cl__opt_state_t *opt_state,
> +             apr_pool_t *pool)
> +{
> +  apr_array_header_t *targets;
> +  const char *native;
> +  int i;
> +
> +  SVN_ERR (svn_cl__args_to_target_array (&targets, os, opt_state,
> +                                         FALSE, pool));
> +
> +  /* Add "." if user passed 0 arguments. */
> +  svn_cl__push_implicit_dot_target (targets, pool);
> +
> +  for (i = 0; i < targets->nelts; i++)
> +    {
> +      const char *target = ((const char **) (targets->elts))[i];
> +      svn_wc_entry_t *entry;
> +
> +      svn_wc_entry (&entry, target, FALSE, pool);
> +      if (! entry)
> +        {
> +          SVN_ERR (svn_utf_cstring_from_utf8 (&native, target, pool));
> +
> +          printf ("%s:  (Not a versioned resource)\n", native);
> +        }
> +      else if (entry->url)
> +        {
> +          SVN_ERR (svn_utf_cstring_from_utf8 (&native, entry->url,
> pool));
> +
> +          printf ("%s\n", native);
> +        }
> +    }
> +
> +  return SVN_NO_ERROR;
> +}
> +
> +>
> +/*
> + * local variables:
> + * eval: (load-file "../../../tools/dev/svn-dev.el")
> + * end:
> + */
> Index: subversion/clients/cmdline/main.c
> ===================================================================
> --- subversion/clients/cmdline/main.c
> +++ subversion/clients/cmdline/main.c	Fri Sep  6 21:43:06 2002
> @@ -423,6 +423,11 @@
>        svn_cl__auth_password_opt, svn_cl__no_auth_cache_opt,
>        svn_cl__xml_file_opt} },
>
> +  { "url", svn_cl__url, {0},
> +    "Display a resource's url.\n"
> +    "usage: url [PATH1 [PATH2 ...]\n",
> +    {0} },
> +
>     { NULL, NULL, {0}, NULL, {0} }
>   };
>
> Index:
> subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout
> ===================================================================
> --- subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout
> +++
> subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout	Fri
> Sep  6 22:14:02 2002
> @@ -33,6 +33,7 @@
>      status (stat, st)
>      switch (sw)
>      update (up)
> +   url
>
>   Subversion is a tool for revision control.
>   For additional information, see http://subversion.tigris.org
> Index:
> subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout
> ===================================================================
> --- subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout
> +++
> subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout	Fri
> Sep  6 22:14:21 2002
> @@ -33,6 +33,7 @@
>      status (stat, st)
>      switch (sw)
>      update (up)
> +   url
>
>   Subversion is a tool for revision control.
>   For additional information, see http://subversion.tigris.org
> Index: doc/handbook/client.texi
> ===================================================================
> --- doc/handbook/client.texi
> +++ doc/handbook/.svn/tmp/client.texi.63104.00001.tmp	Fri Sep  6
> 22:23:32 2002
> @@ -1745,6 +1745,19 @@
>   Again, this is a form of immediate commit, so some sort of log message
>   is required.
>
> +@subheading @samp{svn url}
> +
> +This is a convenience command which prints out the URL associated with
> +a given versioned resource.  This information is also available from
> the
> +@samp{svn info} command, but it is also provided here so that it can be
> +obtained in scripts without having to filter the output through some
> other
> +command.
> +
> +@example
> +$ svn url README
> +http://svn.collab.net/repos/svn/trunk/README
> +@end example
> +
>
>   @c ------------------------------------------------------------------
>   @node Run-time Configuration
>
> --
> garrett rooney                    Remember, any design flaw you're
> rooneg@electricjellyfish.net      sufficiently snide about becomes
> http://electricjellyfish.net/     a feature.       -- Dan Sugalski
>
> ---------------------------------------------------------------------
> 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