You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2013/02/23 02:25:44 UTC
svn commit: r1449262 [10/25] - in /subversion/branches/ev2-export: ./ build/
build/ac-macros/ build/generator/ build/generator/swig/
build/generator/templates/ build/win32/
contrib/server-side/fsfsfixer/fixer/ contrib/server-side/svncutter/ notes/
note...
Modified: subversion/branches/ev2-export/subversion/libsvn_wc/diff_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_wc/diff_editor.c?rev=1449262&r1=1449261&r2=1449262&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_wc/diff_editor.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_wc/diff_editor.c Sat Feb 23 01:25:38 2013
@@ -55,161 +55,48 @@
#include <apr_hash.h>
#include <apr_md5.h>
+#include <assert.h>
+
#include "svn_error.h"
#include "svn_pools.h"
#include "svn_dirent_uri.h"
#include "svn_path.h"
#include "svn_hash.h"
+#include "svn_sorts.h"
#include "private/svn_subr_private.h"
#include "private/svn_wc_private.h"
+#include "private/svn_diff_tree.h"
#include "private/svn_editor.h"
#include "wc.h"
#include "props.h"
#include "adm_files.h"
#include "translate.h"
+#include "diff.h"
#include "svn_private_config.h"
-
-/*-------------------------------------------------------------------------*/
-/* A little helper function.
-
- You see, when we ask the server to update us to a certain revision,
- we construct the new fulltext, and then run
-
- 'diff <repos_fulltext> <working_fulltext>'
-
- which is, of course, actually backwards from the repository's point
- of view. It thinks we want to move from working->repos.
-
- So when the server sends property changes, they're effectively
- backwards from what we want. We don't want working->repos, but
- repos->working. So this little helper "reverses" the value in
- BASEPROPS and PROPCHANGES before we pass them off to the
- prop_changed() diff-callback. */
-static void
-reverse_propchanges(apr_hash_t *baseprops,
- apr_array_header_t *propchanges,
- apr_pool_t *pool)
-{
- int i;
-
- /* ### todo: research lifetimes for property values below */
-
- for (i = 0; i < propchanges->nelts; i++)
- {
- svn_prop_t *propchange
- = &APR_ARRAY_IDX(propchanges, i, svn_prop_t);
-
- const svn_string_t *original_value =
- apr_hash_get(baseprops, propchange->name, APR_HASH_KEY_STRING);
-
- if ((original_value == NULL) && (propchange->value != NULL))
- {
- /* found an addition. make it look like a deletion. */
- apr_hash_set(baseprops, propchange->name, APR_HASH_KEY_STRING,
- svn_string_dup(propchange->value, pool));
- propchange->value = NULL;
- }
-
- else if ((original_value != NULL) && (propchange->value == NULL))
- {
- /* found a deletion. make it look like an addition. */
- propchange->value = svn_string_dup(original_value, pool);
- apr_hash_set(baseprops, propchange->name, APR_HASH_KEY_STRING,
- NULL);
- }
-
- else if ((original_value != NULL) && (propchange->value != NULL))
- {
- /* found a change. just swap the values. */
- const svn_string_t *str = svn_string_dup(propchange->value, pool);
- propchange->value = svn_string_dup(original_value, pool);
- apr_hash_set(baseprops, propchange->name, APR_HASH_KEY_STRING, str);
- }
- }
-}
-
-
-/* Set *RESULT_ABSPATH to the absolute path to a readable file containing
- the pristine text of LOCAL_ABSPATH in DB, or to NULL if it does not have
- any pristine text.
-
- If USE_BASE is FALSE it gets the pristine text of what is currently in the
- working copy. (So it returns the pristine file of a copy).
-
- If USE_BASE is TRUE, it looks in the lowest layer of the working copy and
- shows exactly what was originally checked out (or updated to).
-
- Rationale:
-
- Which text-base do we want to use for the diff? If the node is replaced
- by a new file, then the base of the replaced file is called (in WC-1) the
- "revert base". If the replacement is a copy or move, then there is also
- the base of the copied file to consider.
-
- One could argue that we should never diff against the revert
- base, and instead diff against the empty-file for both types of
- replacement. After all, there is no ancestry relationship
- between the working file and the base file. But my guess is that
- in practice, users want to see the diff between their working
- file and "the nearest versioned thing", whatever that is. I'm
- not 100% sure this is the right decision, but it at least seems
- to match our test suite's expectations. */
-static svn_error_t *
-get_pristine_file(const char **result_abspath,
- svn_wc__db_t *db,
- const char *local_abspath,
- svn_boolean_t use_base,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- const svn_checksum_t *checksum;
-
- if (!use_base)
- {
- SVN_ERR(svn_wc__db_read_pristine_info(NULL, NULL, NULL, NULL, NULL, NULL,
- &checksum, NULL, NULL, NULL,
- db, local_abspath,
- scratch_pool, scratch_pool));
- }
- else
- {
- SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, &checksum,
- NULL, NULL, NULL, NULL, NULL,
- db, local_abspath,
- scratch_pool, scratch_pool));
- }
-
- if (checksum != NULL)
- {
- SVN_ERR(svn_wc__db_pristine_get_path(result_abspath, db, local_abspath,
- checksum,
- result_pool, scratch_pool));
- return SVN_NO_ERROR;
- }
-
- *result_abspath = NULL;
- return SVN_NO_ERROR;
-}
-
-
/*-------------------------------------------------------------------------*/
/* Overall crawler editor baton.
*/
-struct edit_baton {
+struct edit_baton_t
+{
/* A wc db. */
svn_wc__db_t *db;
+ /* A diff tree processor, receiving the result of the diff. */
+ const svn_diff_tree_processor_t *processor;
+
+ /* A boolean indicating whether local additions should be reported before
+ remote deletes. The processor can transform adds in deletes and deletes
+ in adds, but it can't reorder the output. */
+ svn_boolean_t local_before_remote;
+
/* ANCHOR/TARGET represent the base of the hierarchy to be compared. */
const char *target;
-
- /* The absolute path of the anchor directory */
const char *anchor_abspath;
/* Target revision */
@@ -218,31 +105,14 @@ struct edit_baton {
/* Was the root opened? */
svn_boolean_t root_opened;
- /* The callbacks and callback argument that implement the file comparison
- functions */
- const svn_wc_diff_callbacks4_t *callbacks;
- void *callback_baton;
-
- /* How does this diff descend? */
+ /* How does this diff descend as seen from target? */
svn_depth_t depth;
/* Should this diff ignore node ancestry? */
svn_boolean_t ignore_ancestry;
- /* Should this diff not compare copied files with their source? */
- svn_boolean_t show_copies_as_adds;
-
- /* Are we producing a git-style diff? */
- svn_boolean_t use_git_diff_format;
-
/* Possibly diff repos against text-bases instead of working files. */
- svn_boolean_t use_text_base;
-
- /* Possibly show the diffs backwards. */
- svn_boolean_t reverse_order;
-
- /* Empty file used to diff adds / deletes */
- const char *empty_file;
+ svn_boolean_t diff_pristine;
/* Hash whose keys are const char * changelist names. */
apr_hash_t *changelist_hash;
@@ -256,9 +126,10 @@ struct edit_baton {
/* Directory level baton.
*/
-struct dir_baton {
- /* Gets set if the directory is added rather than replaced/unchanged. */
- svn_boolean_t added;
+struct dir_baton_t
+{
+ /* Reference to parent directory baton (or NULL for the root) */
+ struct dir_baton_t *parent_baton;
/* The depth at which this directory should be diffed. */
svn_depth_t depth;
@@ -266,63 +137,95 @@ struct dir_baton {
/* The name and path of this directory as if they would be/are in the
local working copy. */
const char *name;
+ const char *relpath;
const char *local_abspath;
- /* The "correct" path of the directory, but it may not exist in the
- working copy. */
- const char *path;
+ /* TRUE if the file is added by the editor drive. */
+ svn_boolean_t added;
+ /* TRUE if the node exists only on the repository side (op_depth 0 or added) */
+ svn_boolean_t repos_only;
+ /* TRUE if the node is to be compared with an unrelated node*/
+ svn_boolean_t ignoring_ancestry;
+
+ /* Processor state */
+ void *pdb;
+ svn_boolean_t skip;
+ svn_boolean_t skip_children;
+
+ svn_diff_source_t *left_src;
+ svn_diff_source_t *right_src;
+
+ apr_hash_t *local_info;
+
+ /* A hash containing the basenames of the nodes reported deleted by the
+ repository (or NULL for no values). */
+ apr_hash_t *deletes;
/* Identifies those directory elements that get compared while running
the crawler. These elements should not be compared again when
recursively looking for local modifications.
- This hash maps the full path of the entry to an unimportant value
- (presence in the hash is the important factor here, not the value
- itself).
+ This hash maps the basename of the node to an unimportant value.
If the directory's properties have been compared, an item with hash
- key of path will be present in the hash. */
+ key of "" will be present in the hash. */
apr_hash_t *compared;
/* The list of incoming BASE->repos propchanges. */
apr_array_header_t *propchanges;
+ /* Has a change on regular properties */
+ svn_boolean_t has_propchange;
+
/* The overall crawler editor baton. */
- struct edit_baton *eb;
+ struct edit_baton_t *eb;
apr_pool_t *pool;
+ int users;
};
/* File level baton.
*/
-struct file_baton {
- /* Gets set if the file is added rather than replaced. */
- svn_boolean_t added;
+struct file_baton_t
+{
+ struct dir_baton_t *parent_baton;
/* The name and path of this file as if they would be/are in the
- local working copy. */
+ parent directory, diff session and local working copy. */
const char *name;
+ const char *relpath;
const char *local_abspath;
- /* PATH is the "correct" path of the file, but it may not exist in the
- working copy */
- const char *path;
+ /* Processor state */
+ void *pfb;
+ svn_boolean_t skip;
- /* When constructing the requested repository version of the file, we
- drop the result into a file at TEMP_FILE_PATH. */
- const char *temp_file_path;
+ /* TRUE if the file is added by the editor drive. */
+ svn_boolean_t added;
+ /* TRUE if the node exists only on the repository side (op_depth 0 or added) */
+ svn_boolean_t repos_only;
+ /* TRUE if the node is to be compared with an unrelated node*/
+ svn_boolean_t ignoring_ancestry;
+
+ const svn_diff_source_t *left_src;
+ const svn_diff_source_t *right_src;
/* The list of incoming BASE->repos propchanges. */
apr_array_header_t *propchanges;
- /* The current checksum on disk */
+ /* Has a change on regular properties */
+ svn_boolean_t has_propchange;
+
+ /* The current BASE checksum and props */
const svn_checksum_t *base_checksum;
+ apr_hash_t *base_props;
- /* The resulting checksum from apply_textdelta */
- svn_checksum_t *result_checksum;
+ /* The resulting from apply_textdelta */
+ const char *temp_file_path;
+ unsigned char result_digest[APR_MD5_DIGESTSIZE];
/* The overall crawler editor baton. */
- struct edit_baton *eb;
+ struct edit_baton_t *eb;
apr_pool_t *pool;
};
@@ -342,7 +245,7 @@ struct file_baton {
* filtering is requested.
*/
static svn_error_t *
-make_edit_baton(struct edit_baton **edit_baton,
+make_edit_baton(struct edit_baton_t **edit_baton,
svn_wc__db_t *db,
const char *anchor_abspath,
const char *target,
@@ -351,7 +254,6 @@ make_edit_baton(struct edit_baton **edit
svn_depth_t depth,
svn_boolean_t ignore_ancestry,
svn_boolean_t show_copies_as_adds,
- svn_boolean_t use_git_diff_format,
svn_boolean_t use_text_base,
svn_boolean_t reverse_order,
const apr_array_header_t *changelist_filter,
@@ -360,7 +262,8 @@ make_edit_baton(struct edit_baton **edit
apr_pool_t *pool)
{
apr_hash_t *changelist_hash = NULL;
- struct edit_baton *eb;
+ struct edit_baton_t *eb;
+ const svn_diff_tree_processor_t *processor;
SVN_ERR_ASSERT(svn_dirent_is_absolute(anchor_abspath));
@@ -368,18 +271,30 @@ make_edit_baton(struct edit_baton **edit
SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelist_filter,
pool));
+ SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
+ callbacks, callback_baton, TRUE,
+ pool, pool));
+
+ if (reverse_order)
+ processor = svn_diff__tree_processor_reverse_create(processor, NULL, pool);
+
+ /* --show-copies-as-adds implies --notice-ancestry */
+ if (show_copies_as_adds)
+ ignore_ancestry = FALSE;
+
+ if (! show_copies_as_adds)
+ processor = svn_diff__tree_processor_copy_as_changed_create(processor,
+ pool);
+
eb = apr_pcalloc(pool, sizeof(*eb));
eb->db = db;
eb->anchor_abspath = apr_pstrdup(pool, anchor_abspath);
eb->target = apr_pstrdup(pool, target);
- eb->callbacks = callbacks;
- eb->callback_baton = callback_baton;
+ eb->processor = processor;
eb->depth = depth;
eb->ignore_ancestry = ignore_ancestry;
- eb->show_copies_as_adds = show_copies_as_adds;
- eb->use_git_diff_format = use_git_diff_format;
- eb->use_text_base = use_text_base;
- eb->reverse_order = reverse_order;
+ eb->local_before_remote = reverse_order;
+ eb->diff_pristine = use_text_base;
eb->changelist_hash = changelist_hash;
eb->cancel_func = cancel_func;
eb->cancel_baton = cancel_baton;
@@ -397,32 +312,38 @@ make_edit_baton(struct edit_baton **edit
* exist in the working copy. EDIT_BATON is the overall crawler
* editor baton.
*/
-static struct dir_baton *
+static struct dir_baton_t *
make_dir_baton(const char *path,
- struct dir_baton *parent_baton,
- struct edit_baton *eb,
+ struct dir_baton_t *parent_baton,
+ struct edit_baton_t *eb,
svn_boolean_t added,
svn_depth_t depth,
apr_pool_t *result_pool)
{
- apr_pool_t *dir_pool = svn_pool_create(result_pool);
- struct dir_baton *db = apr_pcalloc(dir_pool, sizeof(*db));
+ apr_pool_t *dir_pool = svn_pool_create(parent_baton ? parent_baton->pool
+ : eb->pool);
+ struct dir_baton_t *db = apr_pcalloc(dir_pool, sizeof(*db));
+
+ db->parent_baton = parent_baton;
+
+ /* Allocate 1 string for using as 3 strings */
+ db->local_abspath = svn_dirent_join(eb->anchor_abspath, path, dir_pool);
+ db->relpath = svn_dirent_skip_ancestor(eb->anchor_abspath, db->local_abspath);
+ db->name = svn_dirent_basename(db->relpath, NULL);
db->eb = eb;
db->added = added;
db->depth = depth;
db->pool = dir_pool;
- db->propchanges = apr_array_make(dir_pool, 1, sizeof(svn_prop_t));
+ db->propchanges = apr_array_make(dir_pool, 8, sizeof(svn_prop_t));
db->compared = apr_hash_make(dir_pool);
- db->path = apr_pstrdup(dir_pool, path);
-
- db->name = svn_dirent_basename(db->path, NULL);
if (parent_baton != NULL)
- db->local_abspath = svn_dirent_join(parent_baton->local_abspath, db->name,
- dir_pool);
- else
- db->local_abspath = apr_pstrdup(dir_pool, eb->anchor_abspath);
+ {
+ parent_baton->users++;
+ }
+
+ db->users = 1;
return db;
}
@@ -432,336 +353,245 @@ make_dir_baton(const char *path,
* replaced. PARENT_BATON is the baton of the parent directory.
* The directory and its parent may or may not exist in the working copy.
*/
-static struct file_baton *
+static struct file_baton_t *
make_file_baton(const char *path,
svn_boolean_t added,
- struct dir_baton *parent_baton,
+ struct dir_baton_t *parent_baton,
apr_pool_t *result_pool)
{
apr_pool_t *file_pool = svn_pool_create(result_pool);
- struct file_baton *fb = apr_pcalloc(file_pool, sizeof(*fb));
- struct edit_baton *eb = parent_baton->eb;
+ struct file_baton_t *fb = apr_pcalloc(file_pool, sizeof(*fb));
+ struct edit_baton_t *eb = parent_baton->eb;
fb->eb = eb;
+ fb->parent_baton = parent_baton;
+ fb->parent_baton->users++;
+
+ /* Allocate 1 string for using as 3 strings */
+ fb->local_abspath = svn_dirent_join(eb->anchor_abspath, path, file_pool);
+ fb->relpath = svn_dirent_skip_ancestor(eb->anchor_abspath, fb->local_abspath);
+ fb->name = svn_dirent_basename(fb->relpath, NULL);
+
fb->added = added;
fb->pool = file_pool;
- fb->propchanges = apr_array_make(file_pool, 1, sizeof(svn_prop_t));
- fb->path = apr_pstrdup(file_pool, path);
-
- fb->name = svn_dirent_basename(fb->path, NULL);
- fb->local_abspath = svn_dirent_join(parent_baton->local_abspath, fb->name,
- file_pool);
+ fb->propchanges = apr_array_make(file_pool, 8, sizeof(svn_prop_t));
return fb;
}
-/* Get the empty file associated with the edit baton. This is cached so
- * that it can be reused, all empty files are the same.
- */
+/* Destroy DB when there are no more registered users */
static svn_error_t *
-get_empty_file(struct edit_baton *b,
- const char **empty_file)
+maybe_done(struct dir_baton_t *db)
{
- /* Create the file if it does not exist */
- /* Note that we tried to use /dev/null in r857294, but
- that won't work on Windows: it's impossible to stat NUL */
- if (!b->empty_file)
- {
- SVN_ERR(svn_io_open_unique_file3(NULL, &b->empty_file, NULL,
- svn_io_file_del_on_pool_cleanup,
- b->pool, b->pool));
- }
-
- *empty_file = b->empty_file;
-
- return SVN_NO_ERROR;
-}
+ db->users--;
+ if (!db->users)
+ {
+ struct dir_baton_t *pb = db->parent_baton;
-/* Return the value of the svn:mime-type property held in PROPS, or NULL
- if no such property exists. */
-static const char *
-get_prop_mimetype(apr_hash_t *props)
-{
- return svn_prop_get_value(props, SVN_PROP_MIME_TYPE);
-}
-
+ svn_pool_clear(db->pool);
-/* Return the property hash resulting from combining PROPS and PROPCHANGES.
- *
- * A note on pool usage: The returned hash and hash keys are allocated in
- * the same pool as PROPS, but the hash values will be taken directly from
- * either PROPS or PROPCHANGES, as appropriate. Caller must therefore
- * ensure that the returned hash is only used for as long as PROPS and
- * PROPCHANGES remain valid.
- */
-static apr_hash_t *
-apply_propchanges(apr_hash_t *props,
- const apr_array_header_t *propchanges)
-{
- apr_hash_t *newprops = apr_hash_copy(apr_hash_pool_get(props), props);
- int i;
-
- for (i = 0; i < propchanges->nelts; ++i)
- {
- const svn_prop_t *prop = &APR_ARRAY_IDX(propchanges, i, svn_prop_t);
- apr_hash_set(newprops, prop->name, APR_HASH_KEY_STRING, prop->value);
+ if (pb != NULL)
+ SVN_ERR(maybe_done(pb));
}
- return newprops;
+ return SVN_NO_ERROR;
}
+/* Standard check to see if a node is represented in the local working copy */
+#define NOT_PRESENT(status) \
+ ((status) == svn_wc__db_status_not_present \
+ || (status) == svn_wc__db_status_excluded \
+ || (status) == svn_wc__db_status_server_excluded)
-/* Diff the file PATH against its text base. At this
- * stage we are dealing with a file that does exist in the working copy.
- *
- * DIR_BATON is the parent directory baton, PATH is the path to the file to
- * be compared.
- *
- * Do all allocation in POOL.
- *
- * ### TODO: Need to work on replace if the new filename used to be a
- * directory.
- */
-static svn_error_t *
-file_diff(struct edit_baton *eb,
- const char *local_abspath,
- const char *path,
- apr_pool_t *scratch_pool)
+svn_error_t *
+svn_wc__diff_base_working_diff(svn_wc__db_t *db,
+ const char *local_abspath,
+ const char *relpath,
+ svn_revnum_t revision,
+ apr_hash_t *changelist_hash,
+ const svn_diff_tree_processor_t *processor,
+ void *processor_dir_baton,
+ svn_boolean_t diff_pristine,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *scratch_pool)
{
- svn_wc__db_t *db = eb->db;
- const char *textbase;
- const char *empty_file;
- svn_boolean_t replaced;
+ void *file_baton = NULL;
+ svn_boolean_t skip = FALSE;
svn_wc__db_status_t status;
- const char *original_repos_relpath;
- svn_revnum_t revision;
- svn_revnum_t revert_base_revnum;
- svn_boolean_t have_base;
+ svn_revnum_t db_revision;
+ svn_boolean_t had_props;
+ svn_boolean_t props_mod;
+ svn_boolean_t files_same = FALSE;
svn_wc__db_status_t base_status;
- svn_boolean_t use_base = FALSE;
+ const svn_checksum_t *working_checksum;
+ const svn_checksum_t *checksum;
+ svn_filesize_t recorded_size;
+ apr_time_t recorded_time;
+ const char *pristine_file;
+ const char *local_file;
+ svn_diff_source_t *left_src;
+ svn_diff_source_t *right_src;
+ apr_hash_t *base_props;
+ apr_hash_t *local_props;
+ apr_array_header_t *prop_changes;
+ const char *changelist;
+
+ SVN_ERR(svn_wc__db_read_info(&status, NULL, &db_revision, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, &working_checksum, NULL,
+ NULL, NULL, NULL, NULL, NULL, &recorded_size,
+ &recorded_time, &changelist, NULL, NULL,
+ &had_props, &props_mod, NULL, NULL, NULL,
+ db, local_abspath, scratch_pool, scratch_pool));
+ checksum = working_checksum;
- SVN_ERR_ASSERT(! eb->use_text_base);
+ assert(status == svn_wc__db_status_normal
+ || status == svn_wc__db_status_added
+ || (status == svn_wc__db_status_deleted && diff_pristine));
/* If the item is not a member of a specified changelist (and there are
some specified changelists), skip it. */
- if (! svn_wc__internal_changelist_match(db, local_abspath,
- eb->changelist_hash, scratch_pool))
+ if (changelist_hash && !svn_hash_gets(changelist_hash, changelist))
return SVN_NO_ERROR;
- SVN_ERR(svn_wc__db_read_info(&status, NULL, &revision, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL,
- &have_base, NULL, NULL,
- db, local_abspath, scratch_pool, scratch_pool));
- if (have_base)
- SVN_ERR(svn_wc__db_base_get_info(&base_status, NULL, &revert_base_revnum,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- db, local_abspath,
- scratch_pool, scratch_pool));
-
- replaced = ((status == svn_wc__db_status_added)
- && have_base
- && base_status != svn_wc__db_status_not_present);
-
- /* Now refine ADDED to one of: ADDED, COPIED, MOVED_HERE. Note that only
- the latter two have corresponding pristine info to diff against. */
- if (status == svn_wc__db_status_added)
- SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL,
- &original_repos_relpath, NULL, NULL,
- NULL, NULL, NULL, db, local_abspath,
- scratch_pool, scratch_pool));
- /* A wc-wc diff of replaced files actually shows a diff against the
- * revert-base, showing all previous lines as removed and adding all new
- * lines. This does not happen for copied/moved-here files, not even with
- * show_copies_as_adds == TRUE (in which case copy/move is really shown as
- * an add, diffing against the empty file).
- * So show the revert-base revision for plain replaces. */
- if (replaced
- && ! (status == svn_wc__db_status_copied
- || status == svn_wc__db_status_moved_here))
- {
- use_base = TRUE;
- revision = revert_base_revnum;
- }
-
- /* Set TEXTBASE to the path to the text-base file that we want to diff
- against.
-
- ### There shouldn't be cases where the result is NULL, but at present
- there might be - see get_nearest_pristine_text_as_file(). */
- SVN_ERR(get_pristine_file(&textbase, db, local_abspath,
- use_base, scratch_pool, scratch_pool));
-
- SVN_ERR(get_empty_file(eb, &empty_file));
-
- /* Delete compares text-base against empty file, modifications to the
- * working-copy version of the deleted file are not wanted.
- * Replace is treated like a delete plus an add: two comparisons are
- * generated, first one for the delete and then one for the add.
- * However, if this file was replaced and we are ignoring ancestry,
- * report it as a normal file modification instead. */
- if ((! replaced && status == svn_wc__db_status_deleted) ||
- (replaced && ! eb->ignore_ancestry))
+ if (status != svn_wc__db_status_normal)
{
- const char *base_mimetype;
- apr_hash_t *baseprops;
-
- /* Get svn:mime-type from pristine props (in BASE or WORKING) of PATH. */
- SVN_ERR(svn_wc__db_read_pristine_props(&baseprops, db, local_abspath,
- scratch_pool, scratch_pool));
- if (baseprops)
- base_mimetype = get_prop_mimetype(baseprops);
- else
- base_mimetype = NULL;
-
- SVN_ERR(eb->callbacks->file_deleted(NULL, NULL, path,
- textbase,
- empty_file,
- base_mimetype,
- NULL,
- baseprops,
- eb->callback_baton,
- scratch_pool));
+ SVN_ERR(svn_wc__db_base_get_info(&base_status, NULL, &db_revision,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, &checksum, NULL, NULL, &had_props,
+ NULL, NULL,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
+ recorded_size = SVN_INVALID_FILESIZE;
+ recorded_time = 0;
+ props_mod = TRUE; /* Requires compare */
+ }
+ else if (diff_pristine)
+ files_same = TRUE;
+ else
+ {
+ const svn_io_dirent2_t *dirent;
- if (! (replaced && ! eb->ignore_ancestry))
+ SVN_ERR(svn_io_stat_dirent2(&dirent, local_abspath,
+ FALSE /* verify truename */,
+ TRUE /* ingore_enoent */,
+ scratch_pool, scratch_pool));
+
+ if (dirent->kind == svn_node_file
+ && dirent->filesize == recorded_size
+ && dirent->mtime == recorded_time)
{
- /* We're here only for showing a delete, so we're done. */
- return SVN_NO_ERROR;
+ files_same = TRUE;
}
}
- /* Now deal with showing additions, or the add-half of replacements.
- * If the item is schedule-add *with history*, then we usually want
- * to see the usual working vs. text-base comparison, which will show changes
- * made since the file was copied. But in case we're showing copies as adds,
- * we need to compare the copied file to the empty file. If we're doing a git
- * diff, and the file was copied, we need to report the file as added and
- * diff it against the text base, so that a "copied" git diff header, and
- * possibly a diff against the copy source, will be generated for it. */
- if ((! replaced && status == svn_wc__db_status_added) ||
- (replaced && ! eb->ignore_ancestry) ||
- ((status == svn_wc__db_status_copied ||
- status == svn_wc__db_status_moved_here) &&
- (eb->show_copies_as_adds || eb->use_git_diff_format)))
- {
- const char *translated = NULL;
- const char *working_mimetype;
- apr_hash_t *baseprops;
- apr_hash_t *workingprops;
- apr_array_header_t *propchanges;
+ if (files_same && !props_mod)
+ return SVN_NO_ERROR; /* Cheap exit */
+
+ assert(checksum);
- /* Get svn:mime-type from ACTUAL props of PATH. */
- SVN_ERR(svn_wc__get_actual_props(&workingprops, db, local_abspath,
+ if (!SVN_IS_VALID_REVNUM(revision))
+ revision = db_revision;
+
+ left_src = svn_diff__source_create(revision, scratch_pool);
+ right_src = svn_diff__source_create(SVN_INVALID_REVNUM, scratch_pool);
+
+ SVN_ERR(processor->file_opened(&file_baton, &skip, relpath,
+ left_src,
+ right_src,
+ NULL /* copyfrom_src */,
+ processor_dir_baton,
+ processor,
+ scratch_pool, scratch_pool));
+
+ if (skip)
+ return SVN_NO_ERROR;
+
+ SVN_ERR(svn_wc__db_pristine_get_path(&pristine_file,
+ db, local_abspath, checksum,
scratch_pool, scratch_pool));
- working_mimetype = get_prop_mimetype(workingprops);
- /* Set the original properties to empty, then compute "changes" from
- that. Essentially, all ACTUAL props will be "added". */
- baseprops = apr_hash_make(scratch_pool);
- SVN_ERR(svn_prop_diffs(&propchanges, workingprops, baseprops,
- scratch_pool));
+ if (diff_pristine)
+ SVN_ERR(svn_wc__db_pristine_get_path(&local_file,
+ db, local_abspath,
+ working_checksum,
+ scratch_pool, scratch_pool));
+ else if (! (had_props || props_mod))
+ local_file = local_abspath;
+ else if (files_same)
+ local_file = pristine_file;
+ else
+ SVN_ERR(svn_wc__internal_translated_file(
+ &local_file, local_abspath,
+ db, local_abspath,
+ SVN_WC_TRANSLATE_TO_NF
+ | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+ cancel_func, cancel_baton,
+ scratch_pool, scratch_pool));
+
+ if (! files_same)
+ SVN_ERR(svn_io_files_contents_same_p(&files_same, local_file,
+ pristine_file, scratch_pool));
+
+ if (had_props)
+ SVN_ERR(svn_wc__db_base_get_props(&base_props, db, local_abspath,
+ scratch_pool, scratch_pool));
+ else
+ base_props = apr_hash_make(scratch_pool);
- SVN_ERR(svn_wc__internal_translated_file(
- &translated, local_abspath, db, local_abspath,
- SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
- eb->cancel_func, eb->cancel_baton,
- scratch_pool, scratch_pool));
-
- SVN_ERR(eb->callbacks->file_added(NULL, NULL, NULL, path,
- (! eb->show_copies_as_adds &&
- eb->use_git_diff_format &&
- status != svn_wc__db_status_added) ?
- textbase : empty_file,
- translated,
- 0, revision,
- NULL,
- working_mimetype,
- original_repos_relpath,
- SVN_INVALID_REVNUM, propchanges,
- baseprops, eb->callback_baton,
- scratch_pool));
+ if (status == svn_wc__db_status_normal && (diff_pristine || !props_mod))
+ local_props = base_props;
+ else if (diff_pristine)
+ SVN_ERR(svn_wc__db_read_pristine_props(&local_props, db, local_abspath,
+ scratch_pool, scratch_pool));
+ else
+ SVN_ERR(svn_wc__db_read_props(&local_props, db, local_abspath,
+ scratch_pool, scratch_pool));
+
+ SVN_ERR(svn_prop_diffs(&prop_changes, local_props, base_props, scratch_pool));
+
+ if (prop_changes->nelts || !files_same)
+ {
+ SVN_ERR(processor->file_changed(relpath,
+ left_src,
+ right_src,
+ pristine_file,
+ local_file,
+ base_props,
+ local_props,
+ ! files_same,
+ prop_changes,
+ file_baton,
+ processor,
+ scratch_pool));
}
else
{
- const char *translated = NULL;
- apr_hash_t *baseprops;
- const char *base_mimetype;
- const char *working_mimetype;
- apr_hash_t *workingprops;
- apr_array_header_t *propchanges;
- svn_boolean_t modified;
-
- /* Here we deal with showing pure modifications. */
- SVN_ERR(svn_wc__internal_file_modified_p(&modified, db, local_abspath,
- FALSE, scratch_pool));
- if (modified)
- {
- /* Note that this might be the _second_ time we translate
- the file, as svn_wc__text_modified_internal_p() might have used a
- tmp translated copy too. But what the heck, diff is
- already expensive, translating twice for the sake of code
- modularity is liveable. */
- SVN_ERR(svn_wc__internal_translated_file(
- &translated, local_abspath, db, local_abspath,
- SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
- eb->cancel_func, eb->cancel_baton,
- scratch_pool, scratch_pool));
- }
+ SVN_ERR(processor->file_closed(relpath,
+ left_src,
+ right_src,
+ file_baton,
+ processor,
+ scratch_pool));
+ }
- /* Get the properties, the svn:mime-type values, and compute the
- differences between the two. */
- if (replaced
- && eb->ignore_ancestry)
- {
- /* We don't want the normal pristine properties (which are
- from the WORKING tree). We want the pristines associated
- with the BASE tree, which are saved as "revert" props. */
- SVN_ERR(svn_wc__db_base_get_props(&baseprops,
- db, local_abspath,
- scratch_pool, scratch_pool));
- }
- else
- {
- /* We can only fetch the pristine props (from BASE or WORKING) if
- the node has not been replaced, or it was copied/moved here. */
- SVN_ERR_ASSERT(!replaced
- || status == svn_wc__db_status_copied
- || status == svn_wc__db_status_moved_here);
-
- SVN_ERR(svn_wc__db_read_pristine_props(&baseprops, db, local_abspath,
- scratch_pool, scratch_pool));
-
- /* baseprops will be NULL for added nodes */
- if (!baseprops)
- baseprops = apr_hash_make(scratch_pool);
- }
- base_mimetype = get_prop_mimetype(baseprops);
+ return SVN_NO_ERROR;
+}
- SVN_ERR(svn_wc__get_actual_props(&workingprops, db, local_abspath,
- scratch_pool, scratch_pool));
- working_mimetype = get_prop_mimetype(workingprops);
+static svn_error_t *
+ensure_local_info(struct dir_baton_t *db,
+ apr_pool_t *scratch_pool)
+{
+ apr_hash_t *conflicts;
- SVN_ERR(svn_prop_diffs(&propchanges, workingprops, baseprops, scratch_pool));
+ if (db->local_info)
+ return SVN_NO_ERROR;
- if (modified || propchanges->nelts > 0)
- {
- SVN_ERR(eb->callbacks->file_changed(NULL, NULL, NULL,
- path,
- modified ? textbase : NULL,
- translated,
- revision,
- SVN_INVALID_REVNUM,
- base_mimetype,
- working_mimetype,
- propchanges, baseprops,
- eb->callback_baton,
- scratch_pool));
- }
- }
+ SVN_ERR(svn_wc__db_read_children_info(&db->local_info, &conflicts,
+ db->eb->db, db->local_abspath,
+ db->pool, scratch_pool));
return SVN_NO_ERROR;
}
@@ -774,21 +604,27 @@ file_diff(struct edit_baton *eb,
* DIR_BATON is the baton for the directory.
*/
static svn_error_t *
-walk_local_nodes_diff(struct edit_baton *eb,
+walk_local_nodes_diff(struct edit_baton_t *eb,
const char *local_abspath,
const char *path,
svn_depth_t depth,
apr_hash_t *compared,
+ void *parent_baton,
apr_pool_t *scratch_pool)
{
svn_wc__db_t *db = eb->db;
- const apr_array_header_t *children;
- int i;
svn_boolean_t in_anchor_not_target;
apr_pool_t *iterpool;
+ void *dir_baton = NULL;
+ svn_boolean_t skip = FALSE;
+ svn_boolean_t skip_children = FALSE;
+ svn_revnum_t revision;
+ svn_boolean_t props_mod;
+ svn_diff_source_t *left_src;
+ svn_diff_source_t *right_src;
/* Everything we do below is useless if we are comparing to BASE. */
- if (eb->use_text_base)
+ if (eb->diff_pristine)
return SVN_NO_ERROR;
/* Determine if this is the anchor directory if the anchor is different
@@ -797,346 +633,523 @@ walk_local_nodes_diff(struct edit_baton
skipped. */
in_anchor_not_target = ((*path == '\0') && (*eb->target != '\0'));
- /* Check for local property mods on this directory, if we haven't
- already reported them and we aren't changelist-filted.
- ### it should be noted that we do not currently allow directories
- ### to be part of changelists, so if a changelist is provided, the
- ### changelist check will always fail. */
- if (svn_wc__internal_changelist_match(db, local_abspath,
- eb->changelist_hash, scratch_pool)
- && (! in_anchor_not_target)
- && (!compared || ! apr_hash_get(compared, path, 0)))
- {
- svn_boolean_t modified;
-
- SVN_ERR(svn_wc__props_modified(&modified, db, local_abspath,
- scratch_pool));
- if (modified)
- {
- apr_array_header_t *propchanges;
- apr_hash_t *baseprops;
-
- SVN_ERR(svn_wc__internal_propdiff(&propchanges, &baseprops,
- db, local_abspath,
- scratch_pool, scratch_pool));
-
- SVN_ERR(eb->callbacks->dir_props_changed(NULL, NULL,
- path, FALSE /* ### ? */,
- propchanges, baseprops,
- eb->callback_baton,
- scratch_pool));
- }
- }
-
- if (depth == svn_depth_empty && !in_anchor_not_target)
- return SVN_NO_ERROR;
-
iterpool = svn_pool_create(scratch_pool);
- SVN_ERR(svn_wc__db_read_children(&children, db, local_abspath,
- scratch_pool, iterpool));
-
- for (i = 0; i < children->nelts; i++)
- {
- const char *name = APR_ARRAY_IDX(children, i, const char*);
- const char *child_abspath, *child_path;
- svn_wc__db_status_t status;
- svn_kind_t kind;
+ SVN_ERR(svn_wc__db_read_info(NULL, NULL, &revision, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, &props_mod, NULL, NULL, NULL,
+ db, local_abspath, scratch_pool, scratch_pool));
- svn_pool_clear(iterpool);
+ left_src = svn_diff__source_create(revision, scratch_pool);
+ right_src = svn_diff__source_create(SVN_INVALID_REVNUM, scratch_pool);
- if (eb->cancel_func)
- SVN_ERR(eb->cancel_func(eb->cancel_baton));
+ if (compared)
+ {
+ dir_baton = parent_baton;
+ skip = TRUE;
+ }
+ else if (!in_anchor_not_target)
+ SVN_ERR(eb->processor->dir_opened(&dir_baton, &skip, &skip_children,
+ path,
+ left_src,
+ right_src,
+ NULL /* copyfrom_src */,
+ parent_baton,
+ eb->processor,
+ scratch_pool, scratch_pool));
+
+
+ if (!skip_children && depth != svn_depth_empty)
+ {
+ apr_hash_t *nodes;
+ apr_hash_t *conflicts;
+ apr_array_header_t *children;
+ svn_depth_t depth_below_here = depth;
+ svn_boolean_t diff_files;
+ svn_boolean_t diff_dirs;
+ int i;
+
+ if (depth_below_here == svn_depth_immediates)
+ depth_below_here = svn_depth_empty;
+
+ diff_files = (depth == svn_depth_unknown
+ || depth >= svn_depth_files);
+ diff_dirs = (depth == svn_depth_unknown
+ || depth >= svn_depth_immediates);
- /* In the anchor directory, if the anchor is not the target then all
- entries other than the target should not be diff'd. Running diff
- on one file in a directory should not diff other files in that
- directory. */
- if (in_anchor_not_target && strcmp(eb->target, name))
- continue;
+ SVN_ERR(svn_wc__db_read_children_info(&nodes, &conflicts,
+ db, local_abspath,
+ scratch_pool, iterpool));
- child_abspath = svn_dirent_join(local_abspath, name, iterpool);
+ children = svn_sort__hash(nodes, svn_sort_compare_items_lexically,
+ scratch_pool);
- SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- db, child_abspath,
- iterpool, iterpool));
+ for (i = 0; i < children->nelts; i++)
+ {
+ svn_sort__item_t *item = &APR_ARRAY_IDX(children, i,
+ svn_sort__item_t);
+ const char *name = item->key;
+ struct svn_wc__db_info_t *info = item->value;
+
+ const char *child_abspath;
+ const char *child_relpath;
+ svn_boolean_t repos_only;
+ svn_boolean_t local_only;
+ svn_kind_t base_kind;
+
+ if (eb->cancel_func)
+ SVN_ERR(eb->cancel_func(eb->cancel_baton));
+
+ /* In the anchor directory, if the anchor is not the target then all
+ entries other than the target should not be diff'd. Running diff
+ on one file in a directory should not diff other files in that
+ directory. */
+ if (in_anchor_not_target && strcmp(eb->target, name))
+ continue;
+
+ if (compared && svn_hash_gets(compared, name))
+ continue;
+
+ if (NOT_PRESENT(info->status))
+ continue;
+
+ assert(info->status == svn_wc__db_status_normal
+ || info->status == svn_wc__db_status_added
+ || info->status == svn_wc__db_status_deleted);
+
+ svn_pool_clear(iterpool);
+ child_abspath = svn_dirent_join(local_abspath, name, iterpool);
+ child_relpath = svn_relpath_join(path, name, iterpool);
- if (status == svn_wc__db_status_not_present
- || status == svn_wc__db_status_excluded
- || status == svn_wc__db_status_server_excluded)
- continue;
+ repos_only = FALSE;
+ local_only = FALSE;
- child_path = svn_relpath_join(path, name, iterpool);
+ if (!info->have_base)
+ {
+ local_only = TRUE; /* Only report additions */
+ }
+ else if (info->status == svn_wc__db_status_normal)
+ {
+ /* Simple diff */
+ base_kind = info->kind;
+ }
+ else if (info->status == svn_wc__db_status_deleted
+ && (!eb->diff_pristine || !info->have_more_work))
+ {
+ svn_wc__db_status_t base_status;
+ repos_only = TRUE;
+ SVN_ERR(svn_wc__db_base_get_info(&base_status, &base_kind, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ db, child_abspath,
+ iterpool, iterpool));
- /* Skip this node if it is in the list of nodes already diff'd. */
- if (compared && apr_hash_get(compared, child_path, APR_HASH_KEY_STRING))
- continue;
+ if (NOT_PRESENT(base_status))
+ continue;
+ }
+ else
+ {
+ /* working status is either added or deleted */
+ svn_wc__db_status_t base_status;
- switch (kind)
- {
- case svn_kind_file:
- case svn_kind_symlink:
- SVN_ERR(file_diff(eb, child_abspath, child_path, iterpool));
- break;
+ SVN_ERR(svn_wc__db_base_get_info(&base_status, &base_kind, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ db, child_abspath,
+ iterpool, iterpool));
+
+ if (NOT_PRESENT(base_status))
+ local_only = TRUE;
+ else if (base_kind != info->kind || !eb->ignore_ancestry)
+ {
+ repos_only = TRUE;
+ local_only = TRUE;
+ }
+ }
- case svn_kind_dir:
- /* ### TODO: Don't know how to do replaced dirs. How do I get
- information about what is being replaced? If it was a
- directory then the directory elements are also going to be
- deleted. We need to show deletion diffs for these
- files. If it was a file we need to show a deletion diff
- for that file. */
-
- /* Check the subdir if in the anchor (the subdir is the target), or
- if recursive */
- if (in_anchor_not_target
- || (depth > svn_depth_files)
- || (depth == svn_depth_unknown))
+ if (eb->local_before_remote && local_only)
{
- svn_depth_t depth_below_here = depth;
-
- if (depth_below_here == svn_depth_immediates)
- depth_below_here = svn_depth_empty;
+ if (info->kind == svn_kind_file && diff_files)
+ SVN_ERR(svn_wc__diff_local_only_file(db, child_abspath,
+ child_relpath,
+ eb->processor, dir_baton,
+ eb->changelist_hash,
+ eb->diff_pristine,
+ eb->cancel_func,
+ eb->cancel_baton,
+ iterpool));
+ else if (info->kind == svn_kind_dir && diff_dirs)
+ SVN_ERR(svn_wc__diff_local_only_dir(db, child_abspath,
+ child_relpath,
+ depth_below_here,
+ eb->processor, dir_baton,
+ eb->changelist_hash,
+ eb->diff_pristine,
+ eb->cancel_func,
+ eb->cancel_baton,
+ iterpool));
+ }
- SVN_ERR(walk_local_nodes_diff(eb,
- child_abspath,
- child_path,
- depth_below_here,
- NULL,
- iterpool));
+ if (repos_only)
+ {
+ /* Report repository form deleted */
+ if (base_kind == svn_kind_file && diff_files)
+ SVN_ERR(svn_wc__diff_base_only_file(db, child_abspath,
+ child_relpath, eb->revnum,
+ eb->processor, dir_baton,
+ iterpool));
+ else if (base_kind == svn_kind_dir && diff_dirs)
+ SVN_ERR(svn_wc__diff_base_only_dir(db, child_abspath,
+ child_relpath, eb->revnum,
+ depth_below_here,
+ eb->processor, dir_baton,
+ eb->cancel_func,
+ eb->cancel_baton,
+ iterpool));
+ }
+ else if (!local_only) /* Not local only nor remote only */
+ {
+ /* Diff base against actual */
+ if (info->kind == svn_kind_file && diff_files)
+ {
+ if (info->status != svn_wc__db_status_normal
+ || !eb->diff_pristine)
+ {
+ SVN_ERR(svn_wc__diff_base_working_diff(
+ db, child_abspath,
+ child_relpath,
+ eb->revnum,
+ eb->changelist_hash,
+ eb->processor, dir_baton,
+ eb->diff_pristine,
+ eb->cancel_func,
+ eb->cancel_baton,
+ scratch_pool));
+ }
+ }
+ else if (info->kind == svn_kind_dir && diff_dirs)
+ SVN_ERR(walk_local_nodes_diff(eb, child_abspath,
+ child_relpath,
+ depth_below_here,
+ NULL /* compared */,
+ dir_baton,
+ scratch_pool));
}
- break;
- default:
- break;
+ if (!eb->local_before_remote && local_only)
+ {
+ if (info->kind == svn_kind_file && diff_files)
+ SVN_ERR(svn_wc__diff_local_only_file(db, child_abspath,
+ child_relpath,
+ eb->processor, dir_baton,
+ eb->changelist_hash,
+ eb->diff_pristine,
+ eb->cancel_func,
+ eb->cancel_baton,
+ iterpool));
+ else if (info->kind == svn_kind_dir && diff_dirs)
+ SVN_ERR(svn_wc__diff_local_only_dir(db, child_abspath,
+ child_relpath, depth_below_here,
+ eb->processor, dir_baton,
+ eb->changelist_hash,
+ eb->diff_pristine,
+ eb->cancel_func,
+ eb->cancel_baton,
+ iterpool));
+ }
}
}
+ if (compared)
+ return SVN_NO_ERROR;
+
+ /* Check for local property mods on this directory, if we haven't
+ already reported them and we aren't changelist-filted.
+ ### it should be noted that we do not currently allow directories
+ ### to be part of changelists, so if a changelist is provided, the
+ ### changelist check will always fail. */
+ if (! skip
+ && ! eb->changelist_hash
+ && ! in_anchor_not_target
+ && props_mod)
+ {
+ apr_array_header_t *propchanges;
+ apr_hash_t *left_props;
+ apr_hash_t *right_props;
+
+ SVN_ERR(svn_wc__internal_propdiff(&propchanges, &left_props,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
+
+ right_props = svn_prop__patch(left_props, propchanges, scratch_pool);
+
+ SVN_ERR(eb->processor->dir_changed(path,
+ left_src,
+ right_src,
+ left_props,
+ right_props,
+ propchanges,
+ dir_baton,
+ eb->processor,
+ scratch_pool));
+ }
+ else if (! skip)
+ SVN_ERR(eb->processor->dir_closed(path,
+ left_src,
+ right_src,
+ dir_baton,
+ eb->processor,
+ scratch_pool));
+
svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
-/* Report an existing file in the working copy (either in BASE or WORKING)
- * as having been added.
- *
- * DIR_BATON is the parent directory baton, ADM_ACCESS/PATH is the path
- * to the file to be compared.
- *
- * Do all allocation in POOL.
- */
-static svn_error_t *
-report_wc_file_as_added(struct edit_baton *eb,
- const char *local_abspath,
- const char *path,
- apr_pool_t *scratch_pool)
+svn_error_t *
+svn_wc__diff_local_only_file(svn_wc__db_t *db,
+ const char *local_abspath,
+ const char *relpath,
+ const svn_diff_tree_processor_t *processor,
+ void *processor_parent_baton,
+ apr_hash_t *changelist_hash,
+ svn_boolean_t diff_pristine,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *scratch_pool)
{
- svn_wc__db_t *db = eb->db;
- apr_hash_t *emptyprops;
- const char *mimetype;
- apr_hash_t *wcprops = NULL;
- apr_array_header_t *propchanges;
- const char *empty_file;
- const char *source_file;
- const char *translated_file;
+ svn_diff_source_t *right_src;
+ svn_diff_source_t *copyfrom_src = NULL;
svn_wc__db_status_t status;
+ svn_kind_t kind;
+ const svn_checksum_t *checksum;
+ const char *original_repos_relpath;
+ svn_revnum_t original_revision;
+ const char *changelist;
+ svn_boolean_t had_props;
+ svn_boolean_t props_mod;
+ apr_hash_t *pristine_props;
+ apr_hash_t *right_props = NULL;
+ const char *pristine_file;
+ const char *translated_file;
svn_revnum_t revision;
-
- /* If this entry is filtered by changelist specification, do nothing. */
- if (! svn_wc__internal_changelist_match(db, local_abspath,
- eb->changelist_hash, scratch_pool))
- return SVN_NO_ERROR;
-
- SVN_ERR(get_empty_file(eb, &empty_file));
-
- SVN_ERR(svn_wc__db_read_info(&status, NULL, &revision, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ void *file_baton = NULL;
+ svn_boolean_t skip = FALSE;
+ svn_boolean_t file_mod = TRUE;
+
+ SVN_ERR(svn_wc__db_read_info(&status, &kind, &revision, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, &checksum, NULL,
+ &original_repos_relpath, NULL, NULL,
+ &original_revision, NULL, NULL, NULL,
+ &changelist, NULL, NULL, &had_props,
+ &props_mod, NULL, NULL, NULL,
db, local_abspath,
scratch_pool, scratch_pool));
- if (status == svn_wc__db_status_added)
- SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, db,
- local_abspath, scratch_pool, scratch_pool));
+ assert(kind == svn_kind_file
+ && (status == svn_wc__db_status_normal
+ || status == svn_wc__db_status_added
+ || (status == svn_wc__db_status_deleted && diff_pristine)));
+
- /* We can't show additions for files that don't exist. */
- SVN_ERR_ASSERT(status != svn_wc__db_status_deleted || eb->use_text_base);
+ if (changelist && changelist_hash
+ && !svn_hash_gets(changelist_hash, changelist))
+ return SVN_NO_ERROR;
- /* If the file was added *with history*, then we don't want to
- see a comparison to the empty file; we want the usual working
- vs. text-base comparison. */
- if (status == svn_wc__db_status_copied ||
- status == svn_wc__db_status_moved_here)
+ if (status == svn_wc__db_status_deleted)
{
- /* Don't show anything if we're comparing to BASE, since by
- definition there can't be any local modifications. */
- if (eb->use_text_base)
- return SVN_NO_ERROR;
+ assert(diff_pristine);
- /* Otherwise show just the local modifications. */
- return file_diff(eb, local_abspath, path, scratch_pool);
+ SVN_ERR(svn_wc__db_read_pristine_info(&status, &kind, NULL, NULL, NULL,
+ NULL, &checksum, NULL, &had_props,
+ &pristine_props,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
+ props_mod = FALSE;
}
+ else if (!had_props)
+ pristine_props = apr_hash_make(scratch_pool);
+ else
+ SVN_ERR(svn_wc__db_read_pristine_props(&pristine_props,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
- emptyprops = apr_hash_make(scratch_pool);
+ if (original_repos_relpath)
+ {
+ copyfrom_src = svn_diff__source_create(original_revision, scratch_pool);
+ copyfrom_src->repos_relpath = original_repos_relpath;
+ }
- if (eb->use_text_base)
- SVN_ERR(svn_wc__db_read_pristine_props(&wcprops, db, local_abspath,
- scratch_pool, scratch_pool));
+ if (props_mod || !SVN_IS_VALID_REVNUM(revision))
+ right_src = svn_diff__source_create(SVN_INVALID_REVNUM, scratch_pool);
else
- SVN_ERR(svn_wc__get_actual_props(&wcprops, db, local_abspath,
- scratch_pool, scratch_pool));
- mimetype = get_prop_mimetype(wcprops);
+ {
+ if (diff_pristine)
+ file_mod = FALSE;
+ else
+ SVN_ERR(svn_wc__internal_file_modified_p(&file_mod, db, local_abspath,
+ FALSE, scratch_pool));
- SVN_ERR(svn_prop_diffs(&propchanges,
- wcprops, emptyprops, scratch_pool));
+ if (!file_mod)
+ right_src = svn_diff__source_create(revision, scratch_pool);
+ else
+ right_src = svn_diff__source_create(SVN_INVALID_REVNUM, scratch_pool);
+ }
+ SVN_ERR(processor->file_opened(&file_baton, &skip,
+ relpath,
+ NULL /* left_source */,
+ right_src,
+ copyfrom_src,
+ processor_parent_baton,
+ processor,
+ scratch_pool, scratch_pool));
- if (eb->use_text_base)
+ if (skip)
+ return SVN_NO_ERROR;
+
+ if (props_mod && !diff_pristine)
+ SVN_ERR(svn_wc__db_read_props(&right_props, db, local_abspath,
+ scratch_pool, scratch_pool));
+ else
+ right_props = svn_prop_hash_dup(pristine_props, scratch_pool);
+
+ if (checksum)
+ SVN_ERR(svn_wc__db_pristine_get_path(&pristine_file, db, local_abspath,
+ checksum, scratch_pool, scratch_pool));
+ else
+ pristine_file = NULL;
+
+ if (diff_pristine)
{
- SVN_ERR(get_pristine_file(&source_file, db, local_abspath,
- FALSE, scratch_pool, scratch_pool));
- translated_file = source_file; /* No translation needed */
+ translated_file = pristine_file; /* No translation needed */
}
else
{
- source_file = local_abspath;
-
SVN_ERR(svn_wc__internal_translated_file(
- &translated_file, source_file, db, local_abspath,
+ &translated_file, local_abspath, db, local_abspath,
SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
- eb->cancel_func, eb->cancel_baton,
+ cancel_func, cancel_baton,
scratch_pool, scratch_pool));
}
- SVN_ERR(eb->callbacks->file_added(NULL, NULL, NULL,
- path,
- empty_file, translated_file,
- 0, revision,
- NULL, mimetype,
- NULL, SVN_INVALID_REVNUM,
- propchanges, emptyprops,
- eb->callback_baton,
- scratch_pool));
+ SVN_ERR(processor->file_added(relpath,
+ copyfrom_src,
+ right_src,
+ copyfrom_src
+ ? pristine_file
+ : NULL,
+ translated_file,
+ copyfrom_src
+ ? pristine_props
+ : NULL,
+ right_props,
+ file_baton,
+ processor,
+ scratch_pool));
return SVN_NO_ERROR;
}
-/* Report an existing directory in the working copy (either in BASE
- * or WORKING) as having been added. If recursing, also report any
- * subdirectories as added.
- *
- * DIR_BATON is the baton for the directory.
- *
- * Do all allocation in POOL.
- */
-static svn_error_t *
-report_wc_directory_as_added(struct edit_baton *eb,
- const char *local_abspath,
- const char *path,
- svn_depth_t depth,
- apr_pool_t *scratch_pool)
+svn_error_t *
+svn_wc__diff_local_only_dir(svn_wc__db_t *db,
+ const char *local_abspath,
+ const char *relpath,
+ svn_depth_t depth,
+ const svn_diff_tree_processor_t *processor,
+ void *processor_parent_baton,
+ apr_hash_t *changelist_hash,
+ svn_boolean_t diff_pristine,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *scratch_pool)
{
- svn_wc__db_t *db = eb->db;
- apr_hash_t *emptyprops, *wcprops = NULL;
- apr_array_header_t *propchanges;
const apr_array_header_t *children;
int i;
apr_pool_t *iterpool;
+ void *pdb = NULL;
+ svn_boolean_t skip = FALSE;
+ svn_boolean_t skip_children = FALSE;
+ svn_diff_source_t *right_src = svn_diff__source_create(SVN_INVALID_REVNUM,
+ scratch_pool);
+ svn_depth_t depth_below_here = depth;
+ apr_hash_t *nodes;
+ apr_hash_t *conflicts;
- emptyprops = apr_hash_make(scratch_pool);
-
- /* If this directory passes changelist filtering, get its BASE or
- WORKING properties, as appropriate, and simulate their
- addition.
- ### it should be noted that we do not currently allow directories
- ### to be part of changelists, so if a changelist is provided, this
- ### check will always fail. */
- if (svn_wc__internal_changelist_match(db, local_abspath,
- eb->changelist_hash, scratch_pool))
- {
- if (eb->use_text_base)
- SVN_ERR(svn_wc__db_read_pristine_props(&wcprops, db, local_abspath,
- scratch_pool, scratch_pool));
- else
- SVN_ERR(svn_wc__get_actual_props(&wcprops, db, local_abspath,
- scratch_pool, scratch_pool));
+ /* Report the addition of the directory's contents. */
+ iterpool = svn_pool_create(scratch_pool);
- SVN_ERR(svn_prop_diffs(&propchanges, wcprops, emptyprops, scratch_pool));
+ SVN_ERR(processor->dir_opened(&pdb, &skip, &skip_children,
+ relpath,
+ NULL,
+ right_src,
+ NULL /* copyfrom_src */,
+ processor_parent_baton,
+ processor,
+ scratch_pool, iterpool));
- if (propchanges->nelts > 0)
- SVN_ERR(eb->callbacks->dir_props_changed(NULL, NULL,
- path, TRUE,
- propchanges, emptyprops,
- eb->callback_baton,
- scratch_pool));
- }
+ SVN_ERR(svn_wc__db_read_children_info(&nodes, &conflicts, db, local_abspath,
+ scratch_pool, iterpool));
- /* Report the addition of the directory's contents. */
- iterpool = svn_pool_create(scratch_pool);
+ if (depth_below_here == svn_depth_immediates)
+ depth_below_here = svn_depth_empty;
- SVN_ERR(svn_wc__db_read_children(&children, db, local_abspath,
- scratch_pool, iterpool));
+ children = svn_sort__hash(nodes, svn_sort_compare_items_lexically,
+ scratch_pool);
for (i = 0; i < children->nelts; i++)
{
- const char *name = APR_ARRAY_IDX(children, i, const char *);
- const char *child_abspath, *child_path;
- svn_wc__db_status_t status;
- svn_kind_t kind;
+ svn_sort__item_t *item = &APR_ARRAY_IDX(children, i, svn_sort__item_t);
+ const char *name = item->key;
+ struct svn_wc__db_info_t *info = item->value;
+ const char *child_abspath;
+ const char *child_relpath;
svn_pool_clear(iterpool);
- if (eb->cancel_func)
- SVN_ERR(eb->cancel_func(eb->cancel_baton));
+ if (cancel_func)
+ SVN_ERR(cancel_func(cancel_baton));
child_abspath = svn_dirent_join(local_abspath, name, iterpool);
- SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- db, child_abspath, iterpool, iterpool));
-
- if (status == svn_wc__db_status_not_present
- || status == svn_wc__db_status_excluded
- || status == svn_wc__db_status_server_excluded)
+ if (NOT_PRESENT(info->status))
{
continue;
}
/* If comparing against WORKING, skip entries that are
schedule-deleted - they don't really exist. */
- if (!eb->use_text_base && status == svn_wc__db_status_deleted)
+ if (!diff_pristine && info->status == svn_wc__db_status_deleted)
continue;
- child_path = svn_relpath_join(path, name, iterpool);
+ child_relpath = svn_relpath_join(relpath, name, iterpool);
- switch (kind)
+ switch (info->kind)
{
case svn_kind_file:
case svn_kind_symlink:
- SVN_ERR(report_wc_file_as_added(eb, child_abspath, child_path,
- iterpool));
+ SVN_ERR(svn_wc__diff_local_only_file(db, child_abspath,
+ child_relpath,
+ processor, pdb,
+ changelist_hash,
+ diff_pristine,
+ cancel_func, cancel_baton,
+ scratch_pool));
break;
case svn_kind_dir:
if (depth > svn_depth_files || depth == svn_depth_unknown)
{
- svn_depth_t depth_below_here = depth;
-
- if (depth_below_here == svn_depth_immediates)
- depth_below_here = svn_depth_empty;
-
- SVN_ERR(report_wc_directory_as_added(eb,
- child_abspath,
- child_path,
- depth_below_here,
- iterpool));
+ SVN_ERR(svn_wc__diff_local_only_dir(db, child_abspath,
+ child_relpath, depth_below_here,
+ processor, pdb,
+ changelist_hash,
+ diff_pristine,
+ cancel_func, cancel_baton,
+ iterpool));
}
break;
@@ -1145,11 +1158,289 @@ report_wc_directory_as_added(struct edit
}
}
+ if (!skip)
+ {
+ apr_hash_t *right_props;
+ if (diff_pristine)
+ SVN_ERR(svn_wc__db_read_pristine_props(&right_props, db, local_abspath,
+ scratch_pool, scratch_pool));
+ else
+ SVN_ERR(svn_wc__get_actual_props(&right_props, db, local_abspath,
+ scratch_pool, scratch_pool));
+
+ SVN_ERR(processor->dir_added(relpath,
+ NULL /* copyfrom_src */,
+ right_src,
+ NULL,
+ right_props,
+ pdb,
+ processor,
+ iterpool));
+ }
svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
+/* Reports local changes. */
+static svn_error_t *
+handle_local_only(struct dir_baton_t *pb,
+ const char *name,
+ apr_pool_t *scratch_pool)
+{
+ struct edit_baton_t *eb = pb->eb;
+ const struct svn_wc__db_info_t *info;
+ svn_boolean_t repos_delete = (pb->deletes
+ && svn_hash_gets(pb->deletes, name));
+
+ assert(!strchr(name, '/'));
+ assert(!pb->added || eb->ignore_ancestry);
+
+ if (pb->skip_children)
+ return SVN_NO_ERROR;
+
+ SVN_ERR(ensure_local_info(pb, scratch_pool));
+
+ info = svn_hash_gets(pb->local_info, name);
+
+ if (info == NULL || NOT_PRESENT(info->status))
+ return SVN_NO_ERROR;
+
+ switch (info->status)
+ {
+ case svn_wc__db_status_incomplete:
+ return SVN_NO_ERROR; /* Not local only */
+
+ case svn_wc__db_status_normal:
+ if (!repos_delete)
+ return SVN_NO_ERROR; /* Local and remote */
+ svn_hash_sets(pb->deletes, name, NULL);
+ break;
+
+ case svn_wc__db_status_deleted:
+ if (!(eb->diff_pristine && repos_delete))
+ return SVN_NO_ERROR;
+ break;
+
+ case svn_wc__db_status_added:
+ default:
+ break;
+ }
+
+ if (info->kind == svn_kind_dir)
+ {
+ svn_depth_t depth ;
+
+ if (pb->depth == svn_depth_infinity || pb->depth == svn_depth_unknown)
+ depth = pb->depth;
+ else
+ depth = svn_depth_empty;
+
+ SVN_ERR(svn_wc__diff_local_only_dir(
+ eb->db,
+ svn_dirent_join(pb->local_abspath, name, scratch_pool),
+ svn_relpath_join(pb->relpath, name, scratch_pool),
+ repos_delete ? svn_depth_infinity : depth,
+ eb->processor, pb->pdb,
+ eb->changelist_hash,
+ eb->diff_pristine,
+ eb->cancel_func, eb->cancel_baton,
+ scratch_pool));
+ }
+ else
+ SVN_ERR(svn_wc__diff_local_only_file(
+ eb->db,
+ svn_dirent_join(pb->local_abspath, name, scratch_pool),
+ svn_relpath_join(pb->relpath, name, scratch_pool),
+ eb->processor, pb->pdb,
+ eb->changelist_hash,
+ eb->diff_pristine,
+ eb->cancel_func, eb->cancel_baton,
+ scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+/* Reports a file LOCAL_ABSPATH in BASE as deleted */
+svn_error_t *
+svn_wc__diff_base_only_file(svn_wc__db_t *db,
+ const char *local_abspath,
+ const char *relpath,
+ svn_revnum_t revision,
+ const svn_diff_tree_processor_t *processor,
+ void *processor_parent_baton,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc__db_status_t status;
+ svn_kind_t kind;
+ const svn_checksum_t *checksum;
+ apr_hash_t *props;
+ void *file_baton = NULL;
+ svn_boolean_t skip = FALSE;
+ svn_diff_source_t *left_src;
+ const char *pristine_file;
+
+ SVN_ERR(svn_wc__db_base_get_info(&status, &kind,
+ SVN_IS_VALID_REVNUM(revision)
+ ? NULL : &revision,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &checksum, NULL, NULL, NULL, &props, NULL,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
+
+ SVN_ERR_ASSERT(status == svn_wc__db_status_normal
+ && kind == svn_kind_file
+ && checksum);
+
+ left_src = svn_diff__source_create(revision, scratch_pool);
+
+ SVN_ERR(processor->file_opened(&file_baton, &skip,
+ relpath,
+ left_src,
+ NULL /* right_src */,
+ NULL /* copyfrom_source */,
+ processor_parent_baton,
+ processor,
+ scratch_pool, scratch_pool));
+
+ if (skip)
+ return SVN_NO_ERROR;
+
+ SVN_ERR(svn_wc__db_pristine_get_path(&pristine_file,
+ db, local_abspath, checksum,
+ scratch_pool, scratch_pool));
+
+ SVN_ERR(processor->file_deleted(relpath,
+ left_src,
+ pristine_file,
+ props,
+ file_baton,
+ processor,
+ scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__diff_base_only_dir(svn_wc__db_t *db,
+ const char *local_abspath,
+ const char *relpath,
+ svn_revnum_t revision,
+ svn_depth_t depth,
+ const svn_diff_tree_processor_t *processor,
+ void *processor_parent_baton,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *scratch_pool)
+{
+ void *dir_baton = NULL;
+ svn_boolean_t skip = FALSE;
+ svn_boolean_t skip_children = FALSE;
+ svn_diff_source_t *left_src;
+ svn_revnum_t report_rev = revision;
+
+ if (!SVN_IS_VALID_REVNUM(report_rev))
+ SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, &report_rev, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
+
+ left_src = svn_diff__source_create(report_rev, scratch_pool);
+
+ SVN_ERR(processor->dir_opened(&dir_baton, &skip, &skip_children,
+ relpath,
+ left_src,
+ NULL /* right_src */,
+ NULL /* copyfrom_src */,
+ processor_parent_baton,
+ processor,
+ scratch_pool, scratch_pool));
+
+ if (!skip_children && (depth == svn_depth_unknown || depth > svn_depth_empty))
+ {
+ apr_hash_t *nodes;
+ apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+ apr_array_header_t *children;
+ int i;
+
+ SVN_ERR(svn_wc__db_base_get_children_info(&nodes, db, local_abspath,
+ scratch_pool, iterpool));
+
+ children = svn_sort__hash(nodes, svn_sort_compare_items_lexically,
+ scratch_pool);
+
+ for (i = 0; i < children->nelts; i++)
+ {
+ svn_sort__item_t *item = &APR_ARRAY_IDX(children, i,
+ svn_sort__item_t);
+ const char *name = item->key;
+ struct svn_wc__db_base_info_t *info = item->value;
+ const char *child_abspath;
+ const char *child_relpath;
+
+ if (info->status != svn_wc__db_status_normal)
+ continue;
+
+ if (cancel_func)
+ SVN_ERR(cancel_func(cancel_baton));
+
+ svn_pool_clear(iterpool);
+
+ child_abspath = svn_dirent_join(local_abspath, name, iterpool);
+ child_relpath = svn_relpath_join(relpath, name, iterpool);
+
+ switch (info->kind)
+ {
+ case svn_kind_file:
+ case svn_kind_symlink:
+ SVN_ERR(svn_wc__diff_base_only_file(db, child_abspath,
+ child_relpath,
+ revision,
+ processor, dir_baton,
+ iterpool));
+ break;
+ case svn_kind_dir:
+ if (depth > svn_depth_files || depth == svn_depth_unknown)
+ {
+ svn_depth_t depth_below_here = depth;
+
+ if (depth_below_here == svn_depth_immediates)
+ depth_below_here = svn_depth_empty;
+
+ SVN_ERR(svn_wc__diff_base_only_dir(db, child_abspath,
+ child_relpath,
+ revision,
+ depth_below_here,
+ processor, dir_baton,
+ cancel_func,
+ cancel_baton,
+ iterpool));
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ if (!skip)
+ {
+ apr_hash_t *props;
+ SVN_ERR(svn_wc__db_base_get_props(&props, db, local_abspath,
+ scratch_pool, scratch_pool));
+
+ SVN_ERR(processor->dir_deleted(relpath,
+ left_src,
+ props,
+ dir_baton,
+ processor,
+ scratch_pool));
+ }
+
+ return SVN_NO_ERROR;
+}
/* An svn_delta_editor_t function. */
static svn_error_t *
@@ -1157,7 +1448,7 @@ set_target_revision(void *edit_baton,
svn_revnum_t target_revision,
apr_pool_t *pool)
{
- struct edit_baton *eb = edit_baton;
+ struct edit_baton_t *eb = edit_baton;
eb->revnum = target_revision;
return SVN_NO_ERROR;
@@ -1170,13 +1461,31 @@ open_root(void *edit_baton,
apr_pool_t *dir_pool,
void **root_baton)
{
- struct edit_baton *eb = edit_baton;
- struct dir_baton *db;
+ struct edit_baton_t *eb = edit_baton;
+ struct dir_baton_t *db;
eb->root_opened = TRUE;
db = make_dir_baton("", NULL, eb, FALSE, eb->depth, dir_pool);
*root_baton = db;
+ if (eb->target[0] == '\0')
+ {
+ db->left_src = svn_diff__source_create(eb->revnum, db->pool);
+ db->right_src = svn_diff__source_create(SVN_INVALID_REVNUM, db->pool);
+
+ SVN_ERR(eb->processor->dir_opened(&db->pdb, &db->skip,
+ &db->skip_children,
+ "",
+ db->left_src,
+ db->right_src,
+ NULL /* copyfrom_source */,
+ NULL /* parent_baton */,
+ eb->processor,
+ db->pool, db->pool));
+ }
+ else
+ db->skip = TRUE; /* Skip this, but not the children */
+
return SVN_NO_ERROR;
}
@@ -1187,85 +1496,13 @@ delete_entry(const char *path,
void *parent_baton,
apr_pool_t *pool)
{
- struct dir_baton *pb = parent_baton;
- struct edit_baton *eb = pb->eb;
- svn_wc__db_t *db = eb->db;
- const char *empty_file;
- const char *name = svn_dirent_basename(path, NULL);
- const char *local_abspath = svn_dirent_join(pb->local_abspath, name, pool);
- svn_wc__db_status_t status;
- svn_kind_t kind;
-
- /* Mark this node as compared in the parent directory's baton. */
- apr_hash_set(pb->compared, apr_pstrdup(pb->pool, path),
- APR_HASH_KEY_STRING, "");
-
- SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- db, local_abspath, pool, pool));
-
- /* If comparing against WORKING, skip nodes that are deleted
- - they don't really exist. */
- if (!eb->use_text_base && status == svn_wc__db_status_deleted)
- return SVN_NO_ERROR;
-
- SVN_ERR(get_empty_file(pb->eb, &empty_file));
- switch (kind)
- {
- case svn_kind_file:
- case svn_kind_symlink:
- /* A delete is required to change working-copy into requested
- revision, so diff should show this as an add. Thus compare
- the empty file against the current working copy. If
- 'reverse_order' is set, then show a deletion. */
-
- if (eb->reverse_order)
- {
- /* Whenever showing a deletion, we show the text-base vanishing. */
- /* ### This is wrong if we're diffing WORKING->repos. */
- const char *textbase;
-
- apr_hash_t *baseprops = NULL;
- const char *base_mimetype;
-
- SVN_ERR(get_pristine_file(&textbase, db, local_abspath,
- eb->use_text_base, pool, pool));
-
- SVN_ERR(svn_wc__db_read_pristine_props(&baseprops,
- eb->db, local_abspath,
- pool, pool));
- base_mimetype = get_prop_mimetype(baseprops);
-
- SVN_ERR(eb->callbacks->file_deleted(NULL, NULL, path,
- textbase,
- empty_file,
- base_mimetype,
- NULL,
- baseprops,
- eb->callback_baton,
- pool));
- }
- else
- {
- /* Or normally, show the working file being added. */
- SVN_ERR(report_wc_file_as_added(eb, local_abspath, path, pool));
- }
- break;
- case svn_kind_dir:
- /* A delete is required to change working-copy into requested
- revision, so diff should show this as an add. */
- SVN_ERR(report_wc_directory_as_added(eb,
- local_abspath,
- path,
- svn_depth_infinity,
- pool));
+ struct dir_baton_t *pb = parent_baton;
+ const char *name = svn_dirent_basename(path, pb->pool);
- default:
- break;
- }
+ if (!pb->deletes)
+ pb->deletes = apr_hash_make(pb->pool);
+ svn_hash_sets(pb->deletes, name, "");
return SVN_NO_ERROR;
}
@@ -1278,21 +1515,53 @@ add_directory(const char *path,
[... 1451 lines stripped ...]