diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2007-01-17 17:54:51 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2007-01-17 17:54:51 +0000 |
commit | 85fc4ab54949af79c8a6a9a5053de81499f6116a (patch) | |
tree | c1fe17e97e9da284c6c3c3961f56d14f4eba94b2 /usr.bin | |
parent | 2859e665e7d21c18819d9bbb86fbb84215aa09a2 (diff) |
add support for remote checkout in both our client and server,
with this the last real dependency to actually be able to use opencvs
in a remote setup has been added.
based upon an initial diff from xsa@
'kay niallo@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/checkout.c | 30 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 6 | ||||
-rw-r--r-- | usr.bin/cvs/cvs.h | 3 | ||||
-rw-r--r-- | usr.bin/cvs/remote.h | 3 | ||||
-rw-r--r-- | usr.bin/cvs/server.c | 42 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 7 | ||||
-rw-r--r-- | usr.bin/cvs/util.c | 11 |
7 files changed, 84 insertions, 18 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 878a4e309af..ccc6764f6da 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.78 2007/01/16 08:33:46 xsa Exp $ */ +/* $OpenBSD: checkout.c,v 1.79 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -125,6 +125,34 @@ checkout_check_repository(int argc, char **argv) int i; char repo[MAXPATHLEN]; struct stat st; + struct cvs_recursion cr; + + if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) { + cvs_client_connect_to_server(); + + if (reset_stickies == 1) + cvs_client_send_request("Argument -A"); + + if (cvs_cmdop == CVS_OP_CHECKOUT && prune_dirs == 1) + cvs_client_send_request("Argument -P"); + + cr.enterdir = NULL; + cr.leavedir = NULL; + cr.fileproc = cvs_client_sendfile; + cr.flags = flags; + + cvs_file_run(argc, argv, &cr); + + cvs_client_send_files(argv, argc); + cvs_client_senddir("."); + + cvs_client_send_request("%s", + (cvs_cmdop == CVS_OP_CHECKOUT) ? "co" : "export"); + + cvs_client_get_responses(); + + return; + } for (i = 0; i < argc; i++) { cvs_mkpath(argv[i]); diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index c4cb8ebc602..28df816f35b 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.47 2007/01/16 09:14:19 xsa Exp $ */ +/* $OpenBSD: client.c,v 1.48 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -61,7 +61,7 @@ struct cvs_req cvs_requests[] = { /* commands that might be supported */ { "ci", 0, cvs_server_commit, 0 }, - { "co", 0, NULL, 0 }, + { "co", 0, cvs_server_checkout, 0 }, { "update", 0, cvs_server_update, 0 }, { "diff", 0, cvs_server_diff, 0 }, { "log", 0, cvs_server_log, 0 }, @@ -632,6 +632,8 @@ cvs_client_updated(char *data) repo = xmalloc(MAXPATHLEN); cvs_get_repository_path(".", repo, MAXPATHLEN); + STRIP_SLASH(repo); + if (strlen(repo) + 1 > strlen(rpath)) fatal("received a repository path that is too short"); diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index f7fc2dbf416..d7c0c0f0c4d 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.129 2007/01/13 15:45:59 joris Exp $ */ +/* $OpenBSD: cvs.h,v 1.130 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -374,6 +374,7 @@ int cvs_add(int, char **); int cvs_admin(int, char **); int cvs_annotate(int, char **); int cvs_commit(int, char **); +int cvs_checkout(int, char **); int cvs_diff(int, char **); int cvs_edit(int, char **); int cvs_editors(int, char **); diff --git a/usr.bin/cvs/remote.h b/usr.bin/cvs/remote.h index ea8dd061118..f7a55e032f6 100644 --- a/usr.bin/cvs/remote.h +++ b/usr.bin/cvs/remote.h @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.h,v 1.18 2007/01/13 15:29:34 joris Exp $ */ +/* $OpenBSD: remote.h,v 1.19 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -90,6 +90,7 @@ void cvs_server_add(char *); void cvs_server_admin(char *); void cvs_server_annotate(char *); void cvs_server_commit(char *); +void cvs_server_checkout(char *); void cvs_server_diff(char *); void cvs_server_init(char *); void cvs_server_log(char *); diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index a8a8309cdd9..c27ebd77527 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.48 2007/01/13 15:29:34 joris Exp $ */ +/* $OpenBSD: server.c,v 1.49 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -299,19 +299,34 @@ cvs_server_directory(char *data) { int l; CVSENTRIES *entlist; - char *dir, *repo, *parent, *entry, *dirn; + char *dir, *repo, *parent, *entry, *dirn, *p; dir = cvs_remote_input(); - if (strlen(dir) < strlen(current_cvsroot->cr_dir) + 1) + STRIP_SLASH(dir); + + if (strlen(dir) < strlen(current_cvsroot->cr_dir)) fatal("cvs_server_directory: bad Directory request"); - repo = dir + strlen(current_cvsroot->cr_dir) + 1; - cvs_mkpath(repo); + repo = dir + strlen(current_cvsroot->cr_dir); + + /* + * This is somewhat required for checkout, as the + * directory request will be: + * + * Directory . + * /path/to/cvs/root + */ + if (repo[0] == '\0') + p = xstrdup("."); + else + p = xstrdup(repo + 1); + + cvs_mkpath(p); - if ((dirn = basename(repo)) == NULL) + if ((dirn = basename(p)) == NULL) fatal("cvs_server_directory: %s", strerror(errno)); - if ((parent = dirname(repo)) == NULL) + if ((parent = dirname(p)) == NULL) fatal("cvs_server_directory: %s", strerror(errno)); if (strcmp(parent, ".")) { @@ -328,8 +343,9 @@ cvs_server_directory(char *data) if (server_currentdir != NULL) xfree(server_currentdir); - server_currentdir = xstrdup(repo); + server_currentdir = xstrdup(p); + xfree(p); xfree(dir); } @@ -499,6 +515,16 @@ cvs_server_commit(char *data) } void +cvs_server_checkout(char *data) +{ if (chdir(server_currentdir) == -1) + fatal("cvs_server_checkout: %s", strerror(errno)); + + cvs_cmdop = CVS_OP_CHECKOUT; + cvs_checkout(server_argc, server_argv); + cvs_server_send_response("ok"); +} + +void cvs_server_diff(char *data) { if (chdir(server_currentdir) == -1) diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 29f3d589405..e84aebfa696 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.85 2007/01/13 15:45:59 joris Exp $ */ +/* $OpenBSD: update.c,v 1.86 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -185,6 +185,11 @@ cvs_update_leavedir(struct cvs_file *cf) cvs_log(LP_TRACE, "cvs_update_leavedir(%s)", cf->file_path); + if (cvs_server_active == 1) { + cvs_rmdir(cf->file_path); + return; + } + if (cvs_cmdop == CVS_OP_EXPORT) { export = xmalloc(MAXPATHLEN); if (cvs_path_cat(cf->file_path, CVS_PATH_CVSDIR, export, diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 34e1de8d0ac..6de7a36c86c 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.97 2007/01/11 17:44:18 niallo Exp $ */ +/* $OpenBSD: util.c,v 1.98 2007/01/17 17:54:50 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -611,8 +611,11 @@ cvs_get_repository_name(const char *dir, char *dst, size_t len) } } } else { - if (strlcat(dst, dir, len) >= len) - fatal("cvs_get_repository_name: truncation"); + if (cvs_cmdop != CVS_OP_CHECKOUT) { + if (strlcat(dst, dir, len) >= len) + fatal("cvs_get_repository_name: " + "truncation"); + } } } } @@ -727,7 +730,7 @@ cvs_mkpath(const char *path) if (mkdir(rpath, 0755) == -1 && errno != EEXIST) fatal("cvs_mkpath: %s: %s", rpath, strerror(errno)); - cvs_mkadmin(rpath, current_cvsroot->cr_dir, repo, + cvs_mkadmin(rpath, current_cvsroot->cr_str, repo, NULL, NULL, 0); } |