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

Re: Outstanding Patches.

From: Philip Martin <philip_martin_at_ntlworld.com>
Date: 2001-10-29 02:20:39 CET

Mo DeJong <supermo@bayarea.net> writes:

> On 28 Oct 2001 22:58:35 +0000
> Philip Martin <philip_martin@ntlworld.com> wrote:
>
> > Kevin Pilch-Bisson <kevin@pilch-bisson.net> writes:
> >
> > > 3) svn diff showing added files, from Mo Dejong. I promised to look at this
> > > and I'm still trying to think of a cleaner way to do it than to create
> > > hit the disk three times per added file.
> >
> > The patch worked by creating a temporary, empty file for the diff
> > command, when the svn_wc_get_pristine_copy_path() failed to open a
> > cached version. Now all empty files are identical, so the wc layer
> > could create an empty file once and retain it for future use. Then
> > svn_wc_get_pristine_copy_path() could return a path to the single
> > empty file without the overhead of any file creation calls.
> >
>
> This seems like an early optimization. The time needed to touch an
> empty file seems like nothing compared to creating a new process
> and running diff. We might also just create an empty foo.c in the
> pristine dir when `svn add foo.c` is run. It seems like getting the feature
> implemented and tested is more important than this minor impl detail.

It's more than an optimisation: it doesn't suffer from any lock/race
problems, and it allows running svn diff on a file system to which one
donesn't have write access. Both these benefits apply if an empty
pristine copy were to be created at 'svn add foo.c' time as well.

Putting my code where my mouth is I append a patch for the single
empty file in the adm area approach. I think the idea of adding a
empty pristine copy at 'svn add' time may be even neater from a
conceptual point of view, but I haven't just finished a patch for
that!

* subversion/libsvn_wc/wc.h: Add SVN_WC__ADM_EMPTY_FILE and
  svn_wc__adm_empty_file() to return the path to an empty file in the
  adm area corresponding to a given file node.

* subversion/libsvn_wc/adm_ops.c (svn_wc_get_pristine_copy_path):
  Return empty file path for added files not yet committed

* subversion/libsvn_wc/adm_files.c (init_adm): Create the emtpy file
  in the adm area.

Index: ./subversion/libsvn_wc/wc.h
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/wc.h Sun Oct 28 14:14:34 2001
+++ ./subversion/libsvn_wc/wc.h Mon Oct 29 00:42:49 2001
@@ -100,6 +100,7 @@
 #define SVN_WC__ADM_LOG "log"
 #define SVN_WC__ADM_KILLME "KILLME"
 #define SVN_WC__ADM_AUTH_DIR "auth"
+#define SVN_WC__ADM_EMPTY_FILE "empty-file"
 
 
 /* The basename of the ".prej" file, if a directory ever has property
@@ -109,6 +110,10 @@
 
 /* Return a string containing the admin subdir name. */
 svn_stringbuf_t *svn_wc__adm_subdir (apr_pool_t *pool);
+
+/* Return a string containing the admin empty file. */
+svn_stringbuf_t *svn_wc__adm_empty_file (const svn_stringbuf_t *path,
+ apr_pool_t *pool);
 
 
 /* Return a path to something in PATH's administrative area.
Index: ./subversion/libsvn_wc/adm_ops.c
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/adm_ops.c Sun Oct 28 14:14:40 2001
+++ ./subversion/libsvn_wc/adm_ops.c Mon Oct 29 00:43:48 2001
@@ -1045,7 +1045,13 @@
                                svn_stringbuf_t **pristine_path,
                                apr_pool_t *pool)
 {
- *pristine_path = svn_wc__text_base_path (path, FALSE, pool);
+ svn_wc_entry_t *entry;
+
+ SVN_ERR (svn_wc_entry (&entry, path, pool));
+ if (entry->schedule == svn_wc_schedule_add && entry->kind == svn_node_file)
+ *pristine_path = svn_wc__adm_empty_file (path, pool);
+ else
+ *pristine_path = svn_wc__text_base_path (path, FALSE, pool);
   return SVN_NO_ERROR;
 }
 
Index: ./subversion/libsvn_wc/adm_files.c
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/adm_files.c Sun Oct 28 14:14:39 2001
+++ ./subversion/libsvn_wc/adm_files.c Mon Oct 29 00:42:42 2001
@@ -55,6 +55,19 @@
   return svn_stringbuf_create (adm_subdir (), pool);
 }
 
+svn_stringbuf_t *
+svn_wc__adm_empty_file (const svn_stringbuf_t *path,
+ apr_pool_t *pool)
+{
+ svn_stringbuf_t *empty_file_path = svn_stringbuf_dup (path, pool);
+ svn_path_remove_component (empty_file_path, svn_path_local_style);
+ svn_path_add_component_nts (empty_file_path, SVN_WC_ADM_DIR_NAME,
+ svn_path_local_style);
+ svn_path_add_component_nts (empty_file_path, SVN_WC__ADM_EMPTY_FILE,
+ svn_path_local_style);
+ return empty_file_path;
+}
+
 
 /* Extend PATH to the name of something in PATH's administrative area.
  * Returns the number of path components added to PATH.
@@ -1180,6 +1193,10 @@
 
   /* SVN_WC__ADM_ENTRIES */
   SVN_ERR (svn_wc__entries_init (path, ancestor_path, pool));
+
+ /* SVN_WC__ADM_EMPTY_FILE */
+ SVN_ERR (svn_wc__make_adm_thing (path, SVN_WC__ADM_EMPTY_FILE, svn_node_file,
+ APR_UREAD, 0, pool));
 
   /* THIS FILE MUST BE CREATED LAST:
      After this exists, the dir is considered complete. */

---------------------------------------------------------------------
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:36:46 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.