svn commit: r186700 - projects/csup_cvsmode/contrib/csup
Ulf Lilleengen
lulf at FreeBSD.org
Fri Jan 2 12:40:58 UTC 2009
Author: lulf
Date: Fri Jan 2 12:40:58 2009
New Revision: 186700
URL: http://svn.freebsd.org/changeset/base/186700
Log:
- 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.
Modified:
projects/csup_cvsmode/contrib/csup/detailer.c
projects/csup_cvsmode/contrib/csup/rcsfile.c
projects/csup_cvsmode/contrib/csup/rcsfile.h
projects/csup_cvsmode/contrib/csup/rcsparse.c
projects/csup_cvsmode/contrib/csup/rcsparse.h
projects/csup_cvsmode/contrib/csup/updater.c
Modified: projects/csup_cvsmode/contrib/csup/detailer.c
==============================================================================
--- projects/csup_cvsmode/contrib/csup/detailer.c Fri Jan 2 12:37:31 2009 (r186699)
+++ projects/csup_cvsmode/contrib/csup/detailer.c Fri Jan 2 12:40:58 2009 (r186700)
@@ -432,7 +432,7 @@ detailer_dofile_rcs(struct detailer *d,
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);
Modified: projects/csup_cvsmode/contrib/csup/rcsfile.c
==============================================================================
--- projects/csup_cvsmode/contrib/csup/rcsfile.c Fri Jan 2 12:37:31 2009 (r186699)
+++ projects/csup_cvsmode/contrib/csup/rcsfile.c Fri Jan 2 12:40:58 2009 (r186700)
@@ -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,
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,
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
/* 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, ch
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,
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, ch
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)
{
Modified: projects/csup_cvsmode/contrib/csup/rcsfile.h
==============================================================================
--- projects/csup_cvsmode/contrib/csup/rcsfile.h Fri Jan 2 12:37:31 2009 (r186699)
+++ projects/csup_cvsmode/contrib/csup/rcsfile.h Fri Jan 2 12:40:58 2009 (r186700)
@@ -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 *);
Modified: projects/csup_cvsmode/contrib/csup/rcsparse.c
==============================================================================
--- projects/csup_cvsmode/contrib/csup/rcsparse.c Fri Jan 2 12:37:31 2009 (r186699)
+++ projects/csup_cvsmode/contrib/csup/rcsparse.c Fri Jan 2 12:40:58 2009 (r186700)
@@ -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 *i
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);
}
Modified: projects/csup_cvsmode/contrib/csup/rcsparse.h
==============================================================================
--- projects/csup_cvsmode/contrib/csup/rcsparse.h Fri Jan 2 12:37:31 2009 (r186699)
+++ projects/csup_cvsmode/contrib/csup/rcsparse.h Fri Jan 2 12:40:58 2009 (r186700)
@@ -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_ */
Modified: projects/csup_cvsmode/contrib/csup/updater.c
==============================================================================
--- projects/csup_cvsmode/contrib/csup/updater.c Fri Jan 2 12:37:31 2009 (r186699)
+++ projects/csup_cvsmode/contrib/csup/updater.c Fri Jan 2 12:40:58 2009 (r186700)
@@ -1575,7 +1575,7 @@ updater_rcsedit(struct updater *up, stru
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)); \
More information about the svn-src-projects
mailing list