[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Update Patch

From: Kevin Pilch-Bisson <kevin_at_pilch-bisson.net>
Date: 2001-09-11 20:47:57 CEST

Hey all,

Here is a patch which (almost) gets svn up to work as expected. There are
a couple of things which I don't like about it (most notably how is_thisdir is
set in mod_dav_svn/version.c), which is why I didn't just check it in.

If anyone can think of a better way to get it working just let me know.

Otherwise, I will check this in on say Thursday morning.

PS: if you're wondering what is wrong with svn up, try one of the following
svn up (something missing)
svn up (a child dir under dav)
a couple of other problems I can no longer remember, except that it has taken
me almost a week to get this working.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson                    http://www.pilch-bisson.net
     "Historically speaking, the presences of wheels in Unix
     has never precluded their reinvention." - Larry Wall
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: ./libsvn_client/update.c
===================================================================
--- ./libsvn_client/SVN/text-base/update.c	Thu Sep  6 12:18:42 2001
+++ ./libsvn_client/update.c	Tue Sep 11 14:03:05 2001
@@ -71,6 +71,7 @@
   void *report_baton;
   svn_wc_entry_t *entry;
   svn_stringbuf_t *URL;
+  svn_stringbuf_t *base_dir = path;
 
   /* Sanity check.  Without this, the update is meaningless. */
   assert (path != NULL);
@@ -88,13 +89,35 @@
       (SVN_ERR_WC_ENTRY_NOT_FOUND, 0, NULL, pool,
        "entry '%s' has already been deleted", path->data);
 
-  URL = svn_stringbuf_create (entry->ancestor->data, pool);
+  if (entry->ancestor)
+    URL = svn_stringbuf_create (entry->ancestor->data, pool);
+
+  if (!entry->ancestor)
+    {
+      svn_wc_entry_t *par_entry;
+      svn_stringbuf_t *basename;
+      svn_path_split(path, &base_dir, &basename, svn_path_local_style, pool);
+      if (svn_stringbuf_isempty(base_dir))
+        svn_stringbuf_set(base_dir, ".");
+      SVN_ERR(svn_wc_entry(&par_entry, base_dir, pool));
+      if (! par_entry)
+        return svn_error_createf
+          (SVN_ERR_WC_OBSTRUCTED_UPDATE, 0, NULL, pool,
+           "svn_client_update: %s is not under revision control",
+           base_dir->data);
+      if (entry->existence == svn_wc_existence_deleted)
+        return svn_error_createf
+          (SVN_ERR_WC_ENTRY_NOT_FOUND, 0, NULL, pool,
+           "entry '%s' has already been deleted", base_dir->data);
+      URL = svn_stringbuf_dup(par_entry->ancestor, pool);
+      svn_path_add_component(URL, basename, svn_path_url_style);
+    }
 
   /* The following is an ugly kludge.  In order to let the RA layer
      know the difference between updating entry 'Z' in dir 'X/Y' and
      updating entry '.' in 'X/Y/Z', we'll append a '.' to the URL. */
   if (svn_path_is_thisdir (path, svn_path_repos_style))
-     svn_path_add_component (URL, path, svn_path_repos_style);
+     svn_path_add_component (URL, path, svn_path_url_style);
 
   /* Fetch the update editor.  If REVISION is invalid, that's okay;
      either the RA or XML driver will call editor->set_target_revision
@@ -116,7 +139,6 @@
     {
       void *ra_baton, *session;
       svn_ra_plugin_t *ra_lib;
-      svn_stringbuf_t *base_dir = path;
 
       /* Get the RA vtable that matches URL. */
       SVN_ERR (svn_ra_init_ra_libs (&ra_baton, pool));
Index: ./mod_dav_svn/update.c
===================================================================
--- ./mod_dav_svn/SVN/text-base/update.c	Thu Sep  6 12:18:26 2001
+++ ./mod_dav_svn/update.c	Tue Sep 11 14:14:21 2001
@@ -338,7 +338,8 @@
 
 dav_error * dav_svn__update_report(const dav_resource *resource,
 				   const apr_xml_doc *doc,
-				   apr_text_header *report)
+				   apr_text_header *report,
+                                  int is_thisdir)
 {
   svn_delta_edit_fns_t *editor;
   apr_xml_elem *child;
@@ -349,6 +350,8 @@
   int ns;
   svn_error_t *serr;
   svn_stringbuf_t *pathstr;
+  svn_stringbuf_t *anchor;
+  svn_stringbuf_t *target;
   const dav_svn_repos *repos = resource->info->repos;
 
   if (resource->type != DAV_RESOURCE_TYPE_REGULAR)
@@ -413,22 +416,15 @@
     }
 
   fs_base = svn_stringbuf_create(resource->info->repos_path, resource->pool);
+  if (fs_base->len == 1 && fs_base->data[0] == '/')
+      svn_stringbuf_setempty(fs_base);
 
-  /* ### temp hack until begin_report gets separate anchor/target params */
-  if (resource->collection)
-    {
-      uc.anchor = resource->info->repos_path;
-      svn_stringbuf_appendcstr(fs_base, "/.");
-    }
-  else
-    {
-      svn_stringbuf_t *anchor;
-      svn_stringbuf_t *target;
+  if (is_thisdir)
+    svn_stringbuf_appendcstr(fs_base, "/.");
 
-      svn_path_split(fs_base, &anchor, &target, svn_path_repos_style,
-                     resource->pool);
-      uc.anchor = anchor->data;
-    }
+  svn_path_split(fs_base, &anchor, &target, svn_path_repos_style,
+                 resource->pool);
+  uc.anchor = anchor->data;
 
   serr = svn_repos_begin_report(&rbaton, revnum, repos->username, repos->fs,
                                 fs_base, editor, &uc, resource->pool);
Index: ./mod_dav_svn/version.c
===================================================================
--- ./mod_dav_svn/SVN/text-base/version.c	Thu Sep  6 12:18:26 2001
+++ ./mod_dav_svn/version.c	Tue Sep 11 09:34:28 2001
@@ -367,6 +367,8 @@
                                      ap_text_header *report)
 {
   int ns = dav_svn_find_ns(doc->namespaces, SVN_XML_NAMESPACE);
+  int is_thisdir = 0;
+  apr_size_t len;
 
   if (doc->root->ns != ns
       || strcmp(doc->root->name, "update-report") != 0)
@@ -376,7 +378,11 @@
                            "The requested report is unknown.");
     }
 
-  return dav_svn__update_report(resource, doc, report);
+  len = strlen(r->the_request);
+  if (r->the_request[len - 10] == '.')
+      is_thisdir = 1;
+
+  return dav_svn__update_report(resource, doc, report, is_thisdir);
 }
 
 static int dav_svn_can_be_activity(const dav_resource *resource)
Index: ./mod_dav_svn/dav_svn.h
===================================================================
--- ./mod_dav_svn/SVN/text-base/dav_svn.h	Thu Sep  6 12:18:26 2001
+++ ./mod_dav_svn/dav_svn.h	Tue Sep 11 09:32:43 2001
@@ -307,7 +307,8 @@
 
 dav_error * dav_svn__update_report(const dav_resource *resource,
 				   const apr_xml_doc *doc,
-				   apr_text_header *report);
+				   apr_text_header *report,
+                                  int is_thisdir);
 
 int dav_svn_find_ns(apr_array_header_t *namespaces, const char *uri);
 
Index: ./libsvn_repos/delta.c
===================================================================
--- ./libsvn_repos/SVN/text-base/delta.c	Thu Sep  6 12:17:29 2001
+++ ./libsvn_repos/delta.c	Tue Sep 11 13:22:01 2001
@@ -176,6 +176,7 @@
   svn_stringbuf_t *tgt_parent_dir, *tgt_entry;
   svn_stringbuf_t *src_fullpath, *tgt_fullpath;
   svn_fs_id_t *src_id, *tgt_id;
+  svn_error_t *err;
   int distance;
 
   /* SRC_PARENT_DIR must be valid. */
@@ -248,10 +249,21 @@
     svn_path_add_component (src_fullpath, src_entry, svn_path_repos_style);
 
   /* Get the node ids for the source and target paths. */
-  SVN_ERR (svn_fs_node_id (&src_id, src_root, src_fullpath->data, pool));
+
+  err = svn_fs_node_id (&src_id, src_root, src_fullpath->data, pool);
   SVN_ERR (svn_fs_node_id (&tgt_id, tgt_root, tgt_fullpath->data, pool));
-  
-  if (src_entry && src_entry->len > 0)
+  if (err && err->apr_err == SVN_ERR_FS_NOT_FOUND)
+    {
+      /* The target has been deleted from our working copy. Add back a new
+         one. */
+      SVN_ERR (add_file_or_dir (&c, root_baton,
+                                0,
+                                0,
+                                tgt_parent_dir,
+                                tgt_entry,
+                                pool));
+    }
+  else if (src_entry && src_entry->len > 0)
     {
       /* Use the distance between the node ids to determine the best
          way to update the requested entry. */

  • application/pgp-signature attachment: stored
Received on Sat Oct 21 14:36:40 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.