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

Re: [PATCH] partial fix for issue 571

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2002-02-26 03:56:13 CET

On Mon, Feb 25, 2002 at 05:59:47PM -0800, Greg Stein wrote:
> [ most of this mentioned over IRC to Garrett, but he asked for it to be sent
> to the list, so others can get the info, too :-) ]

and here's the new version of the patch, with gstein's comments taken
into account. note that it has one small problem, but i don't think
it's with this patch. we never print out 'Replaced (bin)', since when
we replace something, even if it is binary (and the svn add showed it
was binary) when we see it in close_file() it never has the binary
flag set on it. i haven't had a chance to debug this yet though, so
if someone wants to take a look, feel free.

again, if there are no more comments, i will commit today or tomorrow.
even with the bug, it gets us closer to the desired functionality, and
doesn't seem to hurt anything.

-garrett

Index: ./subversion/clients/cmdline/trace-commit.c
===================================================================
--- ./subversion/clients/cmdline/trace-commit.c
+++ ./subversion/clients/cmdline/trace-commit.c Mon Feb 25 21:33:17 2002
@@ -27,6 +27,7 @@
 #define APR_WANT_STDIO
 #define APR_WANT_STRFUNC
 #include <apr_want.h>
+#include <assert.h>
 
 #include "svn_pools.h"
 #include "svn_wc.h"
@@ -44,6 +45,19 @@
 };
 
 
+static const int svn_cl__item_added = 0;
+static const int svn_cl__item_added_binary = 0;
+static const int svn_cl__item_deleted = 0;
+static const int svn_cl__item_replaced = 0;
+static const int svn_cl__item_replaced_binary = 0;
+
+#define ITEM_ADDED (&svn_cl__item_added)
+#define ITEM_ADDED_BINARY (&svn_cl__item_added_binary)
+#define ITEM_DELETED (&svn_cl__item_deleted)
+#define ITEM_REPLACED (&svn_cl__item_replaced)
+#define ITEM_REPLACED_BINARY (&svn_cl__item_replaced_binary)
+
+
 struct dir_baton
 {
   struct edit_baton *edit_baton;
@@ -51,6 +65,7 @@
   svn_stringbuf_t *path;
   svn_boolean_t added;
   svn_boolean_t prop_changed;
+ apr_hash_t *added_or_deleted;
   apr_pool_t *subpool;
   int ref_count;
 };
@@ -80,6 +95,33 @@
   if (db->ref_count == 0)
     {
       struct dir_baton *dbparent = db->parent_dir_baton;
+ apr_hash_index_t *hi;
+
+ for (hi = apr_hash_first (db->subpool, db->added_or_deleted);
+ hi;
+ hi = apr_hash_next (hi))
+ {
+ const char *pattern;
+ const void *key;
+ void *val;
+
+ apr_hash_this (hi, &key, NULL, &val);
+
+ if (val == ITEM_REPLACED)
+ pattern = "Replacing %s\n";
+ else if (val == ITEM_REPLACED_BINARY)
+ pattern = "Replacing (bin) %s\n";
+ else if (val == ITEM_DELETED)
+ pattern = "Deleting %s\n";
+ else if (val == ITEM_ADDED)
+ pattern = "Adding %s\n";
+ else if (val == ITEM_ADDED_BINARY)
+ pattern = "Adding (bin) %s\n";
+ else
+ assert(0); /* this should never happen */
+
+ printf (pattern, (const char *)key);
+ }
 
       /* Destroy all memory used by this baton, including the baton
          itself! */
@@ -107,6 +149,8 @@
   rb->subpool = subpool;
   rb->ref_count = 1;
 
+ rb->added_or_deleted = apr_hash_make (subpool);
+
   *root_baton = rb;
 
   return SVN_NO_ERROR;
@@ -122,7 +166,9 @@
 
   svn_path_add_component (printable_name, name);
 
- printf ("Deleting %s\n", printable_name->data);
+ apr_hash_set (d->added_or_deleted, printable_name->data, printable_name->len,
+ ITEM_DELETED);
+
   return SVN_NO_ERROR;
 }
 
@@ -137,6 +183,7 @@
   apr_pool_t *subpool;
   struct dir_baton *parent_d = parent_baton;
   struct dir_baton *child_d;
+ void *vp;
 
   subpool = svn_pool_create (parent_d->edit_baton->pool);
   child_d = apr_pcalloc (subpool, sizeof (*child_d));
@@ -150,7 +197,17 @@
   child_d->ref_count = 1;
   parent_d->ref_count++;
 
- printf ("Adding %s\n", child_d->path->data);
+ child_d->added_or_deleted = apr_hash_make (subpool);
+
+ vp = apr_hash_get (parent_d->added_or_deleted, child_d->path->data,
+ child_d->path->len);
+ if (vp == ITEM_DELETED)
+ apr_hash_set (parent_d->added_or_deleted, child_d->path->data,
+ child_d->path->len, ITEM_REPLACED);
+ else
+ apr_hash_set (parent_d->added_or_deleted, child_d->path->data,
+ child_d->path->len, ITEM_ADDED);
+
   *child_baton = child_d;
 
   return SVN_NO_ERROR;
@@ -178,6 +235,8 @@
   child_d->ref_count = 1;
   parent_d->ref_count++;
 
+ child_d->added_or_deleted = apr_hash_make (subpool);
+
   *child_baton = child_d;
 
   /* Don't print anything for a directory open -- this event is
@@ -206,9 +265,28 @@
   struct file_baton *fb = file_baton;
 
   if (fb->added)
- printf ("Adding %s %s\n",
- fb->binary ? "(bin)" : " ",
- fb->path->data);
+ {
+ void *vp = apr_hash_get (fb->parent_dir_baton->added_or_deleted,
+ fb->path->data, fb->path->len);
+ if (vp == NULL)
+ {
+ if (fb->binary)
+ vp = (void *)ITEM_ADDED_BINARY;
+ else
+ vp = (void *)ITEM_ADDED;
+ }
+ else
+ {
+ if (fb->binary)
+ vp = (void *)ITEM_REPLACED_BINARY;
+ else
+ vp = (void*)ITEM_REPLACED;
+ }
+
+ apr_hash_set (fb->parent_dir_baton->added_or_deleted,
+ fb->path->data, fb->path->len, vp);
+
+ }
   else
     printf ("Sending %s\n", fb->path->data);
 

-- 
garrett rooney                     Unix was not designed to stop you from 
rooneg@electricjellyfish.net       doing stupid things, because that would  
http://electricjellyfish.net/      stop you from doing clever things.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:09 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.