Re: [PATCH 3/8] vcs-svn: Introduce repo_read_path to check the content at a path
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 6, 2011, 12:29 UTC
- Message-ID
- <20110306122942.GA18995@elie>
- In-Reply-To
- <20101120192528.GD17823@burratino>
Hi,
Jonathan Nieder wrote:
> repo_modify_path returns the mode. > > Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Another cryptic commit message.
A long-winded explanation follows. Please feel free to ignore it, or even better, come up with a summary to use as change description that people can refer to for this patch in the future. :)
It is currently possible to _modify_ both the mode and the text at a path but there is only public functionality to retrieve the mode. In its original context, this patch added analogous functionality to retrieve the text (indexed by a blob name) as preparation for applying a delta to it.
In the vcs-svn-incremental series, it will allow us to restructure handle_node() a little: instead of making little modifications to an in-memory cache managed by the repo-tree library (saying, "change the mode this way but keep the content; now keep the mode but change the content"), handle_node can take responsibility for figuring out what will be the final mode and content for the path in question.
In other words, a later patch will change handle_node (in the Node-action: change case) from looking like
/* Change text at path. */ mode = repo_modify_path(path, 0, have_text ? text : 0);
/* Change mode at path. */
if (have_props) {
read_props(&new_mode);
if (new_mode != mode)
repo_modify_path(path, new_mode, have_text ? text : 0);
}to
/* Determine desired text and mode at path. */ old_text = repo_read_path(path); old_mode = repo_modify_path(path, 0, 0); if (have_props) read_props(old_mode, &mode); if (!have_text) text = old_text;
/* Make it so. */ repo_add(path, mode, text);
It is also just nice to have a function like this, to make the API less surprising.