summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/add.c5
-rw-r--r--usr.bin/cvs/checkout.c3
-rw-r--r--usr.bin/cvs/client.c8
-rw-r--r--usr.bin/cvs/commit.c3
-rw-r--r--usr.bin/cvs/cvs.c7
-rw-r--r--usr.bin/cvs/edit.c3
-rw-r--r--usr.bin/cvs/entries.c32
-rw-r--r--usr.bin/cvs/file.c5
-rw-r--r--usr.bin/cvs/rcs.c26
-rw-r--r--usr.bin/cvs/remote.c3
-rw-r--r--usr.bin/cvs/remove.c4
-rw-r--r--usr.bin/cvs/server.c5
-rw-r--r--usr.bin/cvs/update.c10
-rw-r--r--usr.bin/cvs/util.c3
14 files changed, 60 insertions, 57 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 1023209ce32..b0c35f877d6 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.102 2008/06/14 02:34:27 tobias Exp $ */
+/* $OpenBSD: add.c,v 1.103 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -137,7 +137,6 @@ cvs_add_entry(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
} else {
@@ -282,7 +281,6 @@ add_directory(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, p);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(p);
}
}
@@ -495,7 +493,6 @@ add_entry(struct cvs_file *cf)
} else {
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
}
xfree(entry);
}
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 6afb5230cee..d231a0059d6 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.152 2008/06/12 16:55:48 tobias Exp $ */
+/* $OpenBSD: checkout.c,v 1.153 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -565,7 +565,6 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
if (!(co_flags & CO_REMOVE) && cvs_cmdop != CVS_OP_EXPORT) {
ent = cvs_ent_open(cf->file_wd);
cvs_ent_add(ent, entry);
- cvs_ent_close(ent, ENT_SYNC);
cf->file_ent = cvs_ent_parse(entry);
}
} else {
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c
index 4e2de50c91b..c34b408150b 100644
--- a/usr.bin/cvs/client.c
+++ b/usr.bin/cvs/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.115 2008/06/11 02:19:13 tobias Exp $ */
+/* $OpenBSD: client.c,v 1.116 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -189,7 +189,6 @@ client_check_directory(char *data, char *repository)
entlist = cvs_ent_open(parent);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
}
@@ -669,7 +668,6 @@ cvs_client_checkedin(char *data)
cvs_ent_free(newent);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
}
@@ -748,7 +746,6 @@ cvs_client_updated(char *data)
if (cvs_cmdop != CVS_OP_EXPORT) {
ent = cvs_ent_open(data);
cvs_ent_add(ent, entry);
- cvs_ent_close(ent, ENT_SYNC);
}
xfree(entry);
@@ -828,7 +825,6 @@ cvs_client_merged(char *data)
ent = cvs_ent_open(wdir);
cvs_ent_add(ent, entry);
- cvs_ent_close(ent, ENT_SYNC);
xfree(entry);
(void)unlink(fpath);
@@ -869,7 +865,6 @@ cvs_client_removed(char *data)
entlist = cvs_ent_open(data);
cvs_ent_remove(entlist, filename);
- cvs_ent_close(entlist, ENT_SYNC);
(void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", data, filename);
(void)unlink(fpath);
@@ -893,7 +888,6 @@ cvs_client_remove_entry(char *data)
entlist = cvs_ent_open(data);
cvs_ent_remove(entlist, filename);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(rpath);
}
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index ff58ca99d4c..ecfdf49741b 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.140 2008/06/10 19:00:17 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.141 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -633,7 +633,6 @@ cvs_commit_local(struct cvs_file *cf)
} else {
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_remove(entlist, cf->file_name);
- cvs_ent_close(entlist, ENT_SYNC);
cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index ed8e0288e48..13af5505665 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.147 2008/06/10 23:42:04 joris Exp $ */
+/* $OpenBSD: cvs.c,v 1.148 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -79,6 +79,8 @@ void sighandler(int);
volatile sig_atomic_t cvs_quit = 0;
volatile sig_atomic_t sig_received = 0;
+extern CVSENTRIES *current_list;
+
void
sighandler(int sig)
{
@@ -112,6 +114,9 @@ cvs_cleanup(void)
xfree(cvs_server_path);
cvs_server_path = NULL;
}
+
+ if (current_list != NULL)
+ cvs_ent_close(current_list, ENT_SYNC);
}
__dead void
diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c
index cc7944a299d..ef22aa61385 100644
--- a/usr.bin/cvs/edit.c
+++ b/usr.bin/cvs/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.46 2008/06/11 02:19:13 tobias Exp $ */
+/* $OpenBSD: edit.c,v 1.47 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org>
*
@@ -408,7 +408,6 @@ cvs_unedit_local(struct cvs_file *cf)
cvs_ent_add(entlist, entry);
cvs_ent_free(ent);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
}
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 6c4d8848a9c..e9f1f579f86 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.97 2008/06/11 02:19:13 tobias Exp $ */
+/* $OpenBSD: entries.c,v 1.98 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -28,6 +28,8 @@
static struct cvs_ent_line *ent_get_line(CVSENTRIES *, const char *);
+CVSENTRIES *current_list = NULL;
+
CVSENTRIES *
cvs_ent_open(const char *dir)
{
@@ -37,10 +39,19 @@ cvs_ent_open(const char *dir)
struct cvs_ent *ent;
struct cvs_ent_line *line;
- ep = (CVSENTRIES *)xcalloc(1, sizeof(*ep));
+ cvs_log(LP_TRACE, "cvs_ent_open(%s)", dir);
(void)xsnprintf(buf, sizeof(buf), "%s/%s", dir, CVS_PATH_ENTRIES);
+ if (current_list != NULL && !strcmp(current_list->cef_path, buf))
+ return (current_list);
+
+ if (current_list != NULL) {
+ cvs_ent_close(current_list, ENT_SYNC);
+ current_list = NULL;
+ }
+
+ ep = (CVSENTRIES *)xcalloc(1, sizeof(*ep));
ep->cef_path = xstrdup(buf);
(void)xsnprintf(buf, sizeof(buf), "%s/%s",
@@ -100,6 +111,7 @@ cvs_ent_open(const char *dir)
(void)fclose(fp);
}
+ current_list = ep;
return (ep);
}
@@ -235,15 +247,17 @@ cvs_ent_close(CVSENTRIES *ep, int writefile)
int dflag;
dflag = 1;
+ cvs_log(LP_TRACE, "cvs_ent_close(%s, %d)", ep->cef_bpath, writefile);
- if (writefile) {
- if ((fp = fopen(ep->cef_bpath, "w")) == NULL)
- fatal("cvs_ent_close: fopen: `%s': %s",
- ep->cef_path, strerror(errno));
- }
+ if (cvs_cmdop == CVS_OP_EXPORT)
+ writefile = 0;
+
+ fp = NULL;
+ if (writefile)
+ fp = fopen(ep->cef_bpath, "w");
while ((l = TAILQ_FIRST(&(ep->cef_ent))) != NULL) {
- if (writefile) {
+ if (fp != NULL) {
if (l->buf[0] == 'D')
dflag = 0;
@@ -256,7 +270,7 @@ cvs_ent_close(CVSENTRIES *ep, int writefile)
xfree(l);
}
- if (writefile) {
+ if (fp != NULL) {
if (dflag) {
fputc('D', fp);
fputc('\n', fp);
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index 2067db6d2bd..07f75ed6100 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.246 2008/06/13 17:15:13 joris Exp $ */
+/* $OpenBSD: file.c,v 1.247 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -573,8 +573,6 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
cvs_ent_free(ent);
}
- cvs_ent_close(entlist, ENT_NOSYNC);
-
walkrepo:
if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
cvs_get_repository_path(cf->file_path, repo, MAXPATHLEN);
@@ -657,7 +655,6 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
if (cmdp->cmd_flags & CVS_USE_WDIR) {
entlist = cvs_ent_open(cf->file_wd);
cf->file_ent = cvs_ent_get(entlist, cf->file_name);
- cvs_ent_close(entlist, ENT_NOSYNC);
} else
cf->file_ent = NULL;
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 2bbeb32bbad..f87a072b439 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.272 2008/06/14 00:47:49 tobias Exp $ */
+/* $OpenBSD: rcs.c,v 1.273 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -2992,7 +2992,7 @@ rcs_rev_getbuf(RCSFILE *rfp, RCSNUM *rev, int mode)
expand = 0;
lines = rcs_rev_getlines(rfp, rev, NULL);
- bp = cvs_buf_alloc(1024 * 1024);
+ bp = cvs_buf_alloc(1024 * 16);
if (!(mode & RCS_KWEXP_NONE)) {
if (rfp->rf_expand != NULL)
@@ -3035,8 +3035,11 @@ rcs_rev_getbuf(RCSFILE *rfp, RCSNUM *rev, int mode)
* file descriptor <fd>.
*/
void
-rcs_rev_write_fd(RCSFILE *rfp, RCSNUM *rev, int fd, int mode)
+rcs_rev_write_fd(RCSFILE *rfp, RCSNUM *rev, int _fd, int mode)
{
+ int fd;
+ FILE *fp;
+ size_t ret;
int expmode, expand;
struct rcs_delta *rdp;
struct cvs_lines *lines;
@@ -3059,6 +3062,13 @@ rcs_rev_write_fd(RCSFILE *rfp, RCSNUM *rev, int fd, int mode)
}
}
+ fd = dup(_fd);
+ if (fd == -1)
+ fatal("rcs_rev_write_fd: dup: %s", strerror(errno));
+
+ if ((fp = fdopen(fd, "w")) == NULL)
+ fatal("rcs_rev_write_fd: fdopen: %s", strerror(errno));
+
for (lp = TAILQ_FIRST(&lines->l_lines); lp != NULL;) {
nlp = TAILQ_NEXT(lp, l_list);
@@ -3077,19 +3087,20 @@ rcs_rev_write_fd(RCSFILE *rfp, RCSNUM *rev, int fd, int mode)
if (cvs_server_active == 1 &&
(cvs_cmdop == CVS_OP_CHECKOUT ||
cvs_cmdop == CVS_OP_UPDATE) && print_stdout == 1) {
- if (atomicio(vwrite, fd, "M ", 2) != 2)
+ ret = fwrite("M ", 1, 2, fp);
+ if (ret != 2)
fatal("rcs_rev_write_fd: %s",
strerror(errno));
}
- if (atomicio(vwrite, fd, lp->l_line, lp->l_len) !=
- lp->l_len)
+ ret = fwrite(lp->l_line, 1, lp->l_len, fp);
+ if (ret != lp->l_len)
fatal("rcs_rev_write_fd: %s", strerror(errno));
} while ((lp = TAILQ_NEXT(lp, l_list)) != nlp);
}
cvs_freelines(lines);
-
+ (void)fclose(fp);
}
/*
@@ -3605,4 +3616,3 @@ rcs_translate_tag(const char *revstr, RCSFILE *rfp)
return (NULL);
}
-
diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c
index f472dcc274d..b3a0f538244 100644
--- a/usr.bin/cvs/remote.c
+++ b/usr.bin/cvs/remote.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.c,v 1.23 2008/06/12 07:16:14 joris Exp $ */
+/* $OpenBSD: remote.c,v 1.24 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -247,7 +247,6 @@ cvs_remote_classify_file(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cf->file_ent = cvs_ent_get(entlist, cf->file_name);
- cvs_ent_close(entlist, ENT_NOSYNC);
if (cf->file_ent != NULL && cf->file_ent->ce_status != CVS_ENT_REG) {
if (cf->file_ent->ce_status == CVS_ENT_ADDED)
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 195947dd6f0..e52975fd0af 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.77 2008/06/14 02:43:47 tobias Exp $ */
+/* $OpenBSD: remove.c,v 1.78 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -168,7 +168,6 @@ cvs_remove_local(struct cvs_file *cf)
case FILE_REMOVE_ENTRY:
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_remove(entlist, cf->file_name);
- cvs_ent_close(entlist, ENT_SYNC);
(void)xsnprintf(buf, sizeof(buf), "%s/%s/%s%s",
cf->file_wd, CVS_PATH_CVSDIR, cf->file_name,
@@ -210,7 +209,6 @@ cvs_remove_local(struct cvs_file *cf)
} else {
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
}
xfree(entry);
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index e61ec3a49c5..d9955e83c8d 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.90 2008/06/12 07:16:14 joris Exp $ */
+/* $OpenBSD: server.c,v 1.91 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -361,7 +361,6 @@ cvs_server_directory(char *data)
entlist = cvs_ent_open(parent);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
}
@@ -382,7 +381,6 @@ cvs_server_entry(char *data)
entlist = cvs_ent_open(server_currentdir);
cvs_ent_add(entlist, data);
- cvs_ent_close(entlist, ENT_SYNC);
}
void
@@ -462,7 +460,6 @@ cvs_server_unchanged(char *data)
cvs_ent_free(ent);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
}
void
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index fe21ebe49a1..29c83528f43 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.151 2008/06/12 07:16:14 joris Exp $ */
+/* $OpenBSD: update.c,v 1.152 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -42,6 +42,8 @@ static int Aflag = 0;
static void update_clear_conflict(struct cvs_file *);
static void update_join_file(struct cvs_file *);
+extern CVSENTRIES *current_list;
+
struct cvs_cmd cvs_cmd_update = {
CVS_OP_UPDATE, CVS_USE_WDIR, "update",
{ "up", "upd" },
@@ -210,7 +212,6 @@ cvs_update_enterdir(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
}
} else if ((cf->file_status == DIR_CREATE && build_dirs == 0) ||
@@ -278,8 +279,6 @@ cvs_update_leavedir(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_path);
if (!TAILQ_EMPTY(&(entlist->cef_ent)))
isempty = 0;
-
- cvs_ent_close(entlist, ENT_NOSYNC);
} else {
isempty = 0;
}
@@ -304,7 +303,6 @@ cvs_update_leavedir(struct cvs_file *cf)
if (cvs_server_active == 0 && cvs_cmdop != CVS_OP_EXPORT) {
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_remove(entlist, cf->file_name);
- cvs_ent_close(entlist, ENT_SYNC);
}
}
}
@@ -448,7 +446,6 @@ cvs_update_local(struct cvs_file *cf)
case FILE_REMOVE_ENTRY:
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_remove(entlist, cf->file_name);
- cvs_ent_close(entlist, ENT_SYNC);
cvs_history_add(CVS_HISTORY_UPDATE_REMOVE, cf, NULL);
break;
case FILE_UPTODATE:
@@ -501,7 +498,6 @@ update_clear_conflict(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
}
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 8b158889be0..3ad983df1c3 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.145 2008/06/12 07:16:14 joris Exp $ */
+/* $OpenBSD: util.c,v 1.146 2008/06/14 03:19:15 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -654,7 +654,6 @@ cvs_mkpath(const char *path, char *tag)
ent = cvs_ent_open(rpath);
cvs_ent_add(ent, entry);
- cvs_ent_close(ent, ENT_SYNC);
xfree(entry);
if (p != NULL)