On Sat, 2010-06-26 at 08:59 +0100, Julian Foad wrote:
> On Fri, 2010-06-25, Greg Stein wrote:
> > On Fri, Jun 25, 2010 at 08:36, <julianfoad_at_apache.org> wrote:
> > >...
> > > +++ subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c Fri Jun 25 12:36:53 2010
> > >...
> > > + /* Store a pristine text, and set DATA_SHA1 and DATA_MD5. */
> > > + {
> > > + const char *pristine_tmp_dir;
> > > + const char *pristine_tmp_abspath;
> > > + svn_stream_t *pristine_tmp_stream;
> > > + svn_string_t *data_string = svn_string_create(data, pool);
> > > + svn_stream_t *data_stream = svn_stream_from_string(data_string, pool);
> > > +
> > > + SVN_ERR(svn_wc__db_pristine_get_tempdir(&pristine_tmp_dir, db,
> > > + wc_abspath, pool, pool));
> > > + SVN_ERR(svn_stream_open_unique(&pristine_tmp_stream, &pristine_tmp_abspath,
> > > + pristine_tmp_dir, svn_io_file_del_none,
> > > + pool, pool));
> > > +
> > > + data_stream = svn_stream_checksummed2(data_stream, &data_sha1, NULL,
> > > + svn_checksum_sha1, TRUE, pool);
> > > + data_stream = svn_stream_checksummed2(data_stream, &data_md5, NULL,
> > > + svn_checksum_md5, TRUE, pool);
> > > + SVN_ERR(svn_stream_copy3(data_stream, pristine_tmp_stream, NULL, NULL,
> > > + pool));
> >
> > You could just use svn_stream_write(..., data, ...) rather than copying streams.
> >
> > >...
> > > + /* Check that NEW_ABSPATH has been created with the translated text. */
> > > + {
> > > + apr_file_t *file;
> > > + char buf[1000];
> > > + apr_size_t bytes_read;
> > > + svn_error_t *err;
> > > +
> > > + SVN_ERR(svn_io_file_open(&file, new_abspath,
> > > + APR_FOPEN_READ, APR_FPROT_OS_DEFAULT, pool));
> > > + err = svn_io_file_read_full(file, buf, sizeof(buf), &bytes_read, pool);
> > > + if (err && APR_STATUS_IS_EOF(err->apr_err))
> > > + svn_error_clear(err);
> > > + else
> > > + SVN_ERR(err);
> >
> > There is a stream/file function that sucks an entire file into an
> > svn_string_t or somesuch. That would be much easier to use/understand.
>
> I'll try those suggestions later. Thanks.
Simplified in r959321, using svn_stream_printf() for the former and
svn_stream_contents_same2() for the latter.
Thanks.
- Julian
Received on 2010-06-30 16:19:58 CEST