summaryrefslogtreecommitdiffstats
path: root/contrib/csup
diff options
context:
space:
mode:
authorlulf <lulf@FreeBSD.org>2009-01-02 12:40:58 +0000
committerlulf <lulf@FreeBSD.org>2009-01-02 12:40:58 +0000
commitf67ab72faf5803d2034f0aca36255d6710a395ca (patch)
treef553a0280d902cb49fd2c1b3dac838af19672bf9 /contrib/csup
parentfd8c0b9c3abd1f219f008e71e7c8119d9032be3b (diff)
downloadFreeBSD-src-f67ab72faf5803d2034f0aca36255d6710a395ca.zip
FreeBSD-src-f67ab72faf5803d2034f0aca36255d6710a395ca.tar.gz
- 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.
Diffstat (limited to 'contrib/csup')
-rw-r--r--contrib/csup/detailer.c2
-rw-r--r--contrib/csup/rcsfile.c34
-rw-r--r--contrib/csup/rcsfile.h2
-rw-r--r--contrib/csup/rcsparse.c11
-rw-r--r--contrib/csup/rcsparse.h2
-rw-r--r--contrib/csup/updater.c2
6 files changed, 36 insertions, 17 deletions
diff --git a/contrib/csup/detailer.c b/contrib/csup/detailer.c
index 20436c6..c03d6d2 100644
--- a/contrib/csup/detailer.c
+++ b/contrib/csup/detailer.c
@@ -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);
diff --git a/contrib/csup/rcsfile.c b/contrib/csup/rcsfile.c
index ca9d58f..177ef17 100644
--- a/contrib/csup/rcsfile.c
+++ b/contrib/csup/rcsfile.c
@@ -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)
{
diff --git a/contrib/csup/rcsfile.h b/contrib/csup/rcsfile.h
index 83887c7..a2c3f71 100644
--- a/contrib/csup/rcsfile.h
+++ b/contrib/csup/rcsfile.h
@@ -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 *);
diff --git a/contrib/csup/rcsparse.c b/contrib/csup/rcsparse.c
index 1e855f9..19aa8b5 100644
--- a/contrib/csup/rcsparse.c
+++ b/contrib/csup/rcsparse.c
@@ -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);
}
diff --git a/contrib/csup/rcsparse.h b/contrib/csup/rcsparse.h
index 21051e5..888d53d 100644
--- a/contrib/csup/rcsparse.h
+++ b/contrib/csup/rcsparse.h
@@ -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_ */
diff --git a/contrib/csup/updater.c b/contrib/csup/updater.c
index ff66c66..d73775b 100644
--- a/contrib/csup/updater.c
+++ b/contrib/csup/updater.c
@@ -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)); \
OpenPOWER on IntegriCloud