summaryrefslogtreecommitdiff
path: root/vcs-svn
diff options
context:
space:
mode:
Diffstat (limited to 'vcs-svn')
-rw-r--r--vcs-svn/fast_export.c49
-rw-r--r--vcs-svn/fast_export.h7
-rw-r--r--vcs-svn/line_buffer.c4
-rw-r--r--vcs-svn/repo_tree.c48
-rw-r--r--vcs-svn/repo_tree.h23
-rw-r--r--vcs-svn/sliding_window.c2
-rw-r--r--vcs-svn/svndiff.c4
-rw-r--r--vcs-svn/svndump.c40
8 files changed, 71 insertions, 106 deletions
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index bd0f2c2b86..3fd047a8b8 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -6,7 +6,6 @@
#include "cache.h"
#include "quote.h"
#include "fast_export.h"
-#include "repo_tree.h"
#include "strbuf.h"
#include "svndiff.h"
#include "sliding_window.h"
@@ -68,12 +67,12 @@ void fast_export_modify(const char *path, uint32_t mode, const char *dataref)
}
void fast_export_begin_note(uint32_t revision, const char *author,
- const char *log, unsigned long timestamp, const char *note_ref)
+ const char *log, timestamp_t timestamp, const char *note_ref)
{
static int firstnote = 1;
size_t loglen = strlen(log);
printf("commit %s\n", note_ref);
- printf("committer %s <%s@%s> %ld +0000\n", author, author, "local", timestamp);
+ printf("committer %s <%s@%s> %"PRItime" +0000\n", author, author, "local", timestamp);
printf("data %"PRIuMAX"\n", (uintmax_t)loglen);
fwrite(log, loglen, 1, stdout);
if (firstnote) {
@@ -93,7 +92,7 @@ static char gitsvnline[MAX_GITSVN_LINE_LEN];
void fast_export_begin_commit(uint32_t revision, const char *author,
const struct strbuf *log,
const char *uuid, const char *url,
- unsigned long timestamp, const char *local_ref)
+ timestamp_t timestamp, const char *local_ref)
{
static const struct strbuf empty = STRBUF_INIT;
if (!log)
@@ -107,7 +106,7 @@ void fast_export_begin_commit(uint32_t revision, const char *author,
}
printf("commit %s\n", local_ref);
printf("mark :%"PRIu32"\n", revision);
- printf("committer %s <%s@%s> %ld +0000\n",
+ printf("committer %s <%s@%s> %"PRItime" +0000\n",
*author ? author : "nobody",
*author ? author : "nobody",
*uuid ? uuid : "local", timestamp);
@@ -210,7 +209,7 @@ static long apply_delta(off_t len, struct line_buffer *input,
die("invalid cat-blob response: %s", response);
check_preimage_overflow(preimage.max_off, 1);
}
- if (old_mode == REPO_MODE_LNK) {
+ if (old_mode == S_IFLNK) {
strbuf_addstr(&preimage.buf, "link ");
check_preimage_overflow(preimage.max_off, strlen("link "));
preimage.max_off += strlen("link ");
@@ -244,7 +243,7 @@ void fast_export_buf_to_data(const struct strbuf *data)
void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input)
{
assert(len >= 0);
- if (mode == REPO_MODE_LNK) {
+ if (mode == S_IFLNK) {
/* svn symlink blobs start with "link " */
if (len < 5)
die("invalid dump: symlink too short for \"link\" prefix");
@@ -312,6 +311,40 @@ int fast_export_ls(const char *path, uint32_t *mode, struct strbuf *dataref)
return parse_ls_response(get_response_line(), mode, dataref);
}
+const char *fast_export_read_path(const char *path, uint32_t *mode_out)
+{
+ int err;
+ static struct strbuf buf = STRBUF_INIT;
+
+ strbuf_reset(&buf);
+ err = fast_export_ls(path, mode_out, &buf);
+ if (err) {
+ if (errno != ENOENT)
+ die_errno("BUG: unexpected fast_export_ls error");
+ /* Treat missing paths as directories. */
+ *mode_out = S_IFDIR;
+ return NULL;
+ }
+ return buf.buf;
+}
+
+void fast_export_copy(uint32_t revision, const char *src, const char *dst)
+{
+ int err;
+ uint32_t mode;
+ static struct strbuf data = STRBUF_INIT;
+
+ strbuf_reset(&data);
+ err = fast_export_ls_rev(revision, src, &mode, &data);
+ if (err) {
+ if (errno != ENOENT)
+ die_errno("BUG: unexpected fast_export_ls_rev error");
+ fast_export_delete(dst);
+ return;
+ }
+ fast_export_modify(dst, mode, data.buf);
+}
+
void fast_export_blob_delta(uint32_t mode,
uint32_t old_mode, const char *old_data,
off_t len, struct line_buffer *input)
@@ -320,7 +353,7 @@ void fast_export_blob_delta(uint32_t mode,
assert(len >= 0);
postimage_len = apply_delta(len, input, old_data, old_mode);
- if (mode == REPO_MODE_LNK) {
+ if (mode == S_IFLNK) {
buffer_skip_bytes(&postimage, strlen("link "));
postimage_len -= strlen("link ");
}
diff --git a/vcs-svn/fast_export.h b/vcs-svn/fast_export.h
index c8b5adb811..60b79c35b9 100644
--- a/vcs-svn/fast_export.h
+++ b/vcs-svn/fast_export.h
@@ -11,10 +11,10 @@ void fast_export_delete(const char *path);
void fast_export_modify(const char *path, uint32_t mode, const char *dataref);
void fast_export_note(const char *committish, const char *dataref);
void fast_export_begin_note(uint32_t revision, const char *author,
- const char *log, unsigned long timestamp, const char *note_ref);
+ const char *log, timestamp_t timestamp, const char *note_ref);
void fast_export_begin_commit(uint32_t revision, const char *author,
const struct strbuf *log, const char *uuid,const char *url,
- unsigned long timestamp, const char *local_ref);
+ timestamp_t timestamp, const char *local_ref);
void fast_export_end_commit(uint32_t revision);
void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input);
void fast_export_buf_to_data(const struct strbuf *data);
@@ -28,4 +28,7 @@ int fast_export_ls_rev(uint32_t rev, const char *path,
int fast_export_ls(const char *path,
uint32_t *mode_out, struct strbuf *dataref_out);
+void fast_export_copy(uint32_t revision, const char *src, const char *dst);
+const char *fast_export_read_path(const char *path, uint32_t *mode_out);
+
#endif
diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c
index 57cc1cec03..e416caf8a4 100644
--- a/vcs-svn/line_buffer.c
+++ b/vcs-svn/line_buffer.c
@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)
{
long pos = ftell(buf->infile);
if (pos < 0)
- return error("ftell error: %s", strerror(errno));
+ return error_errno("ftell error");
if (fseek(buf->infile, 0, SEEK_SET))
- return error("seek error: %s", strerror(errno));
+ return error_errno("seek error");
return pos;
}
diff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c
deleted file mode 100644
index 67d27f0b6c..0000000000
--- a/vcs-svn/repo_tree.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed under a two-clause BSD-style license.
- * See LICENSE for details.
- */
-
-#include "git-compat-util.h"
-#include "strbuf.h"
-#include "repo_tree.h"
-#include "fast_export.h"
-
-const char *repo_read_path(const char *path, uint32_t *mode_out)
-{
- int err;
- static struct strbuf buf = STRBUF_INIT;
-
- strbuf_reset(&buf);
- err = fast_export_ls(path, mode_out, &buf);
- if (err) {
- if (errno != ENOENT)
- die_errno("BUG: unexpected fast_export_ls error");
- /* Treat missing paths as directories. */
- *mode_out = REPO_MODE_DIR;
- return NULL;
- }
- return buf.buf;
-}
-
-void repo_copy(uint32_t revision, const char *src, const char *dst)
-{
- int err;
- uint32_t mode;
- static struct strbuf data = STRBUF_INIT;
-
- strbuf_reset(&data);
- err = fast_export_ls_rev(revision, src, &mode, &data);
- if (err) {
- if (errno != ENOENT)
- die_errno("BUG: unexpected fast_export_ls_rev error");
- fast_export_delete(dst);
- return;
- }
- fast_export_modify(dst, mode, data.buf);
-}
-
-void repo_delete(const char *path)
-{
- fast_export_delete(path);
-}
diff --git a/vcs-svn/repo_tree.h b/vcs-svn/repo_tree.h
deleted file mode 100644
index 889c6a3c95..0000000000
--- a/vcs-svn/repo_tree.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef REPO_TREE_H_
-#define REPO_TREE_H_
-
-struct strbuf;
-
-#define REPO_MODE_DIR 0040000
-#define REPO_MODE_BLB 0100644
-#define REPO_MODE_EXE 0100755
-#define REPO_MODE_LNK 0120000
-
-uint32_t next_blob_mark(void);
-void repo_copy(uint32_t revision, const char *src, const char *dst);
-void repo_add(const char *path, uint32_t mode, uint32_t blob_mark);
-const char *repo_read_path(const char *path, uint32_t *mode_out);
-void repo_delete(const char *path);
-void repo_commit(uint32_t revision, const char *author,
- const struct strbuf *log, const char *uuid, const char *url,
- long unsigned timestamp);
-void repo_diff(uint32_t r1, uint32_t r2);
-void repo_init(void);
-void repo_reset(void);
-
-#endif
diff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c
index f11d490995..06d273c9e8 100644
--- a/vcs-svn/sliding_window.c
+++ b/vcs-svn/sliding_window.c
@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)
{
if (!buffer_ferror(file))
return error("delta preimage ends early");
- return error("cannot read delta preimage: %s", strerror(errno));
+ return error_errno("cannot read delta preimage");
}
static int skip_or_whine(struct line_buffer *file, off_t gap)
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 74c97c4543..75c753162a 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)
{
if (fwrite(sb->buf, 1, sb->len, out) == sb->len) /* Success. */
return 0;
- return error("cannot write delta postimage: %s", strerror(errno));
+ return error_errno("cannot write delta postimage");
}
static int error_short_read(struct line_buffer *input)
{
if (buffer_ferror(input))
- return error("error reading delta: %s", strerror(errno));
+ return error_errno("error reading delta");
return error("invalid delta: unexpected end of file");
}
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index 31d1d83d45..08d136b8cc 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -8,7 +8,6 @@
*/
#include "cache.h"
-#include "repo_tree.h"
#include "fast_export.h"
#include "line_buffer.h"
#include "strbuf.h"
@@ -47,7 +46,7 @@ static struct {
static struct {
uint32_t revision;
- unsigned long timestamp;
+ timestamp_t timestamp;
struct strbuf log, author, note;
} rev_ctx;
@@ -134,13 +133,13 @@ static void handle_property(const struct strbuf *key_buf,
die("invalid dump: sets type twice");
}
if (!val) {
- node_ctx.type = REPO_MODE_BLB;
+ node_ctx.type = S_IFREG | 0644;
return;
}
*type_set = 1;
node_ctx.type = keylen == strlen("svn:executable") ?
- REPO_MODE_EXE :
- REPO_MODE_LNK;
+ (S_IFREG | 0755) :
+ S_IFLNK;
}
}
@@ -219,45 +218,45 @@ static void handle_node(void)
*/
static const char *const empty_blob = "::empty::";
const char *old_data = NULL;
- uint32_t old_mode = REPO_MODE_BLB;
+ uint32_t old_mode = S_IFREG | 0644;
if (node_ctx.action == NODEACT_DELETE) {
if (have_text || have_props || node_ctx.srcRev)
die("invalid dump: deletion node has "
"copyfrom info, text, or properties");
- repo_delete(node_ctx.dst.buf);
+ fast_export_delete(node_ctx.dst.buf);
return;
}
if (node_ctx.action == NODEACT_REPLACE) {
- repo_delete(node_ctx.dst.buf);
+ fast_export_delete(node_ctx.dst.buf);
node_ctx.action = NODEACT_ADD;
}
if (node_ctx.srcRev) {
- repo_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf);
+ fast_export_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf);
if (node_ctx.action == NODEACT_ADD)
node_ctx.action = NODEACT_CHANGE;
}
- if (have_text && type == REPO_MODE_DIR)
+ if (have_text && type == S_IFDIR)
die("invalid dump: directories cannot have text attached");
/*
* Find old content (old_data) and decide on the new mode.
*/
if (node_ctx.action == NODEACT_CHANGE && !*node_ctx.dst.buf) {
- if (type != REPO_MODE_DIR)
+ if (type != S_IFDIR)
die("invalid dump: root of tree is not a regular file");
old_data = NULL;
} else if (node_ctx.action == NODEACT_CHANGE) {
uint32_t mode;
- old_data = repo_read_path(node_ctx.dst.buf, &mode);
- if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
+ old_data = fast_export_read_path(node_ctx.dst.buf, &mode);
+ if (mode == S_IFDIR && type != S_IFDIR)
die("invalid dump: cannot modify a directory into a file");
- if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR)
+ if (mode != S_IFDIR && type == S_IFDIR)
die("invalid dump: cannot modify a file into a directory");
node_ctx.type = mode;
old_mode = mode;
} else if (node_ctx.action == NODEACT_ADD) {
- if (type == REPO_MODE_DIR)
+ if (type == S_IFDIR)
old_data = NULL;
else if (have_text)
old_data = empty_blob;
@@ -280,7 +279,7 @@ static void handle_node(void)
/*
* Save the result.
*/
- if (type == REPO_MODE_DIR) /* directories are not tracked. */
+ if (type == S_IFDIR) /* directories are not tracked. */
return;
assert(old_data);
if (old_data == empty_blob)
@@ -319,6 +318,7 @@ static void end_revision(const char *note_ref)
strbuf_addf(&mark, ":%"PRIu32, rev_ctx.revision);
fast_export_note(mark.buf, "inline");
fast_export_buf_to_data(&rev_ctx.note);
+ strbuf_release(&mark);
}
}
@@ -385,9 +385,9 @@ void svndump_read(const char *url, const char *local_ref, const char *notes_ref)
continue;
strbuf_addf(&rev_ctx.note, "%s\n", t);
if (!strcmp(val, "dir"))
- node_ctx.type = REPO_MODE_DIR;
+ node_ctx.type = S_IFDIR;
else if (!strcmp(val, "file"))
- node_ctx.type = REPO_MODE_BLB;
+ node_ctx.type = S_IFREG | 0644;
else
fprintf(stderr, "Unknown node-kind: %s\n", val);
break;
@@ -501,7 +501,7 @@ static void init(int report_fd)
int svndump_init(const char *filename)
{
if (buffer_init(&input, filename))
- return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno));
+ return error_errno("cannot open %s", filename ? filename : "NULL");
init(REPORT_FILENO);
return 0;
}
@@ -509,7 +509,7 @@ int svndump_init(const char *filename)
int svndump_init_fd(int in_fd, int back_fd)
{
if(buffer_fdinit(&input, xdup(in_fd)))
- return error("cannot open fd %d: %s", in_fd, strerror(errno));
+ return error_errno("cannot open fd %d", in_fd);
init(xdup(back_fd));
return 0;
}