You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bo Chen <bo...@gmail.com> on 2013/04/06 07:02:38 UTC
two questions in the SVN source code
I need help for the following two questions. Any help will be appreciated.
1 Given a revision number, which function can (should be in libsvn_fs_fs/)
can read the corresponding revision from the repository (FSFS)?
2 For a variable of svn_stream_t, how can I print the information (e.g.,
the string) stored in this variable.
Thanks.
Bo
Re: two questions in the SVN source code
Posted by Daniel Shahaf <da...@elego.de>.
Bo Chen wrote on Sat, Apr 06, 2013 at 14:33:31 -0400:
> Basically, what I want to do here is to retrieve a certain file from any
> two revisions (directly from the repository), and compute the delta between
> these two file versions. So I need to know first how can I retrieve a
> certain file from any revision of the repository (what functions I can use
> in the current code base? etc.), and how to compute the delta (I may
> directly use the functions in \libsvn_delta\txdelta.c). Do you have any
> suggestion for me?
I think your answer might not be high-level enough.
That said, if you want to compute the delta between two versions, it'll
be easiest to just do what 'svn update' does. svn_ra_do_update2() or
svn_repos_dir_delta2() (but see comments in its doc string) might be
good places to start.
Or you could 'svn cat' twice and then pass the result to an svn_delta.h
function.
Re: two questions in the SVN source code
Posted by Bo Chen <bo...@gmail.com>.
Basically, what I want to do here is to retrieve a certain file from any
two revisions (directly from the repository), and compute the delta between
these two file versions. So I need to know first how can I retrieve a
certain file from any revision of the repository (what functions I can use
in the current code base? etc.), and how to compute the delta (I may
directly use the functions in \libsvn_delta\txdelta.c). Do you have any
suggestion for me?
Thanks.
Bo
On Sat, Apr 6, 2013 at 1:50 AM, Ben Reser <be...@reser.org> wrote:
> On Fri, Apr 5, 2013 at 10:02 PM, Bo Chen <bo...@gmail.com> wrote:
> > I need help for the following two questions. Any help will be
> appreciated.
> >
> > 1 Given a revision number, which function can (should be in
> libsvn_fs_fs/)
> > can read the corresponding revision from the repository (FSFS)?
>
> You really shouldn't be using libsvn_fs_fs directly and should use
> libsvn_repos and libsvn_fs. Beyond that I really don't know what you
> mean by "read the corresponding revision." There are all sorts of
> APIs for getting specific information about a revision. I don't think
> we have a function or a structure to represent an entire revision in
> memory. Generally you get a revision root by using
> svn_fs_revision_root() which gives you a svn_fs_root_t and then you
> use functions against it. You may find the source for svnlook
> particularly instructive since it provides implementations of a lot of
> the type of queries you might want to do. Say you want to find the
> nodes changes in a revision, the changed command does this and it does
> it by retrieving the revision root, determining the base revision and
> then using svn_repos_replay2() to build a svn_repos_node_t tree of the
> changed nodes.
>
> It might be helpful for you to tell us overall what you're doing and
> we might be able to point you in the right direction more quickly than
> answering these one off questions.
>
> > 2 For a variable of svn_stream_t, how can I print the information (e.g.,
> the
> > string) stored in this variable.
>
> If you want something quick and dirty for debugging without worrying
> about encoding you probably want to use
> svn_stream_for_stdout() or svn_stream_for_stderr() to get stdout or
> stderr as a stream and then use svn_stream_copy3().
>
> If you need something more permanent and care about the encoding I
> think you have to use the svn_cmdline_* functions, which don't take
> svn_stream_t's so you'll have to consume the stream with
> svn_stream_read() and then write the output with svn_cmdline_*.
>
Re: two questions in the SVN source code
Posted by Daniel Shahaf <da...@elego.de>.
Ben Reser wrote on Fri, Apr 05, 2013 at 22:50:04 -0700:
> On Fri, Apr 5, 2013 at 10:02 PM, Bo Chen <bo...@gmail.com> wrote:
> > I need help for the following two questions. Any help will be appreciated.
> >
> > 1 Given a revision number, which function can (should be in libsvn_fs_fs/)
> > can read the corresponding revision from the repository (FSFS)?
>
> You really shouldn't be using libsvn_fs_fs directly and should use
> libsvn_repos and libsvn_fs. Beyond that I really don't know what you
> mean by "read the corresponding revision." There are all sorts of
> APIs for getting specific information about a revision. I don't think
> we have a function or a structure to represent an entire revision in
> memory. Generally you get a revision root by using
> svn_fs_revision_root() which gives you a svn_fs_root_t and then you
> use functions against it. You may find the source for svnlook
Note that that's the svn_fs.h way of doing things, i.e., the
lowest-level public API we provide. You might want to use libsvn_repos
(or even libsvn_client with file:// URLs) instead, which provide
different APIs (and hide the entire concept of "roots").
> > 2 For a variable of svn_stream_t, how can I print the information (e.g., the
> > string) stored in this variable.
>
The information is not stored in the variable.
svn_stream_t is an opaque struct, but if you look up its definition
you'll see it only contains an svn_read_fn_t and an svn_write_fn_t.
In other words, the "string" the variable represents is not stored in
it.
(Oh, and there are APIs for converting streams to/from
svn_stringbuf_t's, which you might find useful.)
Daniel
> If you want something quick and dirty for debugging without worrying
> about encoding you probably want to use
> svn_stream_for_stdout() or svn_stream_for_stderr() to get stdout or
> stderr as a stream and then use svn_stream_copy3().
>
> If you need something more permanent and care about the encoding I
> think you have to use the svn_cmdline_* functions, which don't take
> svn_stream_t's so you'll have to consume the stream with
> svn_stream_read() and then write the output with svn_cmdline_*.
Re: two questions in the SVN source code
Posted by Ben Reser <be...@reser.org>.
On Fri, Apr 5, 2013 at 10:02 PM, Bo Chen <bo...@gmail.com> wrote:
> I need help for the following two questions. Any help will be appreciated.
>
> 1 Given a revision number, which function can (should be in libsvn_fs_fs/)
> can read the corresponding revision from the repository (FSFS)?
You really shouldn't be using libsvn_fs_fs directly and should use
libsvn_repos and libsvn_fs. Beyond that I really don't know what you
mean by "read the corresponding revision." There are all sorts of
APIs for getting specific information about a revision. I don't think
we have a function or a structure to represent an entire revision in
memory. Generally you get a revision root by using
svn_fs_revision_root() which gives you a svn_fs_root_t and then you
use functions against it. You may find the source for svnlook
particularly instructive since it provides implementations of a lot of
the type of queries you might want to do. Say you want to find the
nodes changes in a revision, the changed command does this and it does
it by retrieving the revision root, determining the base revision and
then using svn_repos_replay2() to build a svn_repos_node_t tree of the
changed nodes.
It might be helpful for you to tell us overall what you're doing and
we might be able to point you in the right direction more quickly than
answering these one off questions.
> 2 For a variable of svn_stream_t, how can I print the information (e.g., the
> string) stored in this variable.
If you want something quick and dirty for debugging without worrying
about encoding you probably want to use
svn_stream_for_stdout() or svn_stream_for_stderr() to get stdout or
stderr as a stream and then use svn_stream_copy3().
If you need something more permanent and care about the encoding I
think you have to use the svn_cmdline_* functions, which don't take
svn_stream_t's so you'll have to consume the stream with
svn_stream_read() and then write the output with svn_cmdline_*.