- Add an optimization when parsing rcsfiles when the intention is to only send
details to the cvsup server. The deltatext does not need parsing, and some parts of the rcsfile data structure doesn't need to be set up. - Fix a bug where the RCS expansion mode is not written out.
This commit is contained in:
parent
e0f42fb982
commit
c81ea6003c
@ -432,7 +432,7 @@ detailer_dofile_rcs(struct detailer *d, struct coll *coll, char *name,
|
||||
return (0);
|
||||
}
|
||||
|
||||
rf = rcsfile_frompath(path, name, coll->co_cvsroot, coll->co_tag);
|
||||
rf = rcsfile_frompath(path, name, coll->co_cvsroot, coll->co_tag, 1);
|
||||
free(path);
|
||||
if (rf == NULL) {
|
||||
error = proto_printf(wr, "A %s\n", name);
|
||||
|
@ -119,6 +119,7 @@ struct rcsfile {
|
||||
int strictlock;
|
||||
char *comment;
|
||||
int expand;
|
||||
int ro;
|
||||
struct branch *trunk; /* The tip delta. */
|
||||
|
||||
LIST_HEAD(, delta) deltatable;
|
||||
@ -153,6 +154,7 @@ const char *state_space = "\t";
|
||||
const char *next_space = "\t";
|
||||
const char *branches_space = "\t";
|
||||
const char *comment_space ="\t";
|
||||
const char *expand_space = "\t";
|
||||
|
||||
void print_stream(struct stream *);
|
||||
|
||||
@ -174,7 +176,7 @@ print_stream(struct stream *s)
|
||||
* Parse rcsfile from path and return a pointer to it.
|
||||
*/
|
||||
struct rcsfile *
|
||||
rcsfile_frompath(char *path, char *name, char *cvsroot, char *colltag)
|
||||
rcsfile_frompath(char *path, char *name, char *cvsroot, char *colltag, int ro)
|
||||
{
|
||||
struct rcsfile *rf;
|
||||
FILE *infp;
|
||||
@ -206,6 +208,7 @@ rcsfile_frompath(char *path, char *name, char *cvsroot, char *colltag)
|
||||
rf->comment = NULL;
|
||||
rf->expand = EXPAND_DEFAULT;
|
||||
rf->desc = NULL;
|
||||
rf->ro = ro;
|
||||
|
||||
infp = fopen(path, "r");
|
||||
if (infp == NULL) {
|
||||
@ -213,7 +216,7 @@ rcsfile_frompath(char *path, char *name, char *cvsroot, char *colltag)
|
||||
rcsfile_free(rf);
|
||||
return (NULL);
|
||||
}
|
||||
error = rcsparse_run(rf, infp);
|
||||
error = rcsparse_run(rf, infp, ro);
|
||||
fclose(infp);
|
||||
if (error) {
|
||||
lprintf(-1, "Error parsing \"%s\"\n", name);
|
||||
@ -343,6 +346,9 @@ rcsfile_write(struct rcsfile *rf, struct stream *dest)
|
||||
/* Write out the comment. */
|
||||
if (rf->comment != NULL)
|
||||
stream_printf(dest, "comment%s%s;\n", comment_space, rf->comment);
|
||||
if (rf->expand != EXPAND_DEFAULT)
|
||||
stream_printf(dest, "expand%s@%s@;\n", expand_space,
|
||||
keyword_encode_expand(rf->expand));
|
||||
|
||||
stream_printf(dest, "\n\n");
|
||||
|
||||
@ -694,7 +700,7 @@ rcsfile_print(struct rcsfile *rf)
|
||||
lprintf(1, "Strict!\n");
|
||||
if (rf->comment != NULL)
|
||||
lprintf(1, "comment: '%s'\n", rf->comment);
|
||||
if (rf->expand >= 0)
|
||||
if (rf->expand != EXPAND_DEFAULT);
|
||||
lprintf(1, "expand: '%s'\n", keyword_encode_expand(rf->expand));
|
||||
|
||||
/* Print all deltas. */
|
||||
@ -769,7 +775,8 @@ rcsfile_free(struct rcsfile *rf)
|
||||
/* Free all deltas in global list */
|
||||
while (!LIST_EMPTY(&rf->deltatable)) {
|
||||
d = LIST_FIRST(&rf->deltatable);
|
||||
LIST_REMOVE(d, delta_next);
|
||||
if (!rf->ro)
|
||||
LIST_REMOVE(d, delta_next);
|
||||
LIST_REMOVE(d, table_next);
|
||||
rcsfile_freedelta(d);
|
||||
}
|
||||
@ -871,7 +878,8 @@ rcsfile_deleterev(struct rcsfile *rf, char *revname)
|
||||
struct delta *d;
|
||||
|
||||
d = rcsfile_getdelta(rf, revname);
|
||||
LIST_REMOVE(d, delta_next);
|
||||
if (!rf->ro)
|
||||
LIST_REMOVE(d, delta_next);
|
||||
LIST_REMOVE(d, table_next);
|
||||
rcsfile_freedelta(d);
|
||||
}
|
||||
@ -1065,6 +1073,17 @@ rcsfile_importdelta(struct rcsfile *rf, char *revnum, char *revdate, char *autho
|
||||
d_next->diffbase = d;
|
||||
}
|
||||
|
||||
/* If we're opening read-only, do minimal work. */
|
||||
if (rf->ro) {
|
||||
if (!d->placeholder)
|
||||
rcsfile_insertsorteddelta(rf, d);
|
||||
else
|
||||
d->placeholder = 0;
|
||||
if (d_next != NULL)
|
||||
rcsfile_insertsorteddelta(rf, d_next);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If it's trunk, insert it in the head branch list. */
|
||||
b = rcsrev_istrunk(d->revnum) ? rf->trunk : rcsfile_getbranch(rf,
|
||||
d->revnum);
|
||||
@ -1152,10 +1171,7 @@ rcsfile_getbranch(struct rcsfile *rf, char *revnum)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a delta into the correct place in the table of the rcsfile. Sorted by
|
||||
* date.
|
||||
*/
|
||||
/* Insert a delta into the correct place in the table of the rcsfile. */
|
||||
static void
|
||||
rcsfile_insertsorteddelta(struct rcsfile *rf, struct delta *d)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ struct delta;
|
||||
struct stream;
|
||||
|
||||
/* Fetching, sending and writing an RCS file. */
|
||||
struct rcsfile *rcsfile_frompath(char *, char *, char *, char *);
|
||||
struct rcsfile *rcsfile_frompath(char *, char *, char *, char *, int);
|
||||
int rcsfile_send_details(struct rcsfile *, struct stream *);
|
||||
int rcsfile_write(struct rcsfile *, struct stream *);
|
||||
void rcsfile_print(struct rcsfile *);
|
||||
|
@ -82,7 +82,7 @@ duptext(yyscan_t *sp, int *arglen)
|
||||
* Start up parser, and use the rcsfile hook to add objects.
|
||||
*/
|
||||
int
|
||||
rcsparse_run(struct rcsfile *rf, FILE *infp)
|
||||
rcsparse_run(struct rcsfile *rf, FILE *infp, int ro)
|
||||
{
|
||||
yyscan_t scanner;
|
||||
char *desc;
|
||||
@ -99,9 +99,12 @@ rcsparse_run(struct rcsfile *rf, FILE *infp)
|
||||
rcsfile_setval(rf, RCSFILE_DESC, desc);
|
||||
free(desc);
|
||||
tok = rcslex(scanner);
|
||||
error = parse_deltatexts(rf, &scanner, tok);
|
||||
if (error)
|
||||
return (error);
|
||||
/* Parse deltatexts if we need to edit. */
|
||||
if (!ro) {
|
||||
error = parse_deltatexts(rf, &scanner, tok);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
rcslex_destroy(scanner);
|
||||
return (0);
|
||||
}
|
||||
|
@ -37,5 +37,5 @@
|
||||
#define COLON 6
|
||||
|
||||
struct rcsfile;
|
||||
int rcsparse_run(struct rcsfile *, FILE *);
|
||||
int rcsparse_run(struct rcsfile *, FILE *, int);
|
||||
#endif /* !_RCSPARSE_H_ */
|
||||
|
@ -1575,7 +1575,7 @@ updater_rcsedit(struct updater *up, struct file_update *fup, char *name,
|
||||
lprintf(1, " -> Attic"); \
|
||||
lprintf(1, "\n"); \
|
||||
(rf) = rcsfile_frompath((path), (name), (cvsroot), \
|
||||
(tag)); \
|
||||
(tag), 0); \
|
||||
if ((rf) == NULL) { \
|
||||
xasprintf(&(up)->errmsg, \
|
||||
"Error reading rcsfile %s\n", (name)); \
|
||||
|
Loading…
Reference in New Issue
Block a user