1 --- orig/batch.c 2005-03-27 05:13:14
2 +++ batch.c 2005-03-27 05:14:42
3 @@ -139,7 +139,7 @@ static void write_filter_rules(int fd)
5 void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
9 char *p, filename[MAXPATHLEN];
11 stringjoin(filename, sizeof filename,
12 @@ -175,11 +175,12 @@ void write_batch_shell_file(int argc, ch
16 - if (strncmp(p, "--write-batch", 13) == 0) {
17 + if (strncmp(p, "--write-batch", len = 13) == 0
18 + || strncmp(p, "--only-write-batch", len = 18) == 0) {
19 write(fd, "--read-batch", 12);
21 + if (p[len] == '=') {
23 - write_arg(fd, p + 14);
24 + write_arg(fd, p + len + 1);
28 --- orig/generator.c 2005-03-29 01:05:12
29 +++ generator.c 2005-03-24 07:07:12
35 extern int log_format_has_i;
36 extern int log_format_has_o_or_i;
37 extern int daemon_log_format_has_i;
38 @@ -1001,7 +1002,7 @@ prepare_to_open:
42 - if (dry_run || read_batch || whole_file)
43 + if (!do_xfers || read_batch || whole_file)
47 @@ -1073,7 +1074,7 @@ notify_others:
48 fuzzy_file ? fuzzy_file->basename : NULL);
53 if (preserve_hard_links && file->link_u.links)
54 hard_link_cluster(file, ndx, itemizing, code);
56 @@ -1121,9 +1122,9 @@ void generate_files(int f_out, struct fi
57 maybe_PERMS_REPORT = log_format_has_i ? 0 : PERMS_REPORT;
58 code = daemon_log_format_has_i ? 0 : FLOG;
59 } else if (am_daemon) {
60 - itemizing = daemon_log_format_has_i && !dry_run;
61 + itemizing = daemon_log_format_has_i && do_xfers;
62 maybe_PERMS_REPORT = PERMS_REPORT;
63 - code = itemizing || dry_run ? FCLIENT : FINFO;
64 + code = itemizing || !do_xfers ? FCLIENT : FINFO;
65 } else if (!am_server) {
66 itemizing = log_format_has_i;
67 maybe_PERMS_REPORT = log_format_has_i ? 0 : PERMS_REPORT;
68 --- orig/main.c 2005-03-16 02:19:30
69 +++ main.c 2005-03-24 07:07:12
70 @@ -168,7 +168,7 @@ static void report(int f)
71 stats.flist_buildtime = read_longint(f);
72 stats.flist_xfertime = read_longint(f);
74 - } else if (write_batch) {
75 + } else if (write_batch && !am_server) {
76 /* The --read-batch process is going to be a client
77 * receiver, so we need to give it the stats. */
78 write_longint(batch_fd, total_read);
79 @@ -583,7 +583,7 @@ static int do_recv(int f_in,int f_out,st
82 close_multiplexing_in();
84 + if (write_batch && !am_server)
88 @@ -756,7 +756,7 @@ int client_run(int f_in, int f_out, pid_
93 + if (write_batch && !am_server)
94 start_write_batch(f_out);
95 flist = send_file_list(f_out, argc, argv);
97 @@ -793,7 +793,7 @@ int client_run(int f_in, int f_out, pid_
102 + if (write_batch && !am_server)
103 start_write_batch(f_in);
104 flist = recv_file_list(f_in);
105 if (!flist || flist->count == 0) {
106 @@ -1111,7 +1111,7 @@ int main(int argc,char *argv[])
110 - if (write_batch || read_batch) {
111 + if ((write_batch || read_batch) && !am_server) {
113 write_batch_shell_file(orig_argc, orig_argv, argc);
115 @@ -1130,6 +1130,8 @@ int main(int argc,char *argv[])
117 read_stream_flags(batch_fd);
119 + if (write_batch < 0)
122 if (am_daemon && !am_server)
123 return daemon_main();
124 --- orig/options.c 2005-03-28 20:56:55
125 +++ options.c 2005-03-24 07:07:13
126 @@ -53,6 +53,7 @@ int omit_dir_times = 0;
131 int ignore_times = 0;
133 int delete_during = 0;
134 @@ -344,6 +345,7 @@ void usage(enum logcode F)
135 rprintf(F," --list-only list the files instead of copying them\n");
136 rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
137 rprintf(F," --write-batch=FILE write a batched update to FILE\n");
138 + rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
139 rprintf(F," --read-batch=FILE read a batched update from FILE\n");
140 rprintf(F," --protocol=NUM force an older protocol version to be used\n");
142 @@ -360,7 +362,8 @@ void usage(enum logcode F)
143 enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
144 OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
145 OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
146 - OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT, OPT_MAX_SIZE,
147 + OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH,
148 + OPT_TIMEOUT, OPT_MAX_SIZE,
149 OPT_REFUSED_BASE = 9000};
151 static struct poptOption long_options[] = {
152 @@ -450,6 +453,7 @@ static struct poptOption long_options[]
153 {"hard-links", 'H', POPT_ARG_NONE, &preserve_hard_links, 0, 0, 0 },
154 {"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
155 {"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
156 + {"only-write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
157 {"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
158 {"from0", '0', POPT_ARG_NONE, &eol_nulls, 0, 0, 0},
159 {"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 },
160 @@ -791,6 +795,11 @@ int parse_arguments(int *argc, const cha
164 + case OPT_ONLY_WRITE_BATCH:
165 + /* batch_name is already set */
170 /* batch_name is already set */
172 @@ -901,7 +910,7 @@ int parse_arguments(int *argc, const cha
173 "--write-batch and --read-batch can not be used together\n");
176 - if (write_batch || read_batch) {
177 + if (write_batch > 0 || read_batch) {
180 "ignoring --%s-batch option sent to server\n",
181 @@ -1093,6 +1102,9 @@ int parse_arguments(int *argc, const cha
188 if (verbose && !log_format) {
190 log_before_transfer = !am_server;
191 @@ -1246,7 +1258,7 @@ void server_options(char **args,int *arg
200 @@ -1374,6 +1386,8 @@ void server_options(char **args,int *arg
201 args[ac++] = "--delete-after";
203 args[ac++] = "--force";
204 + if (write_batch < 0)
205 + args[ac++] = "--only-write-batch=X";
209 --- orig/pipe.c 2005-02-07 20:36:43
210 +++ pipe.c 2005-03-24 07:07:13
211 @@ -25,7 +25,6 @@ extern int am_sender;
212 extern int am_server;
213 extern int blocking_io;
214 extern int orig_umask;
215 -extern int write_batch;
216 extern int filesfrom_fd;
219 @@ -128,10 +127,6 @@ pid_t local_child(int argc, char **argv,
220 am_sender = !am_sender;
223 - /* The server side never writes the batch, even if it
224 - * is local (it makes the logic easier elsewhere). */
230 --- orig/receiver.c 2005-03-24 16:41:46
231 +++ receiver.c 2005-03-24 07:07:13
237 +extern int do_xfers;
238 extern int am_daemon;
239 extern int am_server;
240 extern int do_progress;
241 @@ -30,6 +30,7 @@ extern int log_format_has_i;
242 extern int daemon_log_format_has_i;
243 extern int csum_length;
244 extern int read_batch;
245 +extern int write_batch;
246 extern int batch_gen_fd;
247 extern int protocol_version;
248 extern int relative_paths;
249 @@ -435,13 +436,18 @@ int recv_files(int f_in, struct file_lis
250 exit_cleanup(RERR_PROTOCOL);
253 - if (dry_run) { /* log the transfer */
254 + if (!do_xfers) { /* log the transfer */
255 if (!am_server && log_format)
256 log_item(file, &stats, iflags, NULL);
258 discard_receive_data(f_in, file->length);
261 + if (write_batch < 0) {
262 + log_item(file, &stats, iflags, NULL);
263 + discard_receive_data(f_in, file->length);
268 while (i > next_gen_i) {
269 --- orig/rsync.yo 2005-03-28 20:56:55
270 +++ rsync.yo 2005-03-27 05:13:01
271 @@ -379,6 +379,7 @@ to the detailed description below for a
272 --list-only list the files instead of copying them
273 --bwlimit=KBPS limit I/O bandwidth; KBytes per second
274 --write-batch=FILE write a batched update to FILE
275 + --only-write-batch=FILE like --write-batch but w/o updating dest
276 --read-batch=FILE read a batched update from FILE
277 --protocol=NUM force an older protocol version to be used
278 --checksum-seed=NUM set block/file checksum seed (advanced)
279 @@ -1271,6 +1272,16 @@ dit(bf(--write-batch=FILE)) Record a fil
280 another identical destination with bf(--read-batch). See the "BATCH MODE"
283 +dit(bf(--only-write-batch=FILE)) Works like bf(--write-batch), except that
284 +no updates are made on the destination system when creating the batch.
285 +This lets you transport the changes to the destination system via some
286 +other means and then apply the changes via bf(--read-batch). Note that
287 +you can feel free to write the batch directly to some portable media: if
288 +this media fills to capacity before the end of the transfer, you can just
289 +apply that partial transfer to the destination and repeat the whole process
290 +to get the rest of the changes (as long as you don't mind a partially
291 +updated destination system while the multi-update cycle is happening).
293 dit(bf(--read-batch=FILE)) Apply all of the changes stored in FILE, a
294 file previously generated by bf(--write-batch).
295 If em(FILE) is "-" the batch data will be read from standard input.
296 --- orig/sender.c 2005-03-28 20:56:55
297 +++ sender.c 2005-03-24 07:07:13
303 +extern int do_xfers;
304 extern int am_server;
305 extern int am_daemon;
306 extern int log_before_transfer;
307 @@ -34,6 +34,8 @@ extern int updating_basis_file;
308 extern int make_backups;
309 extern int do_progress;
311 +extern int batch_fd;
312 +extern int write_batch;
313 extern struct stats stats;
314 extern struct file_list *the_file_list;
315 extern char *log_format;
316 @@ -208,6 +210,7 @@ void send_files(struct file_list *flist,
317 int save_make_backups = make_backups;
318 int itemizing = am_daemon ? daemon_log_format_has_i
319 : !am_server && log_format_has_i;
320 + int f_xfer = write_batch < 0 ? batch_fd : f_out;
324 @@ -230,7 +233,7 @@ void send_files(struct file_list *flist,
328 - iflags = read_item_attrs(f_in, f_out, i, &fnamecmp_type,
329 + iflags = read_item_attrs(f_in, f_xfer, i, &fnamecmp_type,
331 if (iflags == ITEM_IS_NEW) /* no-op packet */
333 @@ -266,10 +269,10 @@ void send_files(struct file_list *flist,
334 stats.num_transferred_files++;
335 stats.total_transferred_size += file->length;
337 - if (dry_run) { /* log the transfer */
338 + if (!do_xfers) { /* log the transfer */
339 if (!am_server && log_format)
340 log_item(file, &stats, iflags, NULL);
341 - write_ndx_and_attrs(f_out, i, iflags, fnamecmp_type,
342 + write_ndx_and_attrs(f_xfer, i, iflags, fnamecmp_type,
346 @@ -321,9 +324,9 @@ void send_files(struct file_list *flist,
347 safe_fname(fname), (double)st.st_size);
350 - write_ndx_and_attrs(f_out, i, iflags, fnamecmp_type,
351 + write_ndx_and_attrs(f_xfer, i, iflags, fnamecmp_type,
353 - write_sum_head(f_out, s);
354 + write_sum_head(f_xfer, s);
357 rprintf(FINFO, "calling match_sums %s\n",
358 @@ -337,7 +340,7 @@ void send_files(struct file_list *flist,
360 set_compression(fname);
362 - match_sums(f_out, s, mbuf, st.st_size);
363 + match_sums(f_xfer, s, mbuf, st.st_size);
365 end_progress(st.st_size);