commit.c File Reference

commit action. More...

#include <apr_md5.h>
#include <apr_pools.h>
#include <apr_user.h>
#include <apr_file_io.h>
#include <subversion-1/svn_delta.h>
#include <subversion-1/svn_ra.h>
#include <subversion-1/svn_error.h>
#include <subversion-1/svn_string.h>
#include <subversion-1/svn_time.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include "global.h"
#include "status.h"
#include "checksum.h"
#include "waa.h"
#include "cache.h"
#include "est_ops.h"
#include "props.h"
#include "options.h"
#include "ignore.h"
#include "cp_mv.h"
#include "racallback.h"
#include "url.h"
#include "helper.h"
Include dependency graph for commit.c:

Go to the source code of this file.

Defines

#define TEST_FOR_OUT_OF_DATE(_sts, _s_er,...)

Typedefs

typedef svn_error_t *(* change_any_prop_t )(void *baton, const char *name, const svn_string_t *value, apr_pool_t *pool)
 Typedef needed for ci___send_user_props().

Functions

int ci__set_revision (struct estat *this, svn_revnum_t rev)
 -.
svn_error_t * ci__callback (svn_revnum_t new_revision, const char *utf8_date, const char *utf8_author, void *baton)
 Callback for successfull commits.
int ci__action (struct estat *sts)
 -.
void ci___unset_copyflags (struct estat *root)
 Removes the flags saying that this entry was copied, recursively.
int ci___send_user_props (void *baton, struct estat *sts, change_any_prop_t function, int store_encoder, apr_pool_t *pool)
 Send the user-defined properties.
svn_error_t * ci___set_props (void *baton, struct estat *sts, change_any_prop_t function, apr_pool_t *pool)
 Send the meta-data-properties for baton.
svn_error_t * ci__nondir (const svn_delta_editor_t *editor, struct estat *sts, void *baton, apr_pool_t *pool)
 Commit function for non-directory entries.
STOPIF_SVNERR_INDIR

Commit function for directories.



int ci__getmsg (char **filename)
 Start an editor, to get a commit message.
svn_error_t * ci___base_dirs (char *current_missing, const svn_delta_editor_t *editor, struct estat *root, void *dir_baton)
 Creates base directories from missing_path_utf8, if necessary, and calls ci__directory().
int ci__work (struct estat *root, int argc, char *argv[])
 The main commit function.

Variables

unsigned committed_entries
 Counts the entries committed on the current URL.
char * missing_path_utf8
 Remembers the to-be-made path in the repository, in UTF-8.
int missing_path_utf8_len
 The precalculated length.

Detailed Description

commit action.

This is a bit hairy in that the order in which we process files (sorted by inode, not in the directory structure) is not allowed for a subversion editor.

We have to read the complete tree, get the changes and store what we want to do, and send these changes in a second run.

Committing two revisions at once

Handling identical files; using hardlinks; creating two revisions on commit.

There are some use-cases where we'd like to store the data only a single time in the repository, so that multiple files are seen as identical:

Definition in file commit.c.


Define Documentation

#define TEST_FOR_OUT_OF_DATE ( _sts,
_s_er,
...   ) 
Value:
do { if (_s_er) {                                        \
        if (_s_er->apr_err == SVN_ERR_FS_TXN_OUT_OF_DATE)      \
        {                                                      \
            char *filename;                                      \
            if (ops__build_path(&filename, _sts))                \
                filename="(internal error)";                       \
            STOPIF( EBUSY,                                       \
                    "!The entry \"%s\" is out-of-date;\n"            \
                    "Please update your working copy.",              \
                    filename);                                       \
            goto ex;                                             \
        }                                                      \
        STOPIF( EBUSY, __VA_ARGS__);                           \
    } } while (0)

Definition at line 224 of file commit.c.

Referenced by ci___send_user_props(), and ci___set_props().


Typedef Documentation

typedef svn_error_t*(* change_any_prop_t)(void *baton, const char *name, const svn_string_t *value, apr_pool_t *pool)

Typedef needed for ci___send_user_props().

See there.

Definition at line 102 of file commit.c.


Function Documentation

svn_error_t* ci___base_dirs ( char *  current_missing,
const svn_delta_editor_t *  editor,
struct estat root,
void *  dir_baton 
)

Creates base directories from missing_path_utf8, if necessary, and calls ci__directory().

current_missing points into missing_path_utf8_len, to the current path spec; editor, root and dir_baton are as in ci__directory().

As the number of directories created this way is normally 0, and for typical non-zero use I'd believe about 3 or 4 levels (maximum), we don't use an extra recursion pool here.

Definition at line 993 of file commit.c.

References BUG_ON, current_url, DEBUGP, missing_path_utf8, url_t::pool, RETURN_SVNERR, and STOPIF_SVNERR.

Referenced by ci__work().

Here is the caller graph for this function:

int ci___send_user_props ( void *  baton,
struct estat sts,
change_any_prop_t  function,
int  store_encoder,
apr_pool_t *  pool 
)

Send the user-defined properties.

The property table is left cleaned up, ie. any deletions that were ordered by the user have been done -- no properties with prp__prop_will_be_removed() will be here.

If store_encoder is set, sts->decoder gets set from the value of the commit-pipe.

auto-props from groupings are sent, too.

Definition at line 253 of file commit.c.

References DEBUGP, estat::decoder, hlp__is_special_property_name(), hlp__strdup(), hsh__close(), hsh__register_delete(), ops__apply_group(), propval_commitpipe, prp__fetch(), prp__first(), prp__next(), prp__prop_will_be_removed(), STOPIF, and TEST_FOR_OUT_OF_DATE.

Referenced by ci__nondir().

Here is the call graph for this function:

Here is the caller graph for this function:

svn_error_t* ci___set_props ( void *  baton,
struct estat sts,
change_any_prop_t  function,
apr_pool_t *  pool 
)

Send the meta-data-properties for baton.

We hope that group/user names are ASCII; the names of "our" properties are known, and contain no characters above \x80.

We get the function passed, because subversion has different property setters for files and directories.

If props is not NULL, we return the properties' handle.

Definition at line 351 of file commit.c.

References sstat_t::gid, hlp__get_grname(), hlp__get_uname(), sstat_t::mode, sstat_t::mtim, propname_group, propname_mtime, propname_owner, propname_umode, RETURN_SVNERR, estat::st, TEST_FOR_OUT_OF_DATE, and sstat_t::uid.

Referenced by ci__nondir().

Here is the call graph for this function:

Here is the caller graph for this function:

void ci___unset_copyflags ( struct estat root  ) 

Removes the flags saying that this entry was copied, recursively.

Does stop on new copy-bases.

Is needed because a simple "cp -a" wouldn't even go down into the child-entries - there's nothing to do there!

Definition at line 198 of file commit.c.

References estat::by_inode, current_url, estat::flags, ops__has_children(), RF_ADD, RF_COPY_BASE, RF_COPY_SUB, and estat::url.

Here is the call graph for this function:

int ci__action ( struct estat sts  ) 

-.

This callback is called by input_tree and build_tree.

Definition at line 170 of file commit.c.

References estat::entry_status, estat::flags, ops__build_path(), ops__mark_parent_cc, RF___COMMIT_MASK, RF_CONFLICT, st__progress, STOPIF, and STOPIF_CODE_ERR.

Here is the call graph for this function:

svn_error_t* ci__callback ( svn_revnum_t  new_revision,
const char *  utf8_date,
const char *  utf8_author,
void *  baton 
)

Callback for successfull commits.

This is the only place that gets the new revision number told.

svn_ra.h does not tell whether these strings are really UTF8. I think they must be ASCII, except if someone uses non-ASCII-user names ... which nobody does.

Definition at line 143 of file commit.c.

References url_t::current_rev, current_url, opt__verbosity(), RETURN_SVNERR, UNUSED, and VERBOSITY_VERYQUIET.

Referenced by ci__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ci__getmsg ( char **  filename  ) 

Start an editor, to get a commit message.

We look for $EDITOR and $VISUAL -- to fall back on good ol' vi.

Definition at line 946 of file commit.c.

References global_pool, hlp__strmnalloc(), opt_commitmsgfile, STOPIF, STOPIF_CODE_ERR, and waa__get_tmp_name().

Referenced by ci__work().

Here is the call graph for this function:

Here is the caller graph for this function:

svn_error_t* ci__nondir ( const svn_delta_editor_t *  editor,
struct estat sts,
void *  baton,
apr_pool_t *  pool 
)
int ci__set_revision ( struct estat this,
svn_revnum_t  rev 
)

-.

Sets the given revision rev recursive on all entries correlating to current_url.

Definition at line 118 of file commit.c.

References ci__set_revision(), and current_url.

Referenced by ci__set_revision(), co__work(), sync__work(), and up__work().

Here is the call graph for this function:

Here is the caller graph for this function:

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

The main commit function.

It does as much setup as possible before traversing the tree - to find errors (no network, etc.) as soon as possible.

The message file gets opened here to verify its existence, and to get a handle to it. If we're doing chdir()s later we don't mind; the open handle let's us read when we need it. And the contents are cached only as long as necessary.

Definition at line 1053 of file commit.c.

References CHCHECK_DIRS, CHCHECK_FILE, ci___base_dirs(), ci__callback(), ci__getmsg(), committed_entries, url_t::current_rev, current_url, DEBUGP, DELAY_COMMIT, global_pool, hlp__delay(), hlp__local2utf8(), hlp__lstat(), hlp__strnalloc(), ign__load_list(), url_t::is_readonly, missing_path_utf8, missing_path_utf8_len, estat::name, ops__allowed_by_filter(), OPT__CHANGECHECK, OPT__COMMIT_TO, OPT__EMPTY_COMMIT, OPT__EMPTY_MESSAGE, OPT__MKDIR_BASE, OPT__NO, opt__set_int(), opt__verbosity(), opt_commitmsg, opt_commitmsgfile, PRIO_MUSTHAVE, url_t::session, estat::st, STOP_HANDLE_SVNERR, STOPIF, STOPIF_CODE_ERR, STOPIF_SVNERR, url_t::url, url__find_by_name(), url__load_nonempty_list(), url__open_session(), url__output_list(), urllist, urllist_count, VERBOSITY_VERYQUIET, waa__find_common_base(), waa__output_tree(), and waa__read_or_build_tree().

Here is the call graph for this function:


Variable Documentation

Counts the entries committed on the current URL.

Definition at line 109 of file commit.c.

Referenced by ci__work().

Remembers the to-be-made path in the repository, in UTF-8.

Definition at line 111 of file commit.c.

Referenced by ci___base_dirs(), and ci__work().

The precalculated length.

Definition at line 113 of file commit.c.

Referenced by ci__work().


Generated for fsvs by  doxygen 1.6.1