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
Received on Sat Sep 7 04:30:31 2002