You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Tom Naughton <na...@gmail.com> on 2008/10/15 21:42:25 UTC
absolute paths in svn_wc_notify_t
I have an application that uses version 1.5.2 of the client library APIs.
I've set up the notify_func2 in my svn_client_ctx_t to point to a callback.
Before 1.5, I relied on 'path' in svn_wc_notify_t to point to an absolute
path. Now for commit operations (and only commit operations), I'm getting
partial paths that have had some prefix removed. Is there some way to
determine what this prefix will be or even better, opt to receive absolute
paths instead? According to the comments in svn_wc.h this path is "either
absolute or relative to the current working directory". But I haven't found
that to be the case. In some cases the prefix that is removed is just "/".
Stepping through the subversion code I've been able to derive an algorithm
for determining the prefix that will be removed:
// Determine prefix stripped from the commit notify messages
const char *display_dir = "";
const char *base_dir = nil;
svn_depth_t depth = svn_depth_infinity;
apr_array_header_t *rel_targets;
err = svn_path_condense_targets(&base_dir, &rel_targets, commit_targets,
depth == svn_depth_infinity, pool);
err = svn_path_get_absolute(&display_dir,display_dir, pool);
display_dir = svn_path_get_longest_ancestor(display_dir, base_dir,
pool);
If the current directory is something like "/Objects/Debug" and all of the
paths in commit_targets are outside of /Objects,
svn_path_get_longest_ancestor returns "/", and that's what I'm seeing in my
unit tests.
Is there a better way to figure out this prefix?
Tom
Re: absolute paths in svn_wc_notify_t
Posted by Neels J Hofmeyr <ne...@elego.de>.
sorry, ignore my previous post. gah.
Neels J Hofmeyr wrote:
>
> Tom Naughton wrote:
>> I have an application that uses version 1.5.2 of the client library APIs.
>> I've set up the notify_func2 in my svn_client_ctx_t to point to a callback.
>>
>> Before 1.5, I relied on 'path' in svn_wc_notify_t to point to an absolute
>> path. Now for commit operations (and only commit operations), I'm getting
>> partial paths that have had some prefix removed. Is there some way to
>> determine what this prefix will be or even better, opt to receive absolute
>> paths instead? According to the comments in svn_wc.h this path is "either
>> absolute or relative to the current working directory". But I haven't found
>> that to be the case. In some cases the prefix that is removed is just "/".
>>
>> Stepping through the subversion code I've been able to derive an algorithm
>> for determining the prefix that will be removed:
>>
>> // Determine prefix stripped from the commit notify messages
>> const char *display_dir = "";
>> const char *base_dir = nil;
>> svn_depth_t depth = svn_depth_infinity;
>> apr_array_header_t *rel_targets;
>> err = svn_path_condense_targets(&base_dir, &rel_targets, commit_targets,
>> depth == svn_depth_infinity, pool);
>> err = svn_path_get_absolute(&display_dir,display_dir, pool);
>
> Btw, this is bad. You have two consecutive lines that start with `err =
> ...', and you don't check whether an error actually occurs. If the first
> operation has an error, the second one overwrites it.
>
>> display_dir = svn_path_get_longest_ancestor(display_dir, base_dir,
>> pool);
>>
>> If the current directory is something like "/Objects/Debug" and all of the
>> paths in commit_targets are outside of /Objects,
>> svn_path_get_longest_ancestor returns "/", and that's what I'm seeing in my
>> unit tests.
>>
>> Is there a better way to figure out this prefix?
>
> Hmm, could you send an (if possible complete and runnable) code sample that
> reproduces the problem? Maybe you found a bug.
>
> Thanks!
> ~Neels
>
>> Tom
>>
>
--
Neels Hofmeyr -- elego Software Solutions GmbH
Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23458696 mobile: +49 177 2345869 fax: +49 30 23458695
http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelsreg: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194
Re: absolute paths in svn_wc_notify_t
Posted by Neels J Hofmeyr <ne...@elego.de>.
Tom Naughton wrote:
> I have an application that uses version 1.5.2 of the client library APIs.
> I've set up the notify_func2 in my svn_client_ctx_t to point to a callback.
>
> Before 1.5, I relied on 'path' in svn_wc_notify_t to point to an absolute
> path. Now for commit operations (and only commit operations), I'm getting
> partial paths that have had some prefix removed. Is there some way to
> determine what this prefix will be or even better, opt to receive absolute
> paths instead? According to the comments in svn_wc.h this path is "either
> absolute or relative to the current working directory". But I haven't found
> that to be the case. In some cases the prefix that is removed is just "/".
>
> Stepping through the subversion code I've been able to derive an algorithm
> for determining the prefix that will be removed:
>
> // Determine prefix stripped from the commit notify messages
> const char *display_dir = "";
> const char *base_dir = nil;
> svn_depth_t depth = svn_depth_infinity;
> apr_array_header_t *rel_targets;
> err = svn_path_condense_targets(&base_dir, &rel_targets, commit_targets,
> depth == svn_depth_infinity, pool);
> err = svn_path_get_absolute(&display_dir,display_dir, pool);
Btw, this is bad. You have two consecutive lines that start with `err =
...', and you don't check whether an error actually occurs. If the first
operation has an error, the second one overwrites it.
> display_dir = svn_path_get_longest_ancestor(display_dir, base_dir,
> pool);
>
> If the current directory is something like "/Objects/Debug" and all of the
> paths in commit_targets are outside of /Objects,
> svn_path_get_longest_ancestor returns "/", and that's what I'm seeing in my
> unit tests.
>
> Is there a better way to figure out this prefix?
Hmm, could you send an (if possible complete and runnable) code sample that
reproduces the problem? Maybe you found a bug.
Thanks!
~Neels
>
> Tom
>
--
Neels Hofmeyr -- elego Software Solutions GmbH
Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23458696 mobile: +49 177 2345869 fax: +49 30 23458695
http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelsreg: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194
Re: absolute paths in svn_wc_notify_t
Posted by Tom Naughton <na...@gmail.com>.
Thanks for the confirmation, is there an issue number I can use to
track this?
Tom
On Oct 16, 2008, at 2:09 AM, Bert Huijben wrote:
> Hi Tom,
>
> The fix for this issue is in trunk. I noticed the same problem while
> building SharpSvn and using it from AnkhSVN 2.0, but this was just
> after 1.5 was branched.
>
> This method of using the path was unreliable before 1.5 as well L
> It all depends on your current directory related to the commit
> location. The used base directory is the common ancestor of the
> commit locations and your current working directory.
>
> In trunk/1.6 you will always receive an absolute path and optionally
> the prefix in a separate variable of svn_wc_notify_t. (The UI than
> has the option of extracting the prefix or leaving it to always real
> absolute or relative paths).
>
> The lock functions have the same problem in 1.5 and where fixed in
> the same way for 1.6. This change can’t be ported back to 1.5 as it
> changes the svn_wc_notify_t structure.
>
> Bert
>
> From: Tom Naughton [mailto:naughtont@gmail.com]
> Sent: Wednesday, October 15, 2008 11:42 PM
> To: dev@subversion.tigris.org
> Subject: absolute paths in svn_wc_notify_t
>
> I have an application that uses version 1.5.2 of the client library
> APIs. I've set up the notify_func2 in my svn_client_ctx_t to point
> to a callback.
>
> Before 1.5, I relied on 'path' in svn_wc_notify_t to point to an
> absolute path. Now for commit operations (and only commit
> operations), I'm getting partial paths that have had some prefix
> removed. Is there some way to determine what this prefix will be or
> even better, opt to receive absolute paths instead? According to the
> comments in svn_wc.h this path is "either absolute or relative to
> the current working directory". But I haven't found that to be the
> case. In some cases the prefix that is removed is just "/".
>
> Stepping through the subversion code I've been able to derive an
> algorithm for determining the prefix that will be removed:
>
> // Determine prefix stripped from the commit notify messages
> const char *display_dir = "";
> const char *base_dir = nil;
> svn_depth_t depth = svn_depth_infinity;
> apr_array_header_t *rel_targets;
> err = svn_path_condense_targets(&base_dir, &rel_targets,
> commit_targets, depth == svn_depth_infinity, pool);
> err = svn_path_get_absolute(&display_dir,display_dir, pool);
> display_dir = svn_path_get_longest_ancestor(display_dir,
> base_dir, pool);
>
> If the current directory is something like "/Objects/Debug" and all
> of the paths in commit_targets are outside of /Objects,
> svn_path_get_longest_ancestor returns "/", and that's what I'm
> seeing in my unit tests.
>
> Is there a better way to figure out this prefix?
>
> Tom
>
RE: absolute paths in svn_wc_notify_t
Posted by Bert Huijben <be...@vmoo.com>.
Hi Tom,
The fix for this issue is in trunk. I noticed the same problem while
building SharpSvn and using it from AnkhSVN 2.0, but this was just after 1.5
was branched.
This method of using the path was unreliable before 1.5 as well L
It all depends on your current directory related to the commit location. The
used base directory is the common ancestor of the commit locations and your
current working directory.
In trunk/1.6 you will always receive an absolute path and optionally the
prefix in a separate variable of svn_wc_notify_t. (The UI than has the
option of extracting the prefix or leaving it to always real absolute or
relative paths).
The lock functions have the same problem in 1.5 and where fixed in the same
way for 1.6. This change can't be ported back to 1.5 as it changes the
svn_wc_notify_t structure.
Bert
From: Tom Naughton [mailto:naughtont@gmail.com]
Sent: Wednesday, October 15, 2008 11:42 PM
To: dev@subversion.tigris.org
Subject: absolute paths in svn_wc_notify_t
I have an application that uses version 1.5.2 of the client library APIs.
I've set up the notify_func2 in my svn_client_ctx_t to point to a callback.
Before 1.5, I relied on 'path' in svn_wc_notify_t to point to an absolute
path. Now for commit operations (and only commit operations), I'm getting
partial paths that have had some prefix removed. Is there some way to
determine what this prefix will be or even better, opt to receive absolute
paths instead? According to the comments in svn_wc.h this path is "either
absolute or relative to the current working directory". But I haven't found
that to be the case. In some cases the prefix that is removed is just "/".
Stepping through the subversion code I've been able to derive an algorithm
for determining the prefix that will be removed:
// Determine prefix stripped from the commit notify messages
const char *display_dir = "";
const char *base_dir = nil;
svn_depth_t depth = svn_depth_infinity;
apr_array_header_t *rel_targets;
err = svn_path_condense_targets(&base_dir, &rel_targets, commit_targets,
depth == svn_depth_infinity, pool);
err = svn_path_get_absolute(&display_dir,display_dir, pool);
display_dir = svn_path_get_longest_ancestor(display_dir, base_dir,
pool);
If the current directory is something like "/Objects/Debug" and all of the
paths in commit_targets are outside of /Objects,
svn_path_get_longest_ancestor returns "/", and that's what I'm seeing in my
unit tests.
Is there a better way to figure out this prefix?
Tom