Index: updater.c =================================================================== --- updater.c (revision 186788) +++ updater.c (working copy) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -85,6 +86,9 @@ int deletecount; }; +extern int numdone; +static struct file_update *curfup = NULL; + static struct file_update *fup_new(struct coll *, struct status *); static int fup_prepare(struct file_update *, char *, int); static void fup_cleanup(struct file_update *); @@ -117,6 +121,7 @@ off_t); static int updater_rsync(struct updater *, struct file_update *, size_t); static int updater_read_checkout(struct stream *, struct stream *); +void updater_infohandler(int); static struct file_update * fup_new(struct coll *coll, struct status *st) @@ -127,6 +132,7 @@ memset(fup, 0, sizeof(*fup)); fup->coll = coll; fup->st = st; + fup->coname = NULL; return (fup); } @@ -233,6 +239,7 @@ up->rd = args->rd; up->errmsg = NULL; up->deletecount = 0; + signal(SIGINFO, updater_infohandler); error = updater_batch(up, 0); @@ -316,8 +323,10 @@ return (UPDATER_ERR_MSG); } fup = fup_new(coll, st); + curfup = fup; error = updater_docoll(up, fup, isfixups); status_close(st, &errmsg); + curfup = NULL; fup_free(fup); if (errmsg != NULL) { /* Discard previous error. */ @@ -2013,3 +2022,17 @@ free(buf); return (error); } + +void +updater_infohandler(int sig __unused) +{ + + if (curfup != NULL && curfup->coname != NULL) { + printf("updating %s %s", curfup->coll->co_base, curfup->coname); + if (status_numentries(curfup->st) > 0) + printf(" (%d%% done)", (int) + (((double)numdone * 100.0) / + (double)status_numentries(curfup->st))); + printf("\n"); + } +} Index: status.c =================================================================== --- status.c (revision 186788) +++ status.c (working copy) @@ -86,6 +86,7 @@ int linenum; int depth; int dirty; + int numentries; }; static void @@ -521,11 +522,12 @@ status_open(struct coll *coll, time_t scantime, char **errmsg) { struct status *st; - struct stream *file; + struct stream *file, *tmp; struct fattr *fa; char *destpath, *path; - int error, rv; + int error, isnew, rv; + isnew = access(path, F_OK); path = coll_statuspath(coll); file = stream_open_file(path, O_RDONLY); if (file == NULL) { @@ -536,6 +538,7 @@ return (NULL); } st = status_fromnull(path); + isnew = 1; } else { st = status_fromrd(path, file); if (st == NULL) { @@ -591,6 +594,17 @@ return (NULL); } } + + /* Count the number of entries in the file. */ + if (isnew) { + st->numentries = 0; + tmp = stream_open_file(path, O_RDONLY); + if (tmp == NULL) + return (st); + while (stream_getln(tmp, NULL) != NULL) + st->numentries++; + stream_close(tmp); + } return (st); } @@ -872,3 +886,9 @@ bad: status_free(st); } + +int +status_numentries(struct status *st) +{ + return (st->numentries); +} Index: status.h =================================================================== --- status.h (revision 186788) +++ status.h (working copy) @@ -68,5 +68,6 @@ char *status_errmsg(struct status *); int status_delete(struct status *, char *, int); void status_close(struct status *, char **); +int status_numentries(struct status *); #endif /* !_STATUS_H_ */ Index: lister.c =================================================================== --- lister.c (revision 186788) +++ lister.c (working copy) @@ -69,6 +69,8 @@ static int lister_dorcsdead(struct lister *, struct coll *, struct statusrec *); +int numdone = 0; + void * lister(void *arg) { @@ -212,6 +214,7 @@ } break; } + numdone++; } if (ret == -1) { l->errmsg = status_errmsg(st);