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

Re: [PATCH] Add size information to svn_client_info()

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2007-06-17 09:33:24 CEST

David Glasser wrote:
[snip]
>> [[[
>> Make svn_client_info() return the size or working size of a file or
>> folder too since this information is already available and comes at no
>> cost.
>>
>> subversion/include/svn_client.h : add members working_size and size to
>> the svn_info_t struct and document
>> them.
>> subversion/libsvn_client/info.c : provide the working size and size
>> information to the caller.
>> ]]]
>
> Please follow our standards for writing log messages, especially
> including the names of the modified functions.

Ups, sorry. The attached patch now has a better log message (thanks to
Karl for that :) ).

>
>> Index: subversion/include/svn_client.h
>> ===================================================================
>> --- subversion/include/svn_client.h (revision 25433)
>> +++ subversion/include/svn_client.h (working copy)
>> @@ -3821,8 +3821,21 @@
>> /* @since New in 1.5. */
>> const char *changelist;
>> svn_depth_t depth;
>> +
>> + /**
>> + * size of the file in the working copy.
>> + * @since New in 1.5.
>> + */
>> + apr_size_t working_size;
>> /** @} */
>
> This actually means "size of the file when originally checked out in
> the working copy", not the current size with local modifications,
> right?

It's the entry from the svn_wc_entry_t. It means "Size of the file after
being translated into local representation, or
SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN if unknown."
I've updated the doc string.

>> + /**
>> + * size of the file in the repository (untranslated, i.e., without
>> + * adjustment of line endings and keyword expansion).
>> + * @since New in 1.5.
>> + */
>> + apr_size_t size;
>
> It would seem to me that this value could hypothetically be set on an
> info struct that comes from a WC as well as one that comes from an
> URL; if you're not going to fill it for both that should be
> documented.

Ok, done.

> The values of these fields for directories should be well-defined and
> documented.

done.

> How can you tell the difference between a value of 0 for these fields
> because the file has size 0 and a value of 0 because the function
> didn't fill them in (because each call only fills in one or the
> other)?

if the 'kind' member is svn_node_dir, then of course the value is 0. If
the 'kind' member is svn_node_file and the size member is 0, then it's
because the file actually has a size of 0.

I've added a new define SVN_INFO_SIZE_UNKNOWN which will tell when that
value hasn't been set.

> Should these be printed in "svn info"?

I can't really say, I'm not using the CL client that often. I'm also not
sure if you have some naming conventions for the xml output, so I've
left that one out.

new patch is attached.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net

[[[
Make svn_client_info() return the size or working size of a file or
folder too since this information is already available and comes at no
cost.

* subversion/include/svn_client.h
  (struct svn_info_t): Add members working_size and size.
  (global): Add new define for unknown size

* subversion/libsvn_client/info.c
  (build_info_from_dirent): Adjust accordingly.
]]]
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h (revision 25433)
+++ subversion/include/svn_client.h (working copy)
@@ -3757,6 +3757,13 @@
  * @{
  */
 
+/** The value of the size in the repository is unknown (because the info
+ * was fetched for a local path, not an URL).
+ *
+ * @since New in 1.5
+ */
+#define SVN_INFO_SIZE_UNKNOWN -1
+
 /**
  * A structure which describes various system-generated metadata about
  * a working-copy path or URL.
@@ -3821,8 +3828,26 @@
   /* @since New in 1.5. */
   const char *changelist;
   svn_depth_t depth;
+
+ /**
+ * Size of the file after being translated into local representation,
+ * or:
+ * @c SVN_WC_ENTRY_WORKING_SIZE_UNKOWN if unknown.
+ * @since New in 1.5.
+ */
+ apr_size_t working_size;
   /** @} */
 
+ /**
+ * size of the file in the repository (untranslated, i.e., without
+ * adjustment of line endings and keyword expansion). For directories,
+ * this value will be null.
+ * This is only set for URLs. For working copy paths, this size will
+ * be @c SVN_INFO_SIZE_UNKNOWN.
+ * @since New in 1.5.
+ */
+ apr_size_t size;
+
 } svn_info_t;
 
 
Index: subversion/libsvn_client/info.c
===================================================================
--- subversion/libsvn_client/info.c (revision 25433)
+++ subversion/libsvn_client/info.c (working copy)
@@ -54,6 +54,7 @@
   tmpinfo->last_changed_author = dirent->last_author;
   tmpinfo->lock = lock;
   tmpinfo->depth = svn_depth_unknown;
+ tmpinfo->size = dirent->size;
 
   *info = tmpinfo;
   return SVN_NO_ERROR;
@@ -92,6 +93,8 @@
   tmpinfo->conflict_wrk = entry->conflict_wrk;
   tmpinfo->prejfile = entry->prejfile;
   tmpinfo->changelist = entry->changelist;
+ tmpinfo->working_size = entry->working_size;
+ tmpinfo->size = SVN_INFO_SIZE_UNKNOWN;
 
   /* lock stuff */
   if (entry->lock_token) /* the token is the critical bit. */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jun 17 09:33:33 2007

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.