2010-08-10 00:48:10 +02:00
|
|
|
/*
|
|
|
|
* Licensed under a two-clause BSD-style license.
|
|
|
|
* See LICENSE for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "git-compat-util.h"
|
2010-12-10 11:00:55 +01:00
|
|
|
#include "strbuf.h"
|
2010-08-10 00:48:10 +02:00
|
|
|
#include "repo_tree.h"
|
|
|
|
#include "fast_export.h"
|
|
|
|
|
2011-05-26 09:12:14 +02:00
|
|
|
const char *repo_read_path(const char *path, uint32_t *mode_out)
|
2010-08-10 00:48:10 +02:00
|
|
|
{
|
2010-12-10 11:00:55 +01:00
|
|
|
int err;
|
|
|
|
static struct strbuf buf = STRBUF_INIT;
|
2010-08-10 00:48:10 +02:00
|
|
|
|
2010-12-10 11:00:55 +01:00
|
|
|
strbuf_reset(&buf);
|
2011-05-26 09:12:14 +02:00
|
|
|
err = fast_export_ls(path, mode_out, &buf);
|
2010-12-10 11:00:55 +01:00
|
|
|
if (err) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
die_errno("BUG: unexpected fast_export_ls error");
|
2010-12-13 07:09:31 +01:00
|
|
|
/* Treat missing paths as directories. */
|
|
|
|
*mode_out = REPO_MODE_DIR;
|
2010-08-10 00:48:10 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-12-10 11:00:55 +01: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-20 20:25:28 +01:00
|
|
|
}
|
|
|
|
|
2010-12-13 06:41:12 +01:00
|
|
|
void repo_copy(uint32_t revision, const char *src, const char *dst)
|
2010-08-10 00:48:10 +02:00
|
|
|
{
|
2010-12-10 11:00:55 +01:00
|
|
|
int err;
|
|
|
|
uint32_t mode;
|
|
|
|
static struct strbuf data = STRBUF_INIT;
|
|
|
|
|
|
|
|
strbuf_reset(&data);
|
2010-12-13 06:41:12 +01:00
|
|
|
err = fast_export_ls_rev(revision, src, &mode, &data);
|
2010-12-10 11:00:55 +01:00
|
|
|
if (err) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
die_errno("BUG: unexpected fast_export_ls_rev error");
|
2010-12-13 06:41:12 +01:00
|
|
|
fast_export_delete(dst);
|
2010-12-10 11:00:55 +01:00
|
|
|
return;
|
2010-08-10 00:48:10 +02:00
|
|
|
}
|
2010-12-13 06:41:12 +01:00
|
|
|
fast_export_modify(dst, mode, data.buf);
|
2010-08-10 00:48:10 +02:00
|
|
|
}
|
|
|
|
|
2010-12-13 06:41:12 +01:00
|
|
|
void repo_delete(const char *path)
|
2010-08-10 00:48:10 +02:00
|
|
|
{
|
2010-12-13 06:41:12 +01:00
|
|
|
fast_export_delete(path);
|
2010-08-10 00:48:10 +02:00
|
|
|
}
|