Mo DeJong <email@example.com> writes:
> On 28 Oct 2001 22:58:35 +0000
> Philip Martin <firstname.lastname@example.org> wrote:
> > Kevin Pilch-Bisson <email@example.com> 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
* 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.
--- ./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.
--- ./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 @@
- *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);
+ *pristine_path = svn_wc__text_base_path (path, FALSE, pool);
--- ./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_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_add_component_nts (empty_file_path, SVN_WC__ADM_EMPTY_FILE,
+ 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: firstname.lastname@example.org
For additional commands, e-mail: email@example.com
Received on Sat Oct 21 14:36:46 2006