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

Re: minimalist example of svn_txdelta_run?

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Thu, 31 Mar 2011 06:02:44 +0200

First of all, let's please not mix the terms 'delta' and 'diff'. They
are quite different things in svn.

Clifford Yapp wrote on Wed, Mar 30, 2011 at 19:46:04 -0400:
> Hi - I'm trying to create a minimal-case example creating a delta
> between two strings and applying that delta to a svn repository in C.

Typically to update a file in the repository using the svn_delta API
you'd already know the current contents of that file. Is that the case
for you?

What are you trying to do? Can you give an example with sample data?

> I'm able to add and delete files and add content to an empty file, but
> so far I haven't been able to take the contents of a file, diff them
> with a string, and use that diff to update the file in the repository.
>
> Two immediate questions:
>
> 1) are the md5 checksums integral to the process of creating a delta
> - i.e., can it be ignored or is calculating md5 checksums a required
> step?
>
> 2) is there an example somewhere of this process being done in C code
> as a minimal example? Something along the lines of "given a
> repository and two strings str1 and str2, here's how to apply the
> difference to a file in a repository?"
>
> A code snippet appears below to better illustrate what I'm trying to
> do - I can expand it if that would help any.
>
> Thanks,
> CY
>
> svn_repos_get_commit_editor4(editor, &edit_baton, repos, NULL,
> full_path, base, user, logmsg, NULL, NULL, NULL, NULL, pool);
> (*editor)->open_root(edit_baton, youngest_rev, pool, &root_baton);
> (*editor)->open_file(bu_vls_addr(&filepath), root_baton,
> youngest_rev, pool, &file_baton);
> char *testcontents = "test contents 2";
> teststring = svn_string_createf(pool, "%s", testcontents2);
> svn_stream_t *newstream = svn_stream_from_string(teststring, pool);
> (*editor)->apply_textdelta(file_baton, NULL, pool, &handler, &handler_baton);
> svn_txdelta_run(oldstream, newstream, handler, handler_baton,
> svn_checksum_md5, &local_checksum, NULL, NULL, pool, pool);
> (*editor)->close_file(file_baton, NULL, pool);
> (*editor)->close_edit(edit_baton, pool);
Received on 2011-03-31 06:03:28 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.