Skip to content

Commit 8134746

Browse files
committed
Merge branch 'jn/vcs-svn-cleanup' into maint
Code clean-up. * jn/vcs-svn-cleanup: vcs-svn: move remaining repo_tree functions to fast_export.h vcs-svn: remove repo_delete wrapper function vcs-svn: remove custom mode constants vcs-svn: remove more unused prototypes and declarations
2 parents 044aa0e + b8f43b1 commit 8134746

File tree

6 files changed

+56
-86
lines changed

6 files changed

+56
-86
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,6 @@ XDIFF_OBJS += xdiff/xhistogram.o
20372037

20382038
VCSSVN_OBJS += vcs-svn/line_buffer.o
20392039
VCSSVN_OBJS += vcs-svn/sliding_window.o
2040-
VCSSVN_OBJS += vcs-svn/repo_tree.o
20412040
VCSSVN_OBJS += vcs-svn/fast_export.o
20422041
VCSSVN_OBJS += vcs-svn/svndiff.o
20432042
VCSSVN_OBJS += vcs-svn/svndump.o

vcs-svn/fast_export.c

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "cache.h"
77
#include "quote.h"
88
#include "fast_export.h"
9-
#include "repo_tree.h"
109
#include "strbuf.h"
1110
#include "svndiff.h"
1211
#include "sliding_window.h"
@@ -210,7 +209,7 @@ static long apply_delta(off_t len, struct line_buffer *input,
210209
die("invalid cat-blob response: %s", response);
211210
check_preimage_overflow(preimage.max_off, 1);
212211
}
213-
if (old_mode == REPO_MODE_LNK) {
212+
if (old_mode == S_IFLNK) {
214213
strbuf_addstr(&preimage.buf, "link ");
215214
check_preimage_overflow(preimage.max_off, strlen("link "));
216215
preimage.max_off += strlen("link ");
@@ -244,7 +243,7 @@ void fast_export_buf_to_data(const struct strbuf *data)
244243
void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input)
245244
{
246245
assert(len >= 0);
247-
if (mode == REPO_MODE_LNK) {
246+
if (mode == S_IFLNK) {
248247
/* svn symlink blobs start with "link " */
249248
if (len < 5)
250249
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)
312311
return parse_ls_response(get_response_line(), mode, dataref);
313312
}
314313

314+
const char *fast_export_read_path(const char *path, uint32_t *mode_out)
315+
{
316+
int err;
317+
static struct strbuf buf = STRBUF_INIT;
318+
319+
strbuf_reset(&buf);
320+
err = fast_export_ls(path, mode_out, &buf);
321+
if (err) {
322+
if (errno != ENOENT)
323+
die_errno("BUG: unexpected fast_export_ls error");
324+
/* Treat missing paths as directories. */
325+
*mode_out = S_IFDIR;
326+
return NULL;
327+
}
328+
return buf.buf;
329+
}
330+
331+
void fast_export_copy(uint32_t revision, const char *src, const char *dst)
332+
{
333+
int err;
334+
uint32_t mode;
335+
static struct strbuf data = STRBUF_INIT;
336+
337+
strbuf_reset(&data);
338+
err = fast_export_ls_rev(revision, src, &mode, &data);
339+
if (err) {
340+
if (errno != ENOENT)
341+
die_errno("BUG: unexpected fast_export_ls_rev error");
342+
fast_export_delete(dst);
343+
return;
344+
}
345+
fast_export_modify(dst, mode, data.buf);
346+
}
347+
315348
void fast_export_blob_delta(uint32_t mode,
316349
uint32_t old_mode, const char *old_data,
317350
off_t len, struct line_buffer *input)
@@ -320,7 +353,7 @@ void fast_export_blob_delta(uint32_t mode,
320353

321354
assert(len >= 0);
322355
postimage_len = apply_delta(len, input, old_data, old_mode);
323-
if (mode == REPO_MODE_LNK) {
356+
if (mode == S_IFLNK) {
324357
buffer_skip_bytes(&postimage, strlen("link "));
325358
postimage_len -= strlen("link ");
326359
}

vcs-svn/fast_export.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ int fast_export_ls_rev(uint32_t rev, const char *path,
2828
int fast_export_ls(const char *path,
2929
uint32_t *mode_out, struct strbuf *dataref_out);
3030

31+
void fast_export_copy(uint32_t revision, const char *src, const char *dst);
32+
const char *fast_export_read_path(const char *path, uint32_t *mode_out);
33+
3134
#endif

vcs-svn/repo_tree.c

Lines changed: 0 additions & 48 deletions
This file was deleted.

vcs-svn/repo_tree.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

vcs-svn/svndump.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
#include "cache.h"
11-
#include "repo_tree.h"
1211
#include "fast_export.h"
1312
#include "line_buffer.h"
1413
#include "strbuf.h"
@@ -134,13 +133,13 @@ static void handle_property(const struct strbuf *key_buf,
134133
die("invalid dump: sets type twice");
135134
}
136135
if (!val) {
137-
node_ctx.type = REPO_MODE_BLB;
136+
node_ctx.type = S_IFREG | 0644;
138137
return;
139138
}
140139
*type_set = 1;
141140
node_ctx.type = keylen == strlen("svn:executable") ?
142-
REPO_MODE_EXE :
143-
REPO_MODE_LNK;
141+
(S_IFREG | 0755) :
142+
S_IFLNK;
144143
}
145144
}
146145

@@ -219,45 +218,45 @@ static void handle_node(void)
219218
*/
220219
static const char *const empty_blob = "::empty::";
221220
const char *old_data = NULL;
222-
uint32_t old_mode = REPO_MODE_BLB;
221+
uint32_t old_mode = S_IFREG | 0644;
223222

224223
if (node_ctx.action == NODEACT_DELETE) {
225224
if (have_text || have_props || node_ctx.srcRev)
226225
die("invalid dump: deletion node has "
227226
"copyfrom info, text, or properties");
228-
svn_repo_delete(node_ctx.dst.buf);
227+
fast_export_delete(node_ctx.dst.buf);
229228
return;
230229
}
231230
if (node_ctx.action == NODEACT_REPLACE) {
232-
svn_repo_delete(node_ctx.dst.buf);
231+
fast_export_delete(node_ctx.dst.buf);
233232
node_ctx.action = NODEACT_ADD;
234233
}
235234
if (node_ctx.srcRev) {
236-
svn_repo_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf);
235+
fast_export_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf);
237236
if (node_ctx.action == NODEACT_ADD)
238237
node_ctx.action = NODEACT_CHANGE;
239238
}
240-
if (have_text && type == REPO_MODE_DIR)
239+
if (have_text && type == S_IFDIR)
241240
die("invalid dump: directories cannot have text attached");
242241

243242
/*
244243
* Find old content (old_data) and decide on the new mode.
245244
*/
246245
if (node_ctx.action == NODEACT_CHANGE && !*node_ctx.dst.buf) {
247-
if (type != REPO_MODE_DIR)
246+
if (type != S_IFDIR)
248247
die("invalid dump: root of tree is not a regular file");
249248
old_data = NULL;
250249
} else if (node_ctx.action == NODEACT_CHANGE) {
251250
uint32_t mode;
252-
old_data = svn_repo_read_path(node_ctx.dst.buf, &mode);
253-
if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
251+
old_data = fast_export_read_path(node_ctx.dst.buf, &mode);
252+
if (mode == S_IFDIR && type != S_IFDIR)
254253
die("invalid dump: cannot modify a directory into a file");
255-
if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR)
254+
if (mode != S_IFDIR && type == S_IFDIR)
256255
die("invalid dump: cannot modify a file into a directory");
257256
node_ctx.type = mode;
258257
old_mode = mode;
259258
} else if (node_ctx.action == NODEACT_ADD) {
260-
if (type == REPO_MODE_DIR)
259+
if (type == S_IFDIR)
261260
old_data = NULL;
262261
else if (have_text)
263262
old_data = empty_blob;
@@ -280,7 +279,7 @@ static void handle_node(void)
280279
/*
281280
* Save the result.
282281
*/
283-
if (type == REPO_MODE_DIR) /* directories are not tracked. */
282+
if (type == S_IFDIR) /* directories are not tracked. */
284283
return;
285284
assert(old_data);
286285
if (old_data == empty_blob)
@@ -385,9 +384,9 @@ void svndump_read(const char *url, const char *local_ref, const char *notes_ref)
385384
continue;
386385
strbuf_addf(&rev_ctx.note, "%s\n", t);
387386
if (!strcmp(val, "dir"))
388-
node_ctx.type = REPO_MODE_DIR;
387+
node_ctx.type = S_IFDIR;
389388
else if (!strcmp(val, "file"))
390-
node_ctx.type = REPO_MODE_BLB;
389+
node_ctx.type = S_IFREG | 0644;
391390
else
392391
fprintf(stderr, "Unknown node-kind: %s\n", val);
393392
break;

0 commit comments

Comments
 (0)