revert.c File Reference

revert action. More...

#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <subversion-1/svn_delta.h>
#include <subversion-1/svn_ra.h>
#include "revert.h"
#include "waa.h"
#include "est_ops.h"
#include "racallback.h"
#include "warnings.h"
#include "resolve.h"
#include "checksum.h"
#include "props.h"
#include "helper.h"
#include "url.h"
#include "update.h"
#include "cp_mv.h"
#include "status.h"
Include dependency graph for revert.c:

Go to the source code of this file.

Defines

#define REV___GETFILE_MAX_CACHE   (4)

Enumerations

enum  rev___dir_change_flag_e { NOT_CHANGED = 0, REVERT_MTIME = 1, SET_CURRENT = 2, GET_TSTAMP = 0x1000 }
 

List of (bit-)flags for rev___undo_change().

More...

Functions

int rev__get_text_to_stream (char *loc_url, svn_revnum_t revision, const char *decoder, svn_stream_t *output, struct estat *sts_for_manber, struct estat *output_sts, apr_hash_t **props, apr_pool_t *pool)
 -.
int rev__get_text_to_tmpfile (char *loc_url, svn_revnum_t revision, char *encoder, char *filename_base, char **filename, struct estat *sts_for_manber, struct estat *output_sts, apr_hash_t **props, apr_pool_t *pool)
 -.
int rev__get_text_into_buffer (char *loc_url, svn_revnum_t revision, const char *decoder, svn_stringbuf_t **output, struct estat *sts_for_manber, struct estat *output_sts, apr_hash_t **props, apr_pool_t *pool)
 -.
int rev__install_file (struct estat *sts, svn_revnum_t revision, char *decoder, apr_pool_t *pool)
 -.
int rev__merge (struct estat *sts, const char *file1, const char *common, const char *file2)
 -.
int rev__get_props (struct estat *sts, char *utf8_path, svn_revnum_t revision, apr_pool_t *pool)
 -.
int rev___handle_dir_mtime (struct estat *dir, enum rev___dir_change_flag_e dir_flag)
 Set, reset or fetch the mtime of a directory.
int rev___revert_to_base (struct estat *sts, enum rev___dir_change_flag_e *dir_change_flag, apr_pool_t *pool)
 Revert action, called for every wanted entry.
int rev___no_local_change (struct estat *sts)
 Reset local changes.
int rev___local_revert (struct estat *dir, apr_pool_t *pool)
 -.
int rev__work (struct estat *root, int argc, char *argv[])
 -.
int rev___undo_change (struct estat *sts, enum rev___dir_change_flag_e *dir_change_flag, apr_pool_t *pool)
 Takes the sts->remote_status, and does the changes mentioned there.
int rev__do_changed (struct estat *dir, apr_pool_t *pool)
 -.

Variables

static int number_reverted = 0
 A count of files reverted in this run.
static svn_revnum_t last_rev

Detailed Description

revert action.

This reverts local changes, ie. resets the given paths to the repository versions. This cannot be undone by fsvs - keep backups :-)

Definition in file revert.c.


Define Documentation

#define REV___GETFILE_MAX_CACHE   (4)

Definition at line 151 of file revert.c.


Enumeration Type Documentation

List of (bit-)flags for rev___undo_change().

These have an order, ie. SET_CURRENT overrides REVERT_MTIME.

Enumerator:
NOT_CHANGED 
REVERT_MTIME 
SET_CURRENT 
GET_TSTAMP 

Definition at line 138 of file revert.c.


Function Documentation

int rev___handle_dir_mtime ( struct estat dir,
enum rev___dir_change_flag_e  dir_flag 
)

Set, reset or fetch the mtime of a directory.

Definition at line 721 of file revert.c.

References DEBUGP, estat::entry_status, estat::flags, FS_CHANGED, FS_META_CHANGED, FS_META_MTIME, GET_TSTAMP, hlp__lstat(), sstat_t::mtim, ops__build_path(), estat::remote_status, REVERT_MTIME, RF_CHECK, SET_CURRENT, estat::st, STOPIF, and up__set_meta_data().

Referenced by rev___local_revert(), and rev__do_changed().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev___local_revert ( struct estat dir,
apr_pool_t *  pool 
)

-.

Recurses for rev___revert_to_base.

There's a bit of uglyness here, regarding deleted directories ...

1) If we do the tree depth-first, we have to build multiple levels of directories at once - and store which have to have their meta-data reset.

2) If we do level after level, we might end up with either a) re-creating a directory, doing its children, then have to re-set the meta-data of this directory, or b) just store that the meta-data has to be done for later.

Currently we do 2a - that seems the simplest, and has no big performance penalty.

Definition at line 964 of file revert.c.

References estat::by_inode, DEBUGP, estat::do_this_entry, estat::entry_count, estat::entry_status, FS__CHANGE_MASK, FS_CHILD_CHANGED, sstat_t::mode, estat::name, NOT_CHANGED, ops__allowed_by_filter(), ops__free_marked(), estat::parent, rev___handle_dir_mtime(), rev___revert_to_base(), estat::st, st__status, st__status_string_fromint(), and STOPIF.

Referenced by rev__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev___no_local_change ( struct estat sts  ) 

Reset local changes.

Definition at line 941 of file revert.c.

References estat::entry_status, and st__progress.

Referenced by rev__work().

Here is the caller graph for this function:

int rev___revert_to_base ( struct estat sts,
enum rev___dir_change_flag_e dir_change_flag,
apr_pool_t *  pool 
)

Revert action, called for every wanted entry.

Please note that contacting the repository is allowed, as we're only looping through the local entries.

Doing operations against the repository while being called *from* the ra layer (eg. during an update) is not allowed! See also svn_ra_do_update():

 The caller may not perform any RA operations using @a session before
 finishing the report, and may not perform any RA operations using
 @a session from within the editing operations of @a update_editor.

We may not change sts->entry_status - the caller still needs it; and as this is a revert to BASE, we must not modify the entry list either.

Definition at line 794 of file revert.c.

References DEBUGP, estat::decoder, estat::entry_status, estat::flags, FS__CHANGE_MASK, FS_META_CHANGED, FS_NEW, FS_REMOVED, hlp__rev_to_string(), last_rev, sstat_t::mode, number_reverted, estat::old, ops__build_path(), opt__verbosity(), opt_target_revision, opt_target_revisions_given, estat::parent, estat::remote_status, estat::repos_rev, res__remove_aux_files(), rev__install_file(), REVERT_MTIME, RF_ADD, RF_CHECK, RF_CONFLICT, RF_COPY_BASE, RF_COPY_SUB, RF_PRINT, RF_UNVERSION, estat::st, st__status_string_fromint(), STOPIF, estat::to_be_ignored, up__set_meta_data(), estat::url, and VERBOSITY_VERYQUIET.

Referenced by rev___local_revert().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev___undo_change ( struct estat sts,
enum rev___dir_change_flag_e dir_change_flag,
apr_pool_t *  pool 
)
int rev__do_changed ( struct estat dir,
apr_pool_t *  pool 
)

-.

Go through the tree, and fetch all changed entries (estimated per remote_status).

Used on update.

Definition at line 1344 of file revert.c.

References estat::by_inode, DEBUGP, estat::entry_count, estat::entry_status, estat::flags, FS__CHANGE_MASK, FS_CHILD_CHANGED, FS_NEW, FS_REMOVED, FS_REPLACED, sstat_t::mode, estat::name, NOT_CHANGED, ops__free_marked(), estat::parent, estat::remote_status, rev___handle_dir_mtime(), rev___undo_change(), rev__do_changed(), REVERT_MTIME, RF_CHECK, estat::st, st__rm_status, and STOPIF.

Referenced by rev__do_changed(), rev__work(), and up__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__get_props ( struct estat sts,
char *  utf8_path,
svn_revnum_t  revision,
apr_pool_t *  pool 
)

-.

Gets and writes the properties of the given sts into its prop file.

Definition at line 687 of file revert.c.

References current_url, filename, hlp__local2utf8(), ops__build_path(), prp__set_from_aprhash(), url_t::session, STOPIF, STOPIF_SVNERR, and STORE_IN_FS.

Referenced by rev___undo_change().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__get_text_into_buffer ( char *  loc_url,
svn_revnum_t  revision,
const char *  decoder,
svn_stringbuf_t **  output,
struct estat sts_for_manber,
struct estat output_sts,
apr_hash_t **  props,
apr_pool_t *  pool 
)

-.

Just a wrapper for rev__get_text_to_stream().

Does no validation of input - might fill entire memory.

Definition at line 381 of file revert.c.

References rev__get_text_to_stream(), and STOPIF.

Referenced by sync___recurse().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__get_text_to_stream ( char *  loc_url,
svn_revnum_t  revision,
const char *  decoder,
svn_stream_t *  output,
struct estat sts_for_manber,
struct estat output_sts,
apr_hash_t **  props,
apr_pool_t *  pool 
)

-.

General function to get a file into a stream.

This function fetches an non-directory entry loc_url from the repository in current_url, and writes it to output - which gets closed via svn_stream_close().

decoder should be set correctly.

Todo:
if it's NULL, but an update-pipe is set on the entry, the data has to be read from disk again, to be correctly processed.

No meta-data is set, and the svn:special attribute is ignored.

The revision number must be valid, it may not be SVN_INVALID_REVNUM.

If sts_for_manber is NULL, no manber hashes are calculated.

If output_sts is NULL, the meta-data properties are kept in props; else its fields are filled (as far as possible) with data. That includes the estat::repos_rev field.

The user-specified properties can be returned in props.

As this just returns the data in a stream, the files' type mostly doesn't matter; it just may not be a directory, because we'd get an error from subversion.

loc_url must be given in the current locale; it will be converted to UTF8 before being sent to the subversion libraries.

Definition at line 182 of file revert.c.

References cs__new_manber_filter(), current_url, DEBUGP, DECODER_UNKNOWN, FSVS_EXP_TARGET_REVISION, hlp__encode_filter(), hlp__local2utf8(), hlp__rev_to_string(), estat::md5, ONLY_KEEP_USERDEF, encoder_t::output_md5, propval_updatepipe, prp__set_from_aprhash(), estat::repos_rev, url_t::session, STOPIF, STOPIF_SVNERR, STOPIF_SVNERR_TEXT, url_t::url, and url_t::urllen.

Referenced by cat__work(), rev__get_text_into_buffer(), rev__get_text_to_tmpfile(), and rev__install_file().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__get_text_to_tmpfile ( char *  loc_url,
svn_revnum_t  revision,
char *  encoder,
char *  filename_base,
char **  filename,
struct estat sts_for_manber,
struct estat output_sts,
apr_hash_t **  props,
apr_pool_t *  pool 
)

-.

Gets the entry into a temporary file.

Mostly the same as rev__get_text_to_stream(), but returning a (temporary) filename based on filename_base, if this is not NULL.

The entries' file type isn't taken into account; the file may have the data "symlink XXX", etc.

If filename_base is NULL, the file will be put in a real temporary location.

output_stat is used to store the parsed properties of the entry.

Definition at line 350 of file revert.c.

References rev__get_text_to_stream(), STOPIF, and waa__get_tmp_name().

Referenced by df__do_diff().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__install_file ( struct estat sts,
svn_revnum_t  revision,
char *  decoder,
apr_pool_t *  pool 
)

-.

Gets a clean copy from the repository.

Meta-data is set; an existing local entry gets atomically removed by rename().

If the entry has no URL defined yet, but has a copy flag set (RF_COPY_BASE or RF_COPY_SUB), this URL is taken.

If revision is 0, the BASE revision is and decoder is used; this is the copy base for copied entries.

Definition at line 417 of file revert.c.

References BUG, BUG_ON, cm__get_source(), current_url, DEBUGP, estat::decoder, DECODER_UNKNOWN, filename, filename_tmp, estat::flags, FS_META_CHANGED, hlp__lstat(), estat::local_mode_packed, sstat_t::mode, MODE_T_to_PACKED, estat::new_rev_mode_packed, ops__build_path(), ops__read_special_entry(), estat::parent, propname_special, prp__set_from_aprhash(), estat::remote_status, estat::repos_rev, rev__get_text_to_stream(), RF___IS_COPY, estat::st, STOPIF, STOPIF_CODE_ERR, STORE_IN_FS, estat::to_be_sorted, up__fetch_decoder(), up__handle_special(), up__set_meta_data(), estat::url, url__find(), url__open_session(), waa__delete_byext(), WAA__FILE_MD5s_EXT, waa__get_tmp_name(), and waa__mkdir().

Referenced by rev___revert_to_base(), and rev___undo_change().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__merge ( struct estat sts,
const char *  file1,
const char *  common,
const char *  file2 
)

-.

The base name of the sts gets written to.

If the merge gives no errors, the temporary files get deleted.

Definition at line 584 of file revert.c.

References DEBUGP, FSVS_EXP_CURR_ENTRY, hlp__lstat(), sstat_t::mtim, ops__build_path(), OPT__MERGE_OPT, OPT__MERGE_PRG, res__mark_conflict(), estat::st, STOPIF, STOPIF_CODE_ERR, and up__set_meta_data().

Referenced by rev___undo_change().

Here is the call graph for this function:

Here is the caller graph for this function:

int rev__work ( struct estat root,
int  argc,
char *  argv[] 
)

Variable Documentation

svn_revnum_t last_rev [static]

Definition at line 148 of file revert.c.

Referenced by rev___revert_to_base().

int number_reverted = 0 [static]

A count of files reverted in this run.

Definition at line 147 of file revert.c.

Referenced by rev___revert_to_base().


Generated for fsvs by  doxygen 1.6.1