summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2008-06-12 07:16:15 +0000
committerJoris Vink <joris@cvs.openbsd.org>2008-06-12 07:16:15 +0000
commitff05b352e851c0121dd005f16aee6d1a36088df7 (patch)
treefd53b93d52a75aa4bf4f88da4de96e8355ecec8e /usr.bin/cvs
parent750260e3bf10f2e3e7853d979f57c79e3d35d6f8 (diff)
completely kill the need for TMP_DIR when running checkout,
which gives us better performance among other things. this is however disabled in a few cases: 1) whenever you run checkout over an existing tree (which acts as update) 2) whenever you specify -d or a module alias we're planning on enabling this behaviour for case 2 in the future. anoncvs sysadmins now love us even more. ok tobias@
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/checkout.c56
-rw-r--r--usr.bin/cvs/file.c5
-rw-r--r--usr.bin/cvs/rcs.c4
-rw-r--r--usr.bin/cvs/remote.c32
-rw-r--r--usr.bin/cvs/remote.h3
-rw-r--r--usr.bin/cvs/server.c14
-rw-r--r--usr.bin/cvs/update.c9
-rw-r--r--usr.bin/cvs/util.c9
-rw-r--r--usr.bin/cvs/util.h4
9 files changed, 91 insertions, 45 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index f44daef445e..dde80cdb3c4 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.150 2008/06/11 21:24:50 joris Exp $ */
+/* $OpenBSD: checkout.c,v 1.151 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -49,7 +49,9 @@ static char *dateflag = NULL;
static int nflag = 0;
char *checkout_target_dir = NULL;
+
time_t cvs_specified_date = -1;
+int disable_fast_checkout = 0;
struct cvs_cmd cvs_cmd_checkout = {
CVS_OP_CHECKOUT, CVS_USE_WDIR, "checkout",
@@ -98,6 +100,9 @@ cvs_checkout(int argc, char **argv)
fatal("-d specified two or more times");
dflag = optarg;
checkout_target_dir = dflag;
+
+ if (cvs_server_active == 1)
+ disable_fast_checkout = 1;
break;
case 'j':
if (cvs_join_rev1 == NULL)
@@ -152,8 +157,16 @@ cvs_checkout(int argc, char **argv)
if (argc == 0)
fatal("%s", cvs_cmd_checkout.cmd_synopsis);
+ if (cvs_server_active == 1 && disable_fast_checkout != 1) {
+ cmdp->cmd_flags &= ~CVS_USE_WDIR;
+ cvs_noexec = 1;
+ }
+
checkout_check_repository(argc, argv);
+ if (cvs_server_active == 1 && disable_fast_checkout != 1)
+ cvs_noexec = 0;
+
return (0);
}
@@ -410,7 +423,14 @@ checkout_repository(const char *repobase, const char *wdbase)
cr.leavedir = NULL;
} else {
cr.enterdir = cvs_update_enterdir;
- cr.leavedir = cvs_update_leavedir;
+ if (cvs_server_active == 1) {
+ if (disable_fast_checkout != 1)
+ cr.leavedir = NULL;
+ else
+ cr.leavedir = cvs_update_leavedir;
+ } else {
+ cr.leavedir = prune_dirs ? cvs_update_leavedir : NULL;
+ }
}
cr.fileproc = cvs_update_local;
cr.flags = flags;
@@ -431,14 +451,14 @@ checkout_repository(const char *repobase, const char *wdbase)
void
cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
{
+ BUF *bp;
mode_t mode;
int cf_kflag, exists, fd;
time_t rcstime;
CVSENTRIES *ent;
struct timeval tv[2];
struct tm datetm;
- char *tosend;
- char template[MAXPATHLEN], *entry;
+ char *entry, *tosend;
char kbuf[8], sticky[CVS_REV_BUFSZ], rev[CVS_REV_BUFSZ];
char timebuf[CVS_TIME_BUFSZ], tbuf[CVS_TIME_BUFSZ];
@@ -571,31 +591,13 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
xfree(entry);
if (!(co_flags & CO_MERGE)) {
- (void)xsnprintf(template, MAXPATHLEN,
- "%s/checkout.XXXXXXXXXX", cvs_tmpdir);
-
- fd = rcs_rev_write_stmp(cf->file_rcs, rnum,
- template, 0);
-
mode = cf->file_rcs->rf_mode;
mode |= S_IWUSR;
-
- if (fchmod(fd, mode) == -1) {
- cvs_log(LP_ERR,
- "failed to set mode for %s",
- cf->file_path);
- }
-
- tosend = template;
- }
-
- cvs_remote_send_file(tosend, fd);
-
- if (!(co_flags & CO_MERGE)) {
- close(fd);
- (void)unlink(template);
- cvs_worklist_run(&temp_files,
- cvs_worklist_unlink);
+ bp = rcs_rev_getbuf(cf->file_rcs, rnum, 0);
+ cvs_remote_send_file_buf(cf->file_path,
+ bp, mode);
+ } else {
+ cvs_remote_send_file(tosend, fd);
}
}
}
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index a44cea74164..f2ac9e1fa0e 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.242 2008/06/09 22:31:24 tobias Exp $ */
+/* $OpenBSD: file.c,v 1.243 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -46,6 +46,7 @@
#define CVS_CHAR_ISMETA(c) ((c == '*') || (c == '?') || (c == '['))
extern int print_stdout;
+extern int build_dirs;
/*
* Standard patterns to ignore.
@@ -584,7 +585,7 @@ walkrepo:
xsnprintf(fpath, sizeof(fpath), "%s/%s", cf->file_path,
CVS_PATH_STATICENTRIES);
- if (stat(fpath, &st) == -1)
+ if (stat(fpath, &st) == -1 || build_dirs == 1)
cvs_repository_getdir(repo, cf->file_path, &fl, &dl,
(cr->flags & CR_RECURSE_DIRS));
}
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 0fcc3b4ddc4..62da76238c9 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.269 2008/06/10 20:30:17 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.270 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -2986,7 +2986,7 @@ rcs_rev_getbuf(RCSFILE *rfp, RCSNUM *rev, int mode)
expand = 0;
lines = rcs_rev_getlines(rfp, rev, NULL);
- bp = cvs_buf_alloc(1024);
+ bp = cvs_buf_alloc(1024 * 1024);
if (!(mode & RCS_KWEXP_NONE)) {
if (rfp->rf_expand != NULL)
diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c
index 4ed44f6bfa4..f472dcc274d 100644
--- a/usr.bin/cvs/remote.c
+++ b/usr.bin/cvs/remote.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.c,v 1.22 2008/03/08 11:53:36 joris Exp $ */
+/* $OpenBSD: remote.c,v 1.23 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -210,6 +210,36 @@ cvs_remote_send_file(const char *path, int _fd)
}
void
+cvs_remote_send_file_buf(char *file, BUF *bp, mode_t mode)
+{
+ char buf[18];
+ u_char *data;
+ size_t len, ret;
+
+ if (cvs_server_active != 1)
+ fatal("cvs_remote_send_file_buf is server only");
+
+ len = cvs_buf_len(bp);
+ data = cvs_buf_release(bp);
+
+ cvs_modetostr(mode, buf, sizeof(buf));
+ cvs_remote_output(buf);
+
+ (void)xsnprintf(buf, sizeof(buf), "%ld", len);
+ cvs_remote_output(buf);
+
+ ret = fwrite(data, sizeof(char), len, stdout);
+ if (ret != len)
+ cvs_log(LP_ERR, "warning: sent %s truncated", file);
+
+ if (cvs_server_active == 0 && cvs_client_inlog_fd != -1 &&
+ atomicio(vwrite, cvs_client_inlog_fd, data, len) != len)
+ fatal("failed to write to log file");
+
+ xfree(data);
+}
+
+void
cvs_remote_classify_file(struct cvs_file *cf)
{
struct stat st;
diff --git a/usr.bin/cvs/remote.h b/usr.bin/cvs/remote.h
index bb49701907f..c3e61238cf3 100644
--- a/usr.bin/cvs/remote.h
+++ b/usr.bin/cvs/remote.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.h,v 1.32 2008/02/27 22:34:04 joris Exp $ */
+/* $OpenBSD: remote.h,v 1.33 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -120,6 +120,7 @@ void cvs_remote_output(const char *);
char *cvs_remote_input(void);
void cvs_remote_receive_file(int, size_t);
void cvs_remote_send_file(const char *, int);
+void cvs_remote_send_file_buf(char *, BUF *, mode_t);
extern int cvs_client_inlog_fd;
extern int cvs_client_outlog_fd;
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index f757c28c36f..e61ec3a49c5 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.89 2008/06/10 05:01:36 tobias Exp $ */
+/* $OpenBSD: server.c,v 1.90 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -75,6 +75,8 @@ static char *server_currentdir = NULL;
static char **server_argv;
static int server_argc = 1;
+extern int disable_fast_checkout;
+
struct cvs_cmd cvs_cmd_server = {
CVS_OP_SERVER, CVS_USE_WDIR, "server", { "", "" },
"server mode",
@@ -395,6 +397,9 @@ cvs_server_modified(char *data)
if (data == NULL)
fatal("Missing argument for Modified");
+ /* sorry, we have to use TMP_DIR */
+ disable_fast_checkout = 1;
+
mode = cvs_remote_input();
len = cvs_remote_input();
@@ -436,6 +441,9 @@ cvs_server_unchanged(char *data)
if (data == NULL)
fatal("Missing argument for Unchanged");
+ /* sorry, we have to use TMP_DIR */
+ disable_fast_checkout = 1;
+
(void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
entlist = cvs_ent_open(server_currentdir);
@@ -460,6 +468,8 @@ cvs_server_unchanged(char *data)
void
cvs_server_questionable(char *data)
{
+ /* sorry, we have to use TMP_DIR */
+ disable_fast_checkout = 1;
}
void
@@ -619,7 +629,7 @@ cvs_server_export(char *data)
cvs_cmdop = CVS_OP_EXPORT;
cmdp->cmd_flags = cvs_cmd_export.cmd_flags;
- cvs_checkout(server_argc, server_argv);
+ cvs_export(server_argc, server_argv);
cvs_server_send_response("ok");
}
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 9f6b3f3caf4..fe21ebe49a1 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.150 2008/06/11 19:10:02 joris Exp $ */
+/* $OpenBSD: update.c,v 1.151 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -252,7 +252,8 @@ cvs_update_leavedir(struct cvs_file *cf)
bufsize = st.st_blksize;
if (st.st_size > SIZE_MAX)
- fatal("cvs_update_leavedir: %s: file size too big", cf->file_name);
+ fatal("cvs_update_leavedir: %s: file size too big",
+ cf->file_name);
isempty = 1;
buf = xmalloc(bufsize);
@@ -295,8 +296,8 @@ cvs_update_leavedir(struct cvs_file *cf)
xfree(buf);
- if ((isempty == 1 && prune_dirs == 1) || (cvs_server_active == 1 &&
- cvs_cmdop == CVS_OP_CHECKOUT)) {
+ if ((isempty == 1 && prune_dirs == 1) ||
+ (cvs_server_active == 1 && cvs_cmdop == CVS_OP_CHECKOUT)) {
/* XXX */
cvs_rmdir(cf->file_path);
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index b4d53024732..8b158889be0 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.144 2008/06/10 01:00:35 joris Exp $ */
+/* $OpenBSD: util.c,v 1.145 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -44,6 +44,7 @@
extern int print_stdout;
extern int build_dirs;
+extern int disable_fast_checkout;
/* letter -> mode type map */
static const int cvs_modetypes[26] = {
@@ -364,7 +365,7 @@ cvs_unlink(const char *path)
if (cvs_server_active == 0)
cvs_log(LP_TRACE, "cvs_unlink(%s)", path);
- if (cvs_noexec == 1)
+ if (cvs_noexec == 1 && disable_fast_checkout != 0)
return (0);
if (unlink(path) == -1 && errno != ENOENT) {
@@ -393,7 +394,7 @@ cvs_rmdir(const char *path)
if (cvs_server_active == 0)
cvs_log(LP_TRACE, "cvs_rmdir(%s)", path);
- if (cvs_noexec == 1)
+ if (cvs_noexec == 1 && disable_fast_checkout != 0)
return (0);
if ((dirp = opendir(path)) == NULL) {
@@ -857,7 +858,7 @@ cvs_yesno(void)
* else, 0 or -1 if an error occur.
*/
int
-cvs_exec(const char *prog, const char *in, int needwait)
+cvs_exec(char *prog, const char *in, int needwait)
{
pid_t pid;
int fds[2], size, st;
diff --git a/usr.bin/cvs/util.h b/usr.bin/cvs/util.h
index fa8d32afd34..867f5f98177 100644
--- a/usr.bin/cvs/util.h
+++ b/usr.bin/cvs/util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.25 2008/06/10 01:00:35 joris Exp $ */
+/* $OpenBSD: util.h,v 1.26 2008/06/12 07:16:14 joris Exp $ */
/*
* Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -41,7 +41,7 @@ int cvs_unlink(const char *);
int cvs_rmdir(const char *);
char **cvs_makeargv(const char *, int *);
void cvs_freeargv(char **, int);
-int cvs_exec(const char *, const char *, int);
+int cvs_exec(char *, const char *, int);
u_int cvs_revision_select(RCSFILE *, char *);
struct cvs_line {