Skip to content

Commit 530f237

Browse files
committed
Merge branch 'fa/remote-svn'
A GSoC project. * fa/remote-svn: Add a test script for remote-svn remote-svn: add marks-file regeneration Add a svnrdump-simulator replaying a dump file for testing remote-svn: add incremental import remote-svn: Activate import/export-marks for fast-import Create a note for every imported commit containing svn metadata vcs-svn: add fast_export_note to create notes Allow reading svn dumps from files via file:// urls remote-svn, vcs-svn: Enable fetching to private refs When debug==1, start fast-import with "--stats" instead of "--quiet" Add documentation for the 'bidi-import' capability of remote-helpers Connect fast-import to the remote-helper via pipe, adding 'bidi-import' capability Add argv_array_detach and argv_array_free_detached Add svndump_init_fd to allow reading dumps from arbitrary FDs Add git-remote-testsvn to Makefile Implement a remote helper for svn in C
2 parents 8de8f9f + e99d012 commit 530f237

16 files changed

+655
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
/git-remote-fd
126126
/git-remote-ext
127127
/git-remote-testgit
128+
/git-remote-testsvn
128129
/git-repack
129130
/git-replace
130131
/git-repo-config

Documentation/git-remote-helpers.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ advertised with this capability must cover all refs reported by
9898
the list command. If no 'refspec' capability is advertised,
9999
there is an implied `refspec *:*`.
100100

101+
'bidi-import'::
102+
The fast-import commands 'cat-blob' and 'ls' can be used by remote-helpers
103+
to retrieve information about blobs and trees that already exist in
104+
fast-import's memory. This requires a channel from fast-import to the
105+
remote-helper.
106+
If it is advertised in addition to "import", git establishes a pipe from
107+
fast-import to the remote-helper's stdin.
108+
It follows that git and fast-import are both connected to the
109+
remote-helper's stdin. Because git can send multiple commands to
110+
the remote-helper it is required that helpers that use 'bidi-import'
111+
buffer all 'import' commands of a batch before sending data to fast-import.
112+
This is to prevent mixing commands and fast-import responses on the
113+
helper's stdin.
114+
101115
Capabilities for Pushing
102116
~~~~~~~~~~~~~~~~~~~~~~~~
103117
'connect'::
@@ -286,7 +300,12 @@ terminated with a blank line. For each batch of 'import', the remote
286300
helper should produce a fast-import stream terminated by a 'done'
287301
command.
288302
+
289-
Supported if the helper has the "import" capability.
303+
Note that if the 'bidi-import' capability is used the complete batch
304+
sequence has to be buffered before starting to send data to fast-import
305+
to prevent mixing of commands and fast-import responses on the helper's
306+
stdin.
307+
+
308+
Supported if the helper has the 'import' capability.
290309

291310
'connect' <service>::
292311
Connects to given service. Standard input and standard output

Documentation/technical/api-argv-array.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ Functions
5353
`argv_array_clear`::
5454
Free all memory associated with the array and return it to the
5555
initial, empty state.
56+
57+
`argv_array_detach`::
58+
Detach the argv array from the `struct argv_array`, transfering
59+
ownership of the allocated array and strings.
60+
61+
`argv_array_free_detached`::
62+
Free the memory allocated by a `struct argv_array` that was later
63+
detached and is now no longer needed.

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ PROGRAM_OBJS += sh-i18n--envsubst.o
495495
PROGRAM_OBJS += shell.o
496496
PROGRAM_OBJS += show-index.o
497497
PROGRAM_OBJS += upload-pack.o
498+
PROGRAM_OBJS += remote-testsvn.o
498499

499500
# Binary suffix, set to .exe for Windows builds
500501
X =
@@ -2449,6 +2450,10 @@ git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS)
24492450
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
24502451
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
24512452

2453+
git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
2454+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
2455+
$(VCSSVN_LIB)
2456+
24522457
$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
24532458
$(QUIET_LNCP)$(RM) $@ && \
24542459
ln $< $@ 2>/dev/null || \

argv-array.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,23 @@ void argv_array_clear(struct argv_array *array)
6868
}
6969
argv_array_init(array);
7070
}
71+
72+
const char **argv_array_detach(struct argv_array *array, int *argc)
73+
{
74+
const char **argv =
75+
array->argv == empty_argv || array->argc == 0 ? NULL : array->argv;
76+
if (argc)
77+
*argc = array->argc;
78+
argv_array_init(array);
79+
return argv;
80+
}
81+
82+
void argv_array_free_detached(const char **argv)
83+
{
84+
if (argv) {
85+
int i;
86+
for (i = 0; argv[i]; i++)
87+
free((char **)argv[i]);
88+
free(argv);
89+
}
90+
}

argv-array.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ void argv_array_pushf(struct argv_array *, const char *fmt, ...);
1818
void argv_array_pushl(struct argv_array *, ...);
1919
void argv_array_pop(struct argv_array *);
2020
void argv_array_clear(struct argv_array *);
21+
const char **argv_array_detach(struct argv_array *array, int *argc);
22+
void argv_array_free_detached(const char **argv);
2123

2224
#endif /* ARGV_ARRAY_H */

contrib/svn-fe/svn-fe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ int main(int argc, char **argv)
1010
{
1111
if (svndump_init(NULL))
1212
return 1;
13-
svndump_read((argc > 1) ? argv[1] : NULL);
13+
svndump_read((argc > 1) ? argv[1] : NULL, "refs/heads/master",
14+
"refs/notes/svn/revs");
1415
svndump_deinit();
1516
svndump_reset();
1617
return 0;

contrib/svn-fe/svnrdump_sim.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/python
2+
"""
3+
Simulates svnrdump by replaying an existing dump from a file, taking care
4+
of the specified revision range.
5+
To simulate incremental imports the environment variable SVNRMAX can be set
6+
to the highest revision that should be available.
7+
"""
8+
import sys, os
9+
10+
11+
def getrevlimit():
12+
var = 'SVNRMAX'
13+
if os.environ.has_key(var):
14+
return os.environ[var]
15+
return None
16+
17+
def writedump(url, lower, upper):
18+
if url.startswith('sim://'):
19+
filename = url[6:]
20+
if filename[-1] == '/': filename = filename[:-1] #remove terminating slash
21+
else:
22+
raise ValueError('sim:// url required')
23+
f = open(filename, 'r');
24+
state = 'header'
25+
wroterev = False
26+
while(True):
27+
l = f.readline()
28+
if l == '': break
29+
if state == 'header' and l.startswith('Revision-number: '):
30+
state = 'prefix'
31+
if state == 'prefix' and l == 'Revision-number: %s\n' % lower:
32+
state = 'selection'
33+
if not upper == 'HEAD' and state == 'selection' and l == 'Revision-number: %s\n' % upper:
34+
break;
35+
36+
if state == 'header' or state == 'selection':
37+
if state == 'selection': wroterev = True
38+
sys.stdout.write(l)
39+
return wroterev
40+
41+
if __name__ == "__main__":
42+
if not (len(sys.argv) in (3, 4, 5)):
43+
print "usage: %s dump URL -rLOWER:UPPER"
44+
sys.exit(1)
45+
if not sys.argv[1] == 'dump': raise NotImplementedError('only "dump" is suppported.')
46+
url = sys.argv[2]
47+
r = ('0', 'HEAD')
48+
if len(sys.argv) == 4 and sys.argv[3][0:2] == '-r':
49+
r = sys.argv[3][2:].lstrip().split(':')
50+
if not getrevlimit() is None: r[1] = getrevlimit()
51+
if writedump(url, r[0], r[1]): ret = 0
52+
else: ret = 1
53+
sys.exit(ret)

0 commit comments

Comments
 (0)