2010-08-10 06:48:10 +08:00
|
|
|
/*
|
|
|
|
* Licensed under a two-clause BSD-style license.
|
|
|
|
* See LICENSE for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "git-compat-util.h"
|
2010-12-10 18:00:55 +08:00
|
|
|
#include "strbuf.h"
|
2010-08-10 06:48:10 +08:00
|
|
|
#include "repo_tree.h"
|
|
|
|
#include "fast_export.h"
|
|
|
|
|
2010-12-13 14:09:31 +08:00
|
|
|
const char *repo_read_path(const uint32_t *path, uint32_t *mode_out)
|
2010-08-10 06:48:10 +08:00
|
|
|
{
|
2010-12-10 18:00:55 +08:00
|
|
|
int err;
|
|
|
|
static struct strbuf buf = STRBUF_INIT;
|
2010-08-10 06:48:10 +08:00
|
|
|
|
2010-12-10 18:00:55 +08:00
|
|
|
strbuf_reset(&buf);
|
2010-12-13 14:09:31 +08:00
|
|
|
err = fast_export_ls(REPO_MAX_PATH_DEPTH, path, mode_out, &buf);
|
2010-12-10 18:00:55 +08:00
|
|
|
if (err) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
die_errno("BUG: unexpected fast_export_ls error");
|
2010-12-13 14:09:31 +08:00
|
|
|
/* Treat missing paths as directories. */
|
|
|
|
*mode_out = REPO_MODE_DIR;
|
2010-08-10 06:48:10 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-12-10 18:00:55 +08:00
|
|
|
return buf.buf;
|
vcs-svn: introduce repo_read_path to check the content at a path
The repo_tree structure remembers, for each path in each revision, a
mode (regular file, executable, symlink, or directory) and content
(blob mark or directory structure). Maintaining a second copy of all
this information when it's already in the target repository is
wasteful, it does not persist between svn-fe invocations, and most
importantly, there is no convenient way to transfer it from one
machine to another. So it would be nice to get rid of it.
As a first step, let's change the repo_tree API to match fast-import's
read commands more closely. Currently to read the mode for a path,
one uses
repo_modify_path(path, new_mode, new_content);
which changes the mode and content as a side effect. There is no
function to read the content at a path; add one.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2010-11-21 03:25:28 +08:00
|
|
|
}
|
|
|
|
|
2010-12-10 14:53:54 +08:00
|
|
|
void repo_copy(uint32_t revision, const uint32_t *src, const uint32_t *dst)
|
2010-08-10 06:48:10 +08:00
|
|
|
{
|
2010-12-10 18:00:55 +08:00
|
|
|
int err;
|
|
|
|
uint32_t mode;
|
|
|
|
static struct strbuf data = STRBUF_INIT;
|
|
|
|
|
|
|
|
strbuf_reset(&data);
|
|
|
|
err = fast_export_ls_rev(revision, REPO_MAX_PATH_DEPTH, src, &mode, &data);
|
|
|
|
if (err) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
die_errno("BUG: unexpected fast_export_ls_rev error");
|
|
|
|
fast_export_delete(REPO_MAX_PATH_DEPTH, dst);
|
|
|
|
return;
|
2010-08-10 06:48:10 +08:00
|
|
|
}
|
2010-12-10 18:00:55 +08:00
|
|
|
fast_export_modify(REPO_MAX_PATH_DEPTH, dst, mode, data.buf);
|
2010-08-10 06:48:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void repo_delete(uint32_t *path)
|
|
|
|
{
|
2010-12-10 18:00:55 +08:00
|
|
|
fast_export_delete(REPO_MAX_PATH_DEPTH, path);
|
2010-08-10 06:48:10 +08:00
|
|
|
}
|