You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by mark benedetto king <bk...@inquira.com> on 2002/09/18 17:54:35 UTC

[PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

New subcommand: "relocate".  Useful for when the URL by which the
repository must be referred to has changed.  This happens most
frequently for mobile users.

* subversion/include/svn_wc.h
  (svn_wc_relocate): Prototype for new function.

* subversion/include/svn_client.h
  (svn_client_relocate): Prototype for new function.

* subversion/libsvn_wc/relocate.c
  New file.  Includes implementation of svn_wc_relocate().

* subversion/libsvn_client/relocate.c
  New file.  Includes implementation of svn_client_relocate().

* subversion/clients/cmdline/cl.h
  (svn_cl__relocate): Added subcommand prototype.  Fixed
  alphabetical-order of resolve/revert.

* subversion/clients/cmdline/relocate-cmd.c
  New file.  Includes implementation of svn_cl__relocate().

* subversion/clients/cmdline/main.c
  (svn_cl__cmd_table): Added entry for "relocate".


Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h
+++ subversion/include/svn_wc.h	Wed Sep 18 13:43:59 2002
@@ -1424,6 +1424,19 @@
                 svn_wc_adm_access_t *optional_adm_access,
                 apr_pool_t *pool);
 
+/* Recurse from PATH, changing repository references that begin with
+   FROM to begin with TO instead.  Perform necessary allocations in
+   POOL. 
+
+   ADM_ACCESS is an access baton for the directory containing
+   PATH. ADM_ACCESS can be NULL in which case the function will open and
+   close acess batons as required. */
+svn_error_t *
+svn_wc_relocate (const char *path,
+                 svn_wc_adm_access_t *adm_access,
+                 const char *from,
+                 const char *to,
+                 apr_pool_t *pool);
 
 /* Revert changes to PATH (perhaps in a RECURSIVE fashion).  Perform
    necessary allocations in POOL.
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h
+++ subversion/include/svn_client.h	Wed Sep 18 12:23:17 2002
@@ -684,6 +684,15 @@
                     apr_pool_t *pool);
 
 
+/* Recursively modify a working copy directory DIR, changing any
+   repository URLs that begin with FROM to begin with TO instead. */
+svn_error_t *
+svn_client_relocate (const char *dir,
+                     const char *from,
+                     const char *to,
+                     apr_pool_t *pool);
+
+
 /* Restore the pristine version of a working copy PATH, effectively
    undoing any local mods.  If PATH is a directory, and RECURSIVE is
    TRUE, this will be a recursive operation.
Index: subversion/libsvn_wc/relocate.c
===================================================================
--- subversion/libsvn_wc/relocate.c
+++ subversion/libsvn_wc/relocate.c	Wed Sep 18 13:42:54 2002
@@ -0,0 +1,101 @@
+/*
+ * relocate.c: do wc repos relocation
+ *
+ * ====================================================================
+ * 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/.
+ * ====================================================================
+ */
+
+
+
+#include "svn_wc.h"
+#include "svn_error.h"
+#include "svn_string.h"
+#include "svn_xml.h"
+#include "svn_pools.h"
+#include "svn_io.h"
+
+#include "wc.h"
+#include "entries.h"
+
+
+svn_error_t *
+svn_wc_relocate (const char *path,
+                 svn_wc_adm_access_t *adm_access,
+                 const char *from,
+                 const char *to,
+                 apr_pool_t *pool)
+{
+  apr_hash_t *entries = NULL;
+  apr_hash_index_t *hi;
+  enum svn_node_kind kind;
+  int is_wc;
+  int from_len;
+
+  svn_boolean_t root = FALSE;
+
+
+  SVN_ERR (svn_wc_check_wc (path, &is_wc, pool));
+  if (! is_wc)
+    return svn_error_createf
+      (SVN_ERR_WC_NOT_DIRECTORY, 0, NULL, pool,
+       "svn_wc_cleanup: %s is not a working copy directory", path);
+
+  if (! adm_access)
+    {
+      SVN_ERR (svn_wc_adm_open (&adm_access, NULL, path, TRUE, TRUE, pool));
+      root = TRUE;
+    }
+
+  from_len = strlen(from);
+
+  SVN_ERR (svn_wc_entries_read (&entries, path, FALSE, pool));
+
+  for (hi = apr_hash_first (pool, entries); hi; hi = apr_hash_next (hi))
+    {
+      const void *key;
+      void *val;
+      svn_wc_entry_t *entry;
+
+      apr_hash_this (hi, &key, NULL, &val);
+      entry = val;
+
+      if ((entry->kind == svn_node_dir)
+          && (strcmp (key, SVN_WC_ENTRY_THIS_DIR) != 0))
+        {
+          /* Recurse */
+          const char *subdir = svn_path_join (path, key, pool);
+          SVN_ERR (svn_wc_relocate (subdir, adm_access, from, to, pool));
+        }
+     
+      if (entry->url &&
+          (strncmp(entry->url, from, from_len) == 0))
+          entry->url = apr_psprintf (pool, "%s%s", to, entry->url + from_len);
+    }
+
+  SVN_ERR (svn_wc__entries_write (entries, path, pool));
+
+  if (root)
+    svn_wc_adm_close(adm_access);
+
+  return SVN_NO_ERROR;
+}
+
+
+
+/* 
+ * local variables:
+ * eval: (load-file "../../tools/dev/svn-dev.el")
+ * end:
+ */
+
Index: subversion/libsvn_client/relocate.c
===================================================================
--- subversion/libsvn_client/relocate.c
+++ subversion/libsvn_client/relocate.c	Wed Sep 18 13:44:22 2002
@@ -0,0 +1,59 @@
+/*
+ * relocate.c:  wrapper around wc relocation functionality.
+ *
+ * ====================================================================
+ * 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_client.h"
+#include "svn_string.h"
+#include "svn_pools.h"
+#include "svn_error.h"
+#include "svn_path.h"
+#include "client.h"
+
+
+
+/*** Code. ***/
+
+svn_error_t *
+svn_client_relocate (const char *dir,
+                     const char *from,
+                     const char *to,
+                     apr_pool_t *pool)
+{
+  enum svn_node_kind kind;
+
+  SVN_ERR (svn_io_check_path (dir, &kind, pool));
+  if (kind != svn_node_dir)
+    return svn_error_createf (SVN_ERR_WC_NOT_DIRECTORY, 0, NULL, pool,
+                              "Cannot relocate '%s' -- not a directory", 
+                              dir);
+
+  return svn_wc_relocate (dir, NULL, from, to, pool);
+}
+
+
+
+/* 
+ * local variables:
+ * eval: (load-file "../../tools/dev/svn-dev.el")
+ * end: */
Index: subversion/clients/cmdline/cl.h
===================================================================
--- subversion/clients/cmdline/cl.h
+++ subversion/clients/cmdline/cl.h	Wed Sep 18 13:51:47 2002
@@ -137,8 +137,9 @@
   svn_cl__propget,
   svn_cl__proplist,
   svn_cl__propset,
-  svn_cl__revert,
+  svn_cl__relocate,
   svn_cl__resolve,
+  svn_cl__revert,
   svn_cl__status,
   svn_cl__switch,
   svn_cl__update;
Index: subversion/clients/cmdline/relocate-cmd.c
===================================================================
--- subversion/clients/cmdline/relocate-cmd.c
+++ subversion/clients/cmdline/relocate-cmd.c	Wed Sep 18 13:22:52 2002
@@ -0,0 +1,82 @@
+/*
+ * relocate-cmd.c -- Subversion relocate command
+ *
+ * ====================================================================
+ * 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_client.h"
+#include "svn_string.h"
+#include "svn_path.h"
+#include "svn_pools.h"
+#include "svn_error.h"
+#include "cl.h"
+
+
+
+/*** Code. ***/
+
+svn_error_t *
+svn_cl__relocate (apr_getopt_t *os,
+                  svn_cl__opt_state_t *opt_state,
+                  apr_pool_t *pool)
+{
+  apr_array_header_t *targets;
+  apr_pool_t *subpool;
+  const char *from;
+  const char *to;
+  int i;
+
+  SVN_ERR (svn_cl__args_to_target_array (&targets, os, opt_state, 
+                                         FALSE, pool));
+
+  if (targets->nelts < 2)
+    return svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, 0, 0, pool, "");
+
+  from = ((const char **) (targets->elts))[0];
+  to = ((const char **) (targets->elts))[1];
+
+  subpool = svn_pool_create (pool);
+
+  if (targets->nelts == 2)
+    {
+      SVN_ERR(svn_client_relocate ("", from, to, pool));
+    }
+  else 
+    {
+      for (i = 2; i < targets->nelts; i++)
+        {
+          const char *target = ((const char **) (targets->elts))[i];
+          SVN_ERR (svn_client_relocate (target, from, to, subpool));
+          svn_pool_clear (subpool);
+        }
+    }
+
+  svn_pool_destroy (subpool);
+  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	Wed Sep 18 13:09:48 2002
@@ -353,6 +353,12 @@
     "           foo/bar -r1234 http://example.com/repos/zag\n",
     {'F', 'q', svn_cl__targets_opt, 'R'} },
   
+  { "relocate", svn_cl__relocate, {0},
+    "Recursively change the TARGET working copies' internal URLs, replacing\n"
+    " all URLs that begin with FROM to begin with TO, instead.\n"
+    "usage: svn relocate [FROM] [TO] [TARGETS ...]\n",
+    {0} },
+
   { "revert", svn_cl__revert, {0},
     "Restore pristine working copy file (undo all local edits)\n"
     "usage: revert TARGET1 [TARGET2 [TARGET3 ... ]]\n\n"

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Tom Tromey <tr...@redhat.com>.
[ Warning: lurker post ]

>> If this is a rare operation, perhaps it could exist as an obscure flag
>> to the svn switch command.

Karl> I think people will have to do it often enough that it's worth
Karl> supporting directly.  CVS doesn't have this command, and the result is
Karl> that it gets independently reinvented as a script all the time, with
Karl> predictably inconsistent quality.

I use `cvschroot', part of one of the two cvsutils packages (one by
Alexandre Oliva and one by Pavel Roskin).  I've used it more than a
few times.  So, this does happen.

If you've never looked at cvsutils (or cvs-utils, the other one :-),
it is worth doing.  They both provide useful functionality that
complements cvs, and I use utilities from both packages every day.

It's always been my hope that subversion, eventually, would eliminate
the need for add-on packages, especially packages that exist just to
fill in little holes which cvs has left.

One of those projects is on red-bean.com.  The other is on
subversions.gnu.org.

Tom

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Justin Erenkrantz <je...@apache.org>.
On Fri, Sep 20, 2002 at 02:00:33PM -0400, Greg Hudson wrote:
>   * What exactly is the use case for this operation?  It sounds like it

% grep "url" .svn/entries 
   url="http://svn.collab.net/repos/svn/trunk"
% svn relocate https://svn.collab.net/repos/svn/trunk

So, when can we commit this so I can switch over to the SSL
server?  =)  -- justin

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
mark benedetto king <bk...@Inquira.Com> writes:
> So, does it make sense to (trivially) alter my previous patch to
> trigger the relocate functionality as an option to switch rather than
> a specific subcommand, or is the idea to reuse a large portion of
> the svn_client_switch() functionality?

I'm not sure; which results in the smallest/cleanest change from the
current code base?  (I'd be surprised if reusing svn_client_switch
code were it, but maybe with a refactoring...)

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by mark benedetto king <bk...@inquira.com>.
On Sun, Sep 22, 2002 at 11:06:58PM -0500, Karl Fogel wrote:
> Nuutti Kotivuori <na...@iki.fi> writes:
> > You are right, it does sound like a flag - I'm happy with a flag.
> 
> Me too.
> 

So, does it make sense to (trivially) alter my previous patch to
trigger the relocate functionality as an option to switch rather than
a specific subcommand, or is the idea to reuse a large portion of
the svn_client_switch() functionality?

--ben


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Nuutti Kotivuori <na...@iki.fi> writes:
> You are right, it does sound like a flag - I'm happy with a flag.

Me too.

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Nuutti Kotivuori <na...@iki.fi>.
Greg Hudson wrote:
> On Fri, 2002-09-20 at 19:03, Nuutti Kotivuori wrote:
>> Though ofcourse I won't care one bit if it's 'svn relocate http://'
>> or 'svn switch --really-only-rewrite-the-damn-urls http://' (even
>> though it has very little to do with 'svn switch' semantics).
> 
> After thinking about this, I don't agree that relocate has very
> little to do with "svn switch" semantics, actually.  The result of
> "svn relocate" is exactly the same as the result of "svn switch"
> when there are no content differences between the old repository
> location/version and the new one.  The only problem is that the old
> repository is presumed inaccessible, so instead of going and
> fetching the differences and doing an update, the user wants to
> assert that there are no changes.  That sounds like a flag, to me.

Well I'm just repeating what other have said to me like a
parrot. "Switch is like update, update is a subset of
switch". "Switching and updating both consist of comparing differences
between revisions and applying changes to the working copy".

You are right, it does sound like a flag - I'm happy with a flag.

-- Naked


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Greg Hudson <gh...@MIT.EDU>.
On Fri, 2002-09-20 at 19:03, Nuutti Kotivuori wrote:
> Though ofcourse I won't care one bit if it's 'svn relocate http://' or
> 'svn switch --really-only-rewrite-the-damn-urls http://' (even though
> it has very little to do with 'svn switch' semantics).

After thinking about this, I don't agree that relocate has very little
to do with "svn switch" semantics, actually.  The result of "svn
relocate" is exactly the same as the result of "svn switch" when there
are no content differences between the old repository location/version
and the new one.  The only problem is that the old repository is
presumed inaccessible, so instead of going and fetching the differences
and doing an update, the user wants to assert that there are no
changes.  That sounds like a flag, to me.


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Nuutti Kotivuori <na...@iki.fi>.
Greg Hudson wrote:
> On Fri, 2002-09-20 at 12:50, Karl Fogel wrote:
>> The trouble is that it's not really related to switch at all.  They
>> both affect URLs, but that's about it.  Semantically, they are very
>> different operations.  (Not sure what the "in this area" meant.)
> 
> "This area" would be manipulations of the wc-repository
> relationship. update, merge, and switch are in the same area.
> 
> Here are my other concerns:
> 
>   * "Frob the repository URL in the WC" is a very low-level
> description of what relocate does.  How is a tutorial supposed to
> explain the relocate operation to a user who doesn't understand how
> Subversion works at that level?

How about "Change the repository URL in the WC"? Maybe with an
addendum note of "This command only changes the repository URL and
does not use the network."

That doesn't sound too low-level to me. It's what I'd go look for when
I get a mail saying that the repository just changed it's location -
with CVS start writing a perl script to do the job in my working
copies.

>   * What exactly is the use case for this operation?  It sounds like
> it is only supposed to work when you have two repository areas with
> identical contents, but how are you expected to maintain the
> equality of two repository areas?  Is "svn relocate" part of some
> hackish, interim form of distributed operation?  Will it become
> vestigial if we come up with a more elegant framework for that?

"When your repository URL has changed, you can use this command to
make your working copy point to the new URL." That's enough use case
for me.

I've had to use that twice already. Once when I had a portforwarding
setup set up at work when I couldn't use the proxy and then finally
got the proxy working. And the second time was when my external server
changed it's dns name from cs183115.pp.htv.fi to aka.pp.htv.fi - and I
was using SSL for my connections.

In both cases, I had to do 'svn diff > ../safeplace; cd ..; rm -rf wc;
svn co http//...; cd wc; patch < ../safeplace' That sucked.

In a perfect world, every repository is named 'repos.intra.foo.com'
which they can fix to be the repository every time. In the real world,
things like port-forwarding exist, and rewriting urls is what I need.

Though ofcourse I won't care one bit if it's 'svn relocate http://' or
'svn switch --really-only-rewrite-the-damn-urls http://' (even though
it has very little to do with 'svn switch' semantics).

-- Naked

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by mark benedetto king <bk...@inquira.com>.
On Fri, Sep 20, 2002 at 02:30:40PM -0400, Greg Hudson wrote:
> > Use cases are good ones.  Think about a developer with a laptop (like
> > myself) who has to hit a repository via two different URLs depending
> > on where his net connection is
> 
> This case seems better handled at the DNS layer, honestly.
> 

It would be, if the only thing to change were DNS.  Unfortunately
for me, the port number also changes when I move from home to work.

Unless by DNS you meant "DNS SVC records". :-)

It's even conceivable that the non-host-components of the URL
could differ; perhaps through an eternal interface one would use

    http://firewall.foo.com/codebase/repos

Where the firewall internally forwards /codebase/(.*) to
http://codebase.foo.com/$1


--ben



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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Greg Hudson <gh...@MIT.EDU>.
On Fri, 2002-09-20 at 14:48, Julian Fitzell wrote:
> >>Use cases are good ones.  Think about a developer with a laptop (like
> >>myself) who has to hit a repository via two different URLs depending
> >>on where his net connection is
> > 
> > 
> > This case seems better handled at the DNS layer, honestly.
> 
> I don't understand how it can be... how would DNS solve either of the 
> two use cases?

When I first wrote my response, there was only one use case mentioned so
far.  Now there are three (http to https, moving a repository, and
different URLs for different net connections), but two of them should
happen rarely in the course of any given user's work.

I was talking about the third case.  Having to use a different hostname
to access the same machine from two different sides of a firewall
doesn't seem right to me; it seems that your DNS server should give an
accessible IP address for a given name regardless of where a client
comes from.


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Julian Fitzell <ju...@beta4.com>.
Greg Hudson wrote:
> On Fri, 2002-09-20 at 14:15, cmpilato@collab.net wrote:
> 
>>I echo this concern, though perhaps more like a bathroom's echo than a
>>canyon's.  :-) As an obscure feature, I imagine it will likely only be
>>used by folks who can understand that level of how Subversion works.
> 
> 
> The problem with giving command names to obscure features is that they
> take up just as much room in "svn help" as the non-obscure commands.  I
> really don't want to see us go the way of Bitkeeper here.
> 
> 
>>Use cases are good ones.  Think about a developer with a laptop (like
>>myself) who has to hit a repository via two different URLs depending
>>on where his net connection is
> 
> 
> This case seems better handled at the DNS layer, honestly.

I don't understand how it can be... how would DNS solve either of the 
two use cases?

If you have to change the name of a repository it is presumably because 
you don't want to use the old one for some reason.  How does DNS help 
you solve that?  If you have access a different host name from inside 
your firewall than outside (or even a different port) how dose DNS help 
you solve that?  What about if your sysadmin reorgs the server and you 
have to use a different URL to the repository?  Yes in all but the first 
case you could maybe do a clean checkout but if you don't have too...

> I remain -0 on this command, though others are free to override that, of
> course.

I haven't formed a strong opinion either way, but I do think the 
functionality is nice to have and I don't understand how DNS helps any.

Julian

-- 
julian@beta4.com
Beta4 Productions (http://www.beta4.com)


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Greg Hudson <gh...@MIT.EDU>.
On Fri, 2002-09-20 at 14:15, cmpilato@collab.net wrote:
> I echo this concern, though perhaps more like a bathroom's echo than a
> canyon's.  :-) As an obscure feature, I imagine it will likely only be
> used by folks who can understand that level of how Subversion works.

The problem with giving command names to obscure features is that they
take up just as much room in "svn help" as the non-obscure commands.  I
really don't want to see us go the way of Bitkeeper here.

> Use cases are good ones.  Think about a developer with a laptop (like
> myself) who has to hit a repository via two different URLs depending
> on where his net connection is

This case seems better handled at the DNS layer, honestly.

I remain -0 on this command, though others are free to override that, of
course.


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Josef Wolf <jw...@raven.inka.de>.
On Fri, Sep 20, 2002 at 01:15:06PM -0500, cmpilato@collab.net wrote:

> Use cases are good ones.  Think about a developer with a laptop (like
> myself) who has to hit a repository via two different URLs depending
> on where his net connection is (inside the company firewall vs. at
> home or something).

But don't you find it very annoying to change the repos-root every
day manually? Wouldn't it be better to have some file in the .svn
directory that contains URL-prefixes which would be tried automatically?

IMHO, such an approach would be very easy to explain to the unintended
user: "just put all the FQNDs and the appropriate paths of your repo
into this file". 

-- 
-- Josef Wolf -- jw@raven.inka.de --

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by cm...@collab.net.
Greg Hudson <gh...@MIT.EDU> writes:

> Here are my other concerns:
> 
>   * "Frob the repository URL in the WC" is a very low-level description
> of what relocate does.  How is a tutorial supposed to explain the
> relocate operation to a user who doesn't understand how Subversion works
> at that level?

I echo this concern, though perhaps more like a bathroom's echo than a
canyon's.  :-) As an obscure feature, I imagine it will likely only be
used by folks who can understand that level of how Subversion works.

>   * What exactly is the use case for this operation?  It sounds like it
> is only supposed to work when you have two repository areas with
> identical contents, but how are you expected to maintain the equality of
> two repository areas?  Is "svn relocate" part of some hackish, interim
> form of distributed operation?  Will it become vestigial if we come up
> with a more elegant framework for that?

Use cases are good ones.  Think about a developer with a laptop (like
myself) who has to hit a repository via two different URLs depending
on where his net connection is (inside the company firewall vs. at
home or something).  Others include cases where a repos admin needs to
change the canonical URL of a repos for some reason, but this is
probably rare and a fresh checkout certainly can't hurt *that* much.


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Kevin Pilch-Bisson <ke...@pilch-bisson.net>.
Quoting Greg Hudson <gh...@MIT.EDU>:

> On Fri, 2002-09-20 at 12:50, Karl Fogel wrote:
> > The trouble is that it's not really related to switch at all.  They
> > both affect URLs, but that's about it.  Semantically, they are very
> > different operations.  (Not sure what the "in this area" meant.)
> 
> "This area" would be manipulations of the wc-repository relationship. 
> update, merge, and switch are in the same area.
> 
> Here are my other concerns:
> 
>   * "Frob the repository URL in the WC" is a very low-level description
> of what relocate does.  How is a tutorial supposed to explain the
> relocate operation to a user who doesn't understand how Subversion works
> at that level?

Agreed.
> 
>   * What exactly is the use case for this operation?  It sounds like it
> is only supposed to work when you have two repository areas with
> identical contents, but how are you expected to maintain the equality of
> two repository areas?  Is "svn relocate" part of some hackish, interim
> form of distributed operation?  Will it become vestigial if we come up
> with a more elegant framework for that?
> 

The actual use case is more like one repository is available on two different 
networks by different names, and the users machine sometimes migrates between 
those networks.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson
kevin@pilch-bisson.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Greg Hudson <gh...@MIT.EDU>.
On Fri, 2002-09-20 at 12:50, Karl Fogel wrote:
> The trouble is that it's not really related to switch at all.  They
> both affect URLs, but that's about it.  Semantically, they are very
> different operations.  (Not sure what the "in this area" meant.)

"This area" would be manipulations of the wc-repository relationship. 
update, merge, and switch are in the same area.

Here are my other concerns:

  * "Frob the repository URL in the WC" is a very low-level description
of what relocate does.  How is a tutorial supposed to explain the
relocate operation to a user who doesn't understand how Subversion works
at that level?

  * What exactly is the use case for this operation?  It sounds like it
is only supposed to work when you have two repository areas with
identical contents, but how are you expected to maintain the equality of
two repository areas?  Is "svn relocate" part of some hackish, interim
form of distributed operation?  Will it become vestigial if we come up
with a more elegant framework for that?


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Greg Hudson <gh...@MIT.EDU> writes:
> I am -0 on this idea.  (Sorry to speak up after the implementation and
> not before.)  I think it starts to bring our operation count in this
> area into the confusing range.  Having "svn switch" is already a bit
> foreign to CVS users; having a relocate as well make the situation much
> worse.
> 
> If this is a rare operation, perhaps it could exist as an obscure flag
> to the svn switch command.

The trouble is that it's not really related to switch at all.  They
both affect URLs, but that's about it.  Semantically, they are very
different operations.  (Not sure what the "in this area" meant.)

I think people will have to do it often enough that it's worth
supporting directly.  CVS doesn't have this command, and the result is
that it gets independently reinvented as a script all the time, with
predictably inconsistent quality.

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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Greg Hudson <gh...@MIT.EDU>.
On Wed, 2002-09-18 at 13:54, mark benedetto king wrote:
> New subcommand: "relocate".  Useful for when the URL by which the
> repository must be referred to has changed.  This happens most
> frequently for mobile users.

I am -0 on this idea.  (Sorry to speak up after the implementation and
not before.)  I think it starts to bring our operation count in this
area into the confusing range.  Having "svn switch" is already a bit
foreign to CVS users; having a relocate as well make the situation much
worse.

If this is a rare operation, perhaps it could exist as an obscure flag
to the svn switch command.


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

Re: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Blair Zajac <bl...@orcaware.com>.
mark benedetto king wrote:
> 
> New subcommand: "relocate".  Useful for when the URL by which the
> repository must be referred to has changed.  This happens most
> frequently for mobile users.

Mark,

You may want to run make test on this patch.  I'm guessing that
the getopt test will fail since this new command is listed in
svn help's output.

Best,
Blair

-- 
Blair Zajac <bl...@orcaware.com>
Web and OS performance plots - http://www.orcaware.com/orca/

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

[PATCH] [updated] implement "svn relocate"

Posted by mark benedetto king <bk...@inquira.com>.
Updated patch reflects Blair Zajac's suggestion that
the getopt tests would fail unless they were updated.



New subcommand: "relocate".  Useful for when the URL by which the
repository must be referred to has changed.  This happens most
frequently for mobile users.  

* subversion/include/svn_wc.h
  (svn_wc_relocate): Prototype for new function.

* subversion/include/svn_client.h
  (svn_client_relocate): Prototype for new function.

* subversion/libsvn_wc/relocate.c
  New file.  Includes implementation of svn_wc_relocate().

* subversion/libsvn_client/relocate.c
  New file.  Includes implementation of svn_client_relocate().

* subversion/clients/cmdline/cl.h
  (svn_cl__relocate): Added subcommand prototype.  Fixed
  alphabetical-order of resolve/revert.

* subversion/clients/cmdline/relocate-cmd.c
  New file.  Includes implementation of svn_cl__relocate().

* subversion/clients/cmdline/main.c
  (svn_cl__cmd_table): Added entry for "relocate".

* subversion/tests/clients/cmdline/getopt_tests_data/svn--help_stdout
  Update expected output from "svn --help" to reflect new subcommand.
  Thanks to Blair Zajac for suggesting this.

* subversion/tests/clients/cmdline/getopt_tests_data/svn_help_stdout
  Update expected output from "svn help" to reflect new subcommand.
  Thanks to Blair Zajac for suggesting this.


Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h
+++ subversion/include/svn_wc.h	Wed Sep 18 13:43:59 2002
@@ -1424,6 +1424,19 @@
                 svn_wc_adm_access_t *optional_adm_access,
                 apr_pool_t *pool);
 
+/* Recurse from PATH, changing repository references that begin with
+   FROM to begin with TO instead.  Perform necessary allocations in
+   POOL. 
+
+   ADM_ACCESS is an access baton for the directory containing
+   PATH. ADM_ACCESS can be NULL in which case the function will open and
+   close acess batons as required. */
+svn_error_t *
+svn_wc_relocate (const char *path,
+                 svn_wc_adm_access_t *adm_access,
+                 const char *from,
+                 const char *to,
+                 apr_pool_t *pool);
 
 /* Revert changes to PATH (perhaps in a RECURSIVE fashion).  Perform
    necessary allocations in POOL.
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h
+++ subversion/include/svn_client.h	Wed Sep 18 12:23:17 2002
@@ -684,6 +684,15 @@
                     apr_pool_t *pool);
 
 
+/* Recursively modify a working copy directory DIR, changing any
+   repository URLs that begin with FROM to begin with TO instead. */
+svn_error_t *
+svn_client_relocate (const char *dir,
+                     const char *from,
+                     const char *to,
+                     apr_pool_t *pool);
+
+
 /* Restore the pristine version of a working copy PATH, effectively
    undoing any local mods.  If PATH is a directory, and RECURSIVE is
    TRUE, this will be a recursive operation.
Index: subversion/libsvn_wc/relocate.c
===================================================================
--- subversion/libsvn_wc/relocate.c
+++ subversion/libsvn_wc/relocate.c	Wed Sep 18 13:42:54 2002
@@ -0,0 +1,101 @@
+/*
+ * relocate.c: do wc repos relocation
+ *
+ * ====================================================================
+ * 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/.
+ * ====================================================================
+ */
+
+
+
+#include "svn_wc.h"
+#include "svn_error.h"
+#include "svn_string.h"
+#include "svn_xml.h"
+#include "svn_pools.h"
+#include "svn_io.h"
+
+#include "wc.h"
+#include "entries.h"
+
+
+svn_error_t *
+svn_wc_relocate (const char *path,
+                 svn_wc_adm_access_t *adm_access,
+                 const char *from,
+                 const char *to,
+                 apr_pool_t *pool)
+{
+  apr_hash_t *entries = NULL;
+  apr_hash_index_t *hi;
+  enum svn_node_kind kind;
+  int is_wc;
+  int from_len;
+
+  svn_boolean_t root = FALSE;
+
+
+  SVN_ERR (svn_wc_check_wc (path, &is_wc, pool));
+  if (! is_wc)
+    return svn_error_createf
+      (SVN_ERR_WC_NOT_DIRECTORY, 0, NULL, pool,
+       "svn_wc_cleanup: %s is not a working copy directory", path);
+
+  if (! adm_access)
+    {
+      SVN_ERR (svn_wc_adm_open (&adm_access, NULL, path, TRUE, TRUE, pool));
+      root = TRUE;
+    }
+
+  from_len = strlen(from);
+
+  SVN_ERR (svn_wc_entries_read (&entries, path, FALSE, pool));
+
+  for (hi = apr_hash_first (pool, entries); hi; hi = apr_hash_next (hi))
+    {
+      const void *key;
+      void *val;
+      svn_wc_entry_t *entry;
+
+      apr_hash_this (hi, &key, NULL, &val);
+      entry = val;
+
+      if ((entry->kind == svn_node_dir)
+          && (strcmp (key, SVN_WC_ENTRY_THIS_DIR) != 0))
+        {
+          /* Recurse */
+          const char *subdir = svn_path_join (path, key, pool);
+          SVN_ERR (svn_wc_relocate (subdir, adm_access, from, to, pool));
+        }
+     
+      if (entry->url &&
+          (strncmp(entry->url, from, from_len) == 0))
+          entry->url = apr_psprintf (pool, "%s%s", to, entry->url + from_len);
+    }
+
+  SVN_ERR (svn_wc__entries_write (entries, path, pool));
+
+  if (root)
+    svn_wc_adm_close(adm_access);
+
+  return SVN_NO_ERROR;
+}
+
+
+
+/* 
+ * local variables:
+ * eval: (load-file "../../tools/dev/svn-dev.el")
+ * end:
+ */
+
Index: subversion/libsvn_client/relocate.c
===================================================================
--- subversion/libsvn_client/relocate.c
+++ subversion/libsvn_client/relocate.c	Wed Sep 18 13:44:22 2002
@@ -0,0 +1,59 @@
+/*
+ * relocate.c:  wrapper around wc relocation functionality.
+ *
+ * ====================================================================
+ * 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_client.h"
+#include "svn_string.h"
+#include "svn_pools.h"
+#include "svn_error.h"
+#include "svn_path.h"
+#include "client.h"
+
+
+
+/*** Code. ***/
+
+svn_error_t *
+svn_client_relocate (const char *dir,
+                     const char *from,
+                     const char *to,
+                     apr_pool_t *pool)
+{
+  enum svn_node_kind kind;
+
+  SVN_ERR (svn_io_check_path (dir, &kind, pool));
+  if (kind != svn_node_dir)
+    return svn_error_createf (SVN_ERR_WC_NOT_DIRECTORY, 0, NULL, pool,
+                              "Cannot relocate '%s' -- not a directory", 
+                              dir);
+
+  return svn_wc_relocate (dir, NULL, from, to, pool);
+}
+
+
+
+/* 
+ * local variables:
+ * eval: (load-file "../../tools/dev/svn-dev.el")
+ * end: */
Index: subversion/clients/cmdline/cl.h
===================================================================
--- subversion/clients/cmdline/cl.h
+++ subversion/clients/cmdline/cl.h	Wed Sep 18 13:51:47 2002
@@ -137,8 +137,9 @@
   svn_cl__propget,
   svn_cl__proplist,
   svn_cl__propset,
-  svn_cl__revert,
+  svn_cl__relocate,
   svn_cl__resolve,
+  svn_cl__revert,
   svn_cl__status,
   svn_cl__switch,
   svn_cl__update;
Index: subversion/clients/cmdline/relocate-cmd.c
===================================================================
--- subversion/clients/cmdline/relocate-cmd.c
+++ subversion/clients/cmdline/relocate-cmd.c	Wed Sep 18 13:22:52 2002
@@ -0,0 +1,82 @@
+/*
+ * relocate-cmd.c -- Subversion relocate command
+ *
+ * ====================================================================
+ * 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_client.h"
+#include "svn_string.h"
+#include "svn_path.h"
+#include "svn_pools.h"
+#include "svn_error.h"
+#include "cl.h"
+
+
+
+/*** Code. ***/
+
+svn_error_t *
+svn_cl__relocate (apr_getopt_t *os,
+                  svn_cl__opt_state_t *opt_state,
+                  apr_pool_t *pool)
+{
+  apr_array_header_t *targets;
+  apr_pool_t *subpool;
+  const char *from;
+  const char *to;
+  int i;
+
+  SVN_ERR (svn_cl__args_to_target_array (&targets, os, opt_state, 
+                                         FALSE, pool));
+
+  if (targets->nelts < 2)
+    return svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, 0, 0, pool, "");
+
+  from = ((const char **) (targets->elts))[0];
+  to = ((const char **) (targets->elts))[1];
+
+  subpool = svn_pool_create (pool);
+
+  if (targets->nelts == 2)
+    {
+      SVN_ERR(svn_client_relocate ("", from, to, pool));
+    }
+  else 
+    {
+      for (i = 2; i < targets->nelts; i++)
+        {
+          const char *target = ((const char **) (targets->elts))[i];
+          SVN_ERR (svn_client_relocate (target, from, to, subpool));
+          svn_pool_clear (subpool);
+        }
+    }
+
+  svn_pool_destroy (subpool);
+  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	Wed Sep 18 13:09:48 2002
@@ -353,6 +353,12 @@
     "           foo/bar -r1234 http://example.com/repos/zag\n",
     {'F', 'q', svn_cl__targets_opt, 'R'} },
   
+  { "relocate", svn_cl__relocate, {0},
+    "Recursively change the TARGET working copies' internal URLs, replacing\n"
+    " all URLs that begin with FROM to begin with TO, instead.\n"
+    "usage: svn relocate [FROM] [TO] [TARGETS ...]\n",
+    {0} },
+
   { "revert", svn_cl__revert, {0},
     "Restore pristine working copy file (undo all local edits)\n"
     "usage: revert TARGET1 [TARGET2 [TARGET3 ... ]]\n\n"
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	Wed Sep 18 14:44:47 2002
@@ -28,6 +28,7 @@
    propget (pget, pg)
    proplist (plist, pl)
    propset (pset, ps)
+   relocate
    revert
    resolve
    status (stat, st)
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	Wed Sep 18 14:45:03 2002
@@ -28,6 +28,7 @@
    propget (pget, pg)
    proplist (plist, pl)
    propset (pset, ps)
+   relocate
    revert
    resolve
    status (stat, st)

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

RE: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Sander Striker <st...@apache.org>.
> From: Sander Striker [mailto:striker@apache.org]
> Sent: 18 September 2002 20:31

> -1 on this patch.  The switch command should be able to handle
> the use case for this new subcommand just fine (in a safer
> way).

Ok, replying to my own post.  After some discussion on IRC it
became apparent that switch isn't able to do the job of rewriting
the urls of a wc without updating.  And so we need this new
functionality.  Therefor I revoke my -1.  But, in it's current
form this patch is way too dangerous.  We need to at least
do some checking of the new url to see if the new url indeed
is the location of the repository the wc points to.  This implies
we need to check the checksums on files (or compare the repository
GUIDs ;)


Sander


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

RE: [PATCH] implement "svn relocate", a subcommand for frobbing the wc's urls.

Posted by Sander Striker <st...@apache.org>.
-1 on this patch.  The switch command should be able to handle
the use case for this new subcommand just fine (in a safer
way).

Sander

> -----Original Message-----
> From: mark benedetto king [mailto:bking@inquira.com]
> Sent: 18 September 2002 19:55
> To: dev@subversion.tigris.org
> Subject: [PATCH] implement "svn relocate", a subcommand for frobbing the
> wc's urls.
> 
> 
> New subcommand: "relocate".  Useful for when the URL by which the
> repository must be referred to has changed.  This happens most
> frequently for mobile users.
> 
> * subversion/include/svn_wc.h
>   (svn_wc_relocate): Prototype for new function.
> 
> * subversion/include/svn_client.h
>   (svn_client_relocate): Prototype for new function.
> 
> * subversion/libsvn_wc/relocate.c
>   New file.  Includes implementation of svn_wc_relocate().
> 
> * subversion/libsvn_client/relocate.c
>   New file.  Includes implementation of svn_client_relocate().
> 
> * subversion/clients/cmdline/cl.h
>   (svn_cl__relocate): Added subcommand prototype.  Fixed
>   alphabetical-order of resolve/revert.
> 
> * subversion/clients/cmdline/relocate-cmd.c
>   New file.  Includes implementation of svn_cl__relocate().
> 
> * subversion/clients/cmdline/main.c
>   (svn_cl__cmd_table): Added entry for "relocate".


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