You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Madan U Sreenivasan <ma...@collab.net> on 2006/10/24 23:36:20 UTC
[PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo during repos to repos copy
Hi,
Please find attached step 3 in recording copyfrom mergeinfo during a
repos to repos copy. whats pending?
- Python tests for the same
Regards,
Madan.
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo during repos to repos copy
Posted by Daniel Rall <dl...@collab.net>.
On Fri, 27 Oct 2006, Kamesh Jayachandran wrote:
> Madan U Sreenivasan wrote:
> >On Thu, 26 Oct 2006 12:31:38 +0530, Kamesh Jayachandran
> ><ka...@collab.net> wrote:
> >
> >>
> >>>>>+static svn_error_t *
> >>>>>+get_src_merge_info(svn_ra_session_t *ra_session,
> >>>>>+ apr_hash_t **src_mergeinfo,
> >>>>>+ const char *src_path,
> >>>>>+ svn_revnum_t src_rev,
> >>>>>+ apr_pool_t *pool)
> >>>>>
> >>>>May be we should export this function so that
> >>>>subversion/libsvn_client/diff.c:get_wc_target_merge_info can make
> >>>>use of the same. I could see the scope for its usage when we might
> >>>>have 'mergeaudit' subcommands.
> >>>
> >>>Could you explain a bit more in detail. All this function does is
> >>>call svn_ra_get_merge_info(), and wraps it up in a mergeinfo hash.
> >>Yes we have a similar code lying out in the function
> >>'get_wc_target_merge_info' inside subversion/libsvn_client/diff.c. If
> >>you make get_src_merge_info public(that is what I meant when I said
> >>export(static functions are not exported) it ) we can reuse it there
> >>and possible future consumers like subcommands like 'svn mergeaudit'.
> >>May be we can call it svn_client_get_mergeinfo_for_single_path() ??
> >
> >No, these are not the same...
>
> <snip from libsvn_client/diff.c>
> APR_ARRAY_PUSH(mergeinfo_paths, const char *) = repos_rel_path;
>
> /* ### TODO: To handle sub-tree merge info, the list will need to
> ### include the those child paths which have merge info which
> ### differs from that of TARGET_WCPATH, and if those paths are
> ### directories, their children as well. */
>
> SVN_ERR(svn_ra_get_merge_info(ra_session, &repos_mergeinfo,
> mergeinfo_paths,
> target_rev, TRUE, pool));
> //This line is independent of the earlier one and the following one so
> can be moved above or below.
> SVN_ERR(parse_merge_info(target_mergeinfo, *entry, target_wcpath,
> adm_access, ctx, pool));
>
> if (repos_mergeinfo != NULL)
> {
> apr_hash_t *target_repos_mergeinfo =
> apr_hash_get(repos_mergeinfo, repos_rel_path, APR_HASH_KEY_STRING);
>
>
> </snip>
> <snip from your patch>
>
> apr_hash_t *merge_info;
> apr_array_header_t *rel_paths = apr_array_make(pool, 1,
> sizeof(src_path));
>
> APR_ARRAY_PUSH(rel_paths, const char *) = src_path;
>
> SVN_ERR(svn_ra_get_merge_info(ra_session, &merge_info, rel_paths,
> src_rev, TRUE, pool));
>
> /* Dereference to obtain only the merge info of the src_path provided */
> if (merge_info)
> *src_mergeinfo = apr_hash_get(merge_info, src_path, APR_HASH_KEY_STRING);
> else
> *src_mergeinfo = NULL;
>
> return SVN_NO_ERROR;
>
> </snip>
> I meant to reuse this implementation in
> libsvn_client/diff.c:get_wc_target_merge_info.
>
> Hope I made it clear.
Good suggestion, Kamesh. I've added an
svn_client__get_merge_info_for_path() API in r22130, which is now used
from get_wc_target_merge_info(). As WC -> repos 'copy' is implemented
in terms of Merge Tracking, we'll likely refactor more of
get_wc_target_merge_info() into the shared subroutine.
I will also use this new API when committing Madan's patch.
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo
during repos to repos copy
Posted by Kamesh Jayachandran <ka...@collab.net>.
Madan U Sreenivasan wrote:
> On Thu, 26 Oct 2006 12:31:38 +0530, Kamesh Jayachandran
> <ka...@collab.net> wrote:
>
>>
>>>>> +static svn_error_t *
>>>>> +get_src_merge_info(svn_ra_session_t *ra_session,
>>>>> + apr_hash_t **src_mergeinfo,
>>>>> + const char *src_path,
>>>>> + svn_revnum_t src_rev,
>>>>> + apr_pool_t *pool)
>>>>>
>>>> May be we should export this function so that
>>>> subversion/libsvn_client/diff.c:get_wc_target_merge_info can make
>>>> use of the same. I could see the scope for its usage when we might
>>>> have 'mergeaudit' subcommands.
>>>
>>> Could you explain a bit more in detail. All this function does is
>>> call svn_ra_get_merge_info(), and wraps it up in a mergeinfo hash.
>> Yes we have a similar code lying out in the function
>> 'get_wc_target_merge_info' inside subversion/libsvn_client/diff.c. If
>> you make get_src_merge_info public(that is what I meant when I said
>> export(static functions are not exported) it ) we can reuse it there
>> and possible future consumers like subcommands like 'svn mergeaudit'.
>> May be we can call it svn_client_get_mergeinfo_for_single_path() ??
>
> No, these are not the same...
<snip from libsvn_client/diff.c>
APR_ARRAY_PUSH(mergeinfo_paths, const char *) = repos_rel_path;
/* ### TODO: To handle sub-tree merge info, the list will need to
### include the those child paths which have merge info which
### differs from that of TARGET_WCPATH, and if those paths are
### directories, their children as well. */
SVN_ERR(svn_ra_get_merge_info(ra_session, &repos_mergeinfo,
mergeinfo_paths,
target_rev, TRUE, pool));
//This line is independent of the earlier one and the following one so
can be moved above or below.
SVN_ERR(parse_merge_info(target_mergeinfo, *entry, target_wcpath,
adm_access, ctx, pool));
if (repos_mergeinfo != NULL)
{
apr_hash_t *target_repos_mergeinfo =
apr_hash_get(repos_mergeinfo, repos_rel_path, APR_HASH_KEY_STRING);
</snip>
<snip from your patch>
apr_hash_t *merge_info;
apr_array_header_t *rel_paths = apr_array_make(pool, 1,
sizeof(src_path));
APR_ARRAY_PUSH(rel_paths, const char *) = src_path;
SVN_ERR(svn_ra_get_merge_info(ra_session, &merge_info, rel_paths,
src_rev, TRUE, pool));
/* Dereference to obtain only the merge info of the src_path provided */
if (merge_info)
*src_mergeinfo = apr_hash_get(merge_info, src_path, APR_HASH_KEY_STRING);
else
*src_mergeinfo = NULL;
return SVN_NO_ERROR;
</snip>
I meant to reuse this implementation in
libsvn_client/diff.c:get_wc_target_merge_info.
Hope I made it clear.
>
>>>>> +{
>>>>> + /* Dereference to obtain only the merge info of the src_path
>>>>> provided */
>>>>> + if (merge_info)
>>>>>
>>>> No need to check for nullity of merge_info. Unless rel_paths->nelts
>>>> == 0 merge_info will never be null.
>>>
>>> We need to ensure that src_mergeinfo is set to NULL, thats why the
>>> null-check.
>> No need to ensure that. Across our code, atleast the places where I
>> have seen, the callee always sets the apr_hash_t*. Checking for NULL
>> there is redundancy.
>>
>> In this particular case refer 'svn_repos_fs_get_merge_info' in
>> subversion/libsvn_repos/fs-wrap.c you will realize that
>> 'src_mergeinfo' will never be NULL.
>
> Please read the code. We also have to extract the inner-hash of the
> mergeinfo. To do this, we have to know whether the mergeinfo hash is
> non-NULL before we can call the apr_hash_get() function.
Please read the implementation of the following carefully.
a) 'svn_repos_fs_get_merge_info' in subversion/libsvn_repos/fs-wrap.c
b)svn_fs_merge_info__get_merge_info in
subversion/libsvn_fs_util/merge-info-sqlite-index.c
You will understand that for this case(you have some meaningful stuff
inside your rel_paths array) that you work with 'mergeinfo' hash will
never be null, as with many of our library functions having
'apr_hash_t**' kind of out params.
With regards
Kamesh Jayachandran
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo during repos to repos copy
Posted by Madan U Sreenivasan <ma...@collab.net>.
On Thu, 26 Oct 2006 12:31:38 +0530, Kamesh Jayachandran
<ka...@collab.net> wrote:
>
>>>> +static svn_error_t *
>>>> +get_src_merge_info(svn_ra_session_t *ra_session,
>>>> + apr_hash_t **src_mergeinfo,
>>>> + const char *src_path,
>>>> + svn_revnum_t src_rev,
>>>> + apr_pool_t *pool)
>>>>
>>> May be we should export this function so that
>>> subversion/libsvn_client/diff.c:get_wc_target_merge_info can make use
>>> of the same. I could see the scope for its usage when we might have
>>> 'mergeaudit' subcommands.
>>
>> Could you explain a bit more in detail. All this function does is call
>> svn_ra_get_merge_info(), and wraps it up in a mergeinfo hash.
> Yes we have a similar code lying out in the function
> 'get_wc_target_merge_info' inside subversion/libsvn_client/diff.c. If
> you make get_src_merge_info public(that is what I meant when I said
> export(static functions are not exported) it ) we can reuse it there and
> possible future consumers like subcommands like 'svn mergeaudit'.
> May be we can call it svn_client_get_mergeinfo_for_single_path() ??
No, these are not the same...
>>>> +{
>>>> + /* Dereference to obtain only the merge info of the src_path
>>>> provided */
>>>> + if (merge_info)
>>>>
>>> No need to check for nullity of merge_info. Unless rel_paths->nelts ==
>>> 0 merge_info will never be null.
>>
>> We need to ensure that src_mergeinfo is set to NULL, thats why the
>> null-check.
> No need to ensure that. Across our code, atleast the places where I have
> seen, the callee always sets the apr_hash_t*. Checking for NULL there is
> redundancy.
>
> In this particular case refer 'svn_repos_fs_get_merge_info' in
> subversion/libsvn_repos/fs-wrap.c you will realize that 'src_mergeinfo'
> will never be NULL.
Please read the code. We also have to extract the inner-hash of the
mergeinfo. To do this, we have to know whether the mergeinfo hash is
non-NULL before we can call the apr_hash_get() function.
Regards,
Madan.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo
during repos to repos copy
Posted by Kamesh Jayachandran <ka...@collab.net>.
>>> +static svn_error_t *
>>> +get_src_merge_info(svn_ra_session_t *ra_session,
>>> + apr_hash_t **src_mergeinfo,
>>> + const char *src_path,
>>> + svn_revnum_t src_rev,
>>> + apr_pool_t *pool)
>>>
>> May be we should export this function so that
>> subversion/libsvn_client/diff.c:get_wc_target_merge_info can make use
>> of the same. I could see the scope for its usage when we might have
>> 'mergeaudit' subcommands.
>
> Could you explain a bit more in detail. All this function does is call
> svn_ra_get_merge_info(), and wraps it up in a mergeinfo hash.
Yes we have a similar code lying out in the function
'get_wc_target_merge_info' inside subversion/libsvn_client/diff.c. If
you make get_src_merge_info public(that is what I meant when I said
export(static functions are not exported) it ) we can reuse it there and
possible future consumers like subcommands like 'svn mergeaudit'.
May be we can call it svn_client_get_mergeinfo_for_single_path() ??
>
>>> +{
>>> + /* Dereference to obtain only the merge info of the src_path
>>> provided */
>>> + if (merge_info)
>>>
>> No need to check for nullity of merge_info. Unless rel_paths->nelts
>> == 0 merge_info will never be null.
>
> We need to ensure that src_mergeinfo is set to NULL, thats why the
> null-check.
No need to ensure that. Across our code, atleast the places where I have
seen, the callee always sets the apr_hash_t*. Checking for NULL there is
redundancy.
In this particular case refer 'svn_repos_fs_get_merge_info' in
subversion/libsvn_repos/fs-wrap.c you will realize that 'src_mergeinfo'
will never be NULL.
Anyway I could see this kind of too cautious(????) null checking atleast
in 2 instances(for which my patch found its place in issue tracker!!!,
and hence did not give much motivation to dig further.)
>
>>> +
>>> + /* Obtain copyfrom information of the source */
>>> SVN_ERR(get_copyfrom_merge_info(ra_session, ©from_mergeinfo,
>>> src_rel_path, copyfrom_path,
>>> src_revnum, pool));
>>>
>> What about using only 'get_src_merge_info'?
>
> get_src_merge_info() is to get the existing mergeinfo of the source.
> get_copyfrom_merge_info() is to get the copyfrom information of the
> source. How can we use the same function?
>
Oh I misunderstood!.
I thought 'get_implied_merge_info' would get the 'svn:mergeinfo' as
available on 'copy_from_source_path'. I am wrong it just gives the
'copy_from_source_path:created_rev-cur_rev'. So we need both this
mergeinfo and mergeinfo crawl on 'copy_from_mergeinfo'.
With regards
Kamesh Jayachandran
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo during repos to repos copy
Posted by Madan U Sreenivasan <ma...@collab.net>.
On Wed, 25 Oct 2006 18:06:37 +0530, Kamesh Jayachandran
<ka...@collab.net> wrote:
>
>> * subversion/libsvn_client/copy.c
>> (includes): svn_mergeinfo.h
>> (get_src_merge_info): New. Obtains the existing mergeinfo hash for the
>> given path.
>> (calculate_target_merge_info): Modfied to use get_src_merge_info(),
>> and
>> merge the result with the already available copyfrom information.
>>
> Please use svn diff. I could not see 'calculate_target_merge_info'
> anywhere in the merge-tracking branch.
calculate_target_merge_info() is part of my uncommitted patch submitted at
http://svn.haxx.se/dev/archive-2006-10/0681.shtml. Sorry, I should have
mentioned the dependency.
>> ------------------------------------------------------------------------
>>
>> --- subversion/libsvn_client/copy.c.bu4diff 2006-10-24
>> 04:21:03.000000000 +0530
>> +++ subversion/libsvn_client/copy.c 2006-10-25 04:57:26.000000000 +0530
>> @@ -31,6 +31,7 @@
>> #include "svn_opt.h"
>> #include "svn_time.h"
>> #include "svn_props.h"
>> +#include "svn_mergeinfo.h"
>> #include "client.h"
>> @@ -239,6 +240,33 @@
>> return SVN_NO_ERROR;
>> }
>> +/* Obtain the mergeinfo hash of the given path in SRC_MERGEINFO.
>> + If theres no merge info available, SRC_MERGEINFO will be NULL */
>> +static svn_error_t *
>> +get_src_merge_info(svn_ra_session_t *ra_session,
>> + apr_hash_t **src_mergeinfo,
>> + const char *src_path,
>> + svn_revnum_t src_rev,
>> + apr_pool_t *pool)
>>
> May be we should export this function so that
> subversion/libsvn_client/diff.c:get_wc_target_merge_info can make use of
> the same. I could see the scope for its usage when we might have
> 'mergeaudit' subcommands.
Could you explain a bit more in detail. All this function does is call
svn_ra_get_merge_info(), and wraps it up in a mergeinfo hash.
>> +{
>> + apr_hash_t *merge_info;
>> + apr_array_header_t *rel_paths = apr_array_make(pool, 1,
>> + sizeof(src_path));
>> +
>> + APR_ARRAY_PUSH(rel_paths, const char *) = src_path;
>> +
>> + SVN_ERR(svn_ra_get_merge_info(ra_session, &merge_info, rel_paths,
>> + src_rev, TRUE, pool));
>> +
>> + /* Dereference to obtain only the merge info of the src_path
>> provided */
>> + if (merge_info)
>>
> No need to check for nullity of merge_info. Unless rel_paths->nelts == 0
> merge_info will never be null.
We need to ensure that src_mergeinfo is set to NULL, thats why the
null-check.
>> + *src_mergeinfo = apr_hash_get(merge_info, src_path,
>> APR_HASH_KEY_STRING);
>> + else
>> + *src_mergeinfo = NULL;
>> +
>> + return SVN_NO_ERROR;
>> +}
>> +
>> /* Obtain the copyfrom merge info and the existing merge info of
>> the source path, merge them and set as a svn_string_t in
>> TARGET_MERGEINFO. */
>> @@ -252,7 +280,7 @@
>> {
>> const char *repos_root;
>> const char *copyfrom_path = copyfrom_url;
>> - apr_hash_t *copyfrom_mergeinfo;
>> + apr_hash_t *copyfrom_mergeinfo, *src_mergeinfo;
>> svn_stringbuf_t *mergeinfo;
>> /* Find src path relative to the repos root */
>> @@ -260,14 +288,19 @@
>> while (*copyfrom_path++ == *repos_root++);
>> copyfrom_path--;
>> + /* Obtain copyfrom information of the source */
>> SVN_ERR(get_copyfrom_merge_info(ra_session, ©from_mergeinfo,
>> src_rel_path, copyfrom_path,
>> src_revnum, pool));
>>
> What about using only 'get_src_merge_info'?
get_src_merge_info() is to get the existing mergeinfo of the source.
get_copyfrom_merge_info() is to get the copyfrom information of the
source. How can we use the same function?
Thanks for the comments.
Regards,
Madan.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo
during repos to repos copy
Posted by Kamesh Jayachandran <ka...@collab.net>.
> * subversion/libsvn_client/copy.c
> (includes): svn_mergeinfo.h
> (get_src_merge_info): New. Obtains the existing mergeinfo hash for the
> given path.
> (calculate_target_merge_info): Modfied to use get_src_merge_info(), and
> merge the result with the already available copyfrom information.
>
Please use svn diff. I could not see 'calculate_target_merge_info'
anywhere in the merge-tracking branch.
> ------------------------------------------------------------------------
>
> --- subversion/libsvn_client/copy.c.bu4diff 2006-10-24 04:21:03.000000000 +0530
> +++ subversion/libsvn_client/copy.c 2006-10-25 04:57:26.000000000 +0530
> @@ -31,6 +31,7 @@
> #include "svn_opt.h"
> #include "svn_time.h"
> #include "svn_props.h"
> +#include "svn_mergeinfo.h"
>
> #include "client.h"
>
> @@ -239,6 +240,33 @@
> return SVN_NO_ERROR;
> }
>
> +/* Obtain the mergeinfo hash of the given path in SRC_MERGEINFO.
> + If theres no merge info available, SRC_MERGEINFO will be NULL */
> +static svn_error_t *
> +get_src_merge_info(svn_ra_session_t *ra_session,
> + apr_hash_t **src_mergeinfo,
> + const char *src_path,
> + svn_revnum_t src_rev,
> + apr_pool_t *pool)
>
May be we should export this function so that
subversion/libsvn_client/diff.c:get_wc_target_merge_info can make use of
the same. I could see the scope for its usage when we might have
'mergeaudit' subcommands.
> +{
> + apr_hash_t *merge_info;
> + apr_array_header_t *rel_paths = apr_array_make(pool, 1,
> + sizeof(src_path));
> +
> + APR_ARRAY_PUSH(rel_paths, const char *) = src_path;
> +
> + SVN_ERR(svn_ra_get_merge_info(ra_session, &merge_info, rel_paths,
> + src_rev, TRUE, pool));
> +
> + /* Dereference to obtain only the merge info of the src_path provided */
> + if (merge_info)
>
No need to check for nullity of merge_info. Unless rel_paths->nelts == 0
merge_info will never be null.
> + *src_mergeinfo = apr_hash_get(merge_info, src_path, APR_HASH_KEY_STRING);
> + else
> + *src_mergeinfo = NULL;
> +
> + return SVN_NO_ERROR;
> +}
> +
> /* Obtain the copyfrom merge info and the existing merge info of
> the source path, merge them and set as a svn_string_t in
> TARGET_MERGEINFO. */
> @@ -252,7 +280,7 @@
> {
> const char *repos_root;
> const char *copyfrom_path = copyfrom_url;
> - apr_hash_t *copyfrom_mergeinfo;
> + apr_hash_t *copyfrom_mergeinfo, *src_mergeinfo;
> svn_stringbuf_t *mergeinfo;
>
> /* Find src path relative to the repos root */
> @@ -260,14 +288,19 @@
> while (*copyfrom_path++ == *repos_root++);
> copyfrom_path--;
>
> + /* Obtain copyfrom information of the source */
> SVN_ERR(get_copyfrom_merge_info(ra_session, ©from_mergeinfo,
> src_rel_path, copyfrom_path,
> src_revnum, pool));
>
What about using only 'get_src_merge_info'?
With regards
Kamesh Jayachandran
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo during repos to repos copy
Posted by Daniel Rall <dl...@collab.net>.
On Wed, 25 Oct 2006, Madan S. wrote:
...
> Step 3 of recording copyfrom history as mergeinfo on repos to repos copy.
> This step
> - obtains the existing merge info on the source path
> - Merges it with the already obtained copyfrom information
>
> On the merge-tracking branch:
>
> * subversion/libsvn_client/copy.c
> (includes): svn_mergeinfo.h
> (get_src_merge_info): New. Obtains the existing mergeinfo hash for the
> given path.
> (calculate_target_merge_info): Modfied to use get_src_merge_info(), and
> merge the result with the already available copyfrom information.
I've committed a tweaked version of this patch in r22131.