diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-21 16:36:47 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-21 16:36:47 +0000 |
commit | 15898420b698ef6903c46af4084c532aeb09cc81 (patch) | |
tree | 1cb38fa4340dee984513f42b3b6233b86260c637 /usr.bin | |
parent | 0e676bb7aa999a2d725c7a7655fe84ee5e6e77f2 (diff) |
Fixed export to be fully functional and compliant to GNU cvs in local and
remote setups.
OK xsa@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/checkout.c | 10 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 41 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 8 | ||||
-rw-r--r-- | usr.bin/cvs/remote.h | 3 | ||||
-rw-r--r-- | usr.bin/cvs/server.c | 12 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 34 | ||||
-rw-r--r-- | usr.bin/cvs/util.c | 8 |
7 files changed, 67 insertions, 49 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index c2e892680f5..ba32136cc61 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.107 2008/01/10 10:08:22 tobias Exp $ */ +/* $OpenBSD: checkout.c,v 1.108 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -127,6 +127,9 @@ cvs_export(int argc, char **argv) argc -= optind; argv += optind; + if (cvs_specified_tag == NULL) + fatal("must specify a tag or date"); + if (argc == 0) fatal("%s", cvs_cmd_export.cmd_synopsis); @@ -173,7 +176,8 @@ checkout_check_repository(int argc, char **argv) flags &= ~CR_REPO; cr.flags = flags; - cvs_file_run(argc, argv, &cr); + if (cvs_cmdop != CVS_OP_EXPORT) + cvs_file_run(argc, argv, &cr); cvs_client_send_files(argv, argc); cvs_client_senddir("."); @@ -349,7 +353,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) cf->file_name, rev, timebuf, kbuf, stickytag); if (cvs_server_active == 0) { - if (!(co_flags & CO_REMOVE)) { + 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); diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 75f45b7066f..484bd8b9f8f 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.89 2008/01/10 11:20:29 tobias Exp $ */ +/* $OpenBSD: client.c,v 1.90 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -96,7 +96,8 @@ struct cvs_req cvs_requests[] = { { "import", 0, cvs_server_import, REQ_NEEDDIR }, { "admin", 0, cvs_server_admin, REQ_NEEDDIR }, - { "export", 0, NULL, 0 }, + { "export", 0, cvs_server_export, + REQ_NEEDDIR }, { "history", 0, NULL, 0 }, { "release", 0, cvs_server_release, REQ_NEEDDIR }, @@ -169,6 +170,9 @@ client_check_directory(char *data) cvs_mkpath(data, NULL); + if (cvs_cmdop == CVS_OP_EXPORT) + return; + if ((base = basename(data)) == NULL) fatal("client_check_directory: overflow"); @@ -714,9 +718,12 @@ cvs_client_updated(char *data) e->ce_opts ? e->ce_opts : "", sticky); cvs_ent_free(e); - ent = cvs_ent_open(wdir); - cvs_ent_add(ent, entry); - cvs_ent_close(ent, ENT_SYNC); + + if (cvs_cmdop != CVS_OP_EXPORT) { + ent = cvs_ent_open(wdir); + cvs_ent_add(ent, entry); + cvs_ent_close(ent, ENT_SYNC); + } if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1) fatal("cvs_client_updated: open: %s: %s", @@ -864,9 +871,6 @@ cvs_client_set_static_directory(char *data) FILE *fp; char *dir, fpath[MAXPATHLEN]; - if (cvs_cmdop == CVS_OP_EXPORT) - return; - if (data == NULL) fatal("Missing argument for Set-static-directory"); @@ -875,6 +879,9 @@ cvs_client_set_static_directory(char *data) dir = cvs_remote_input(); xfree(dir); + if (cvs_cmdop == CVS_OP_EXPORT) + return; + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_STATICENTRIES); @@ -890,9 +897,6 @@ cvs_client_clear_static_directory(char *data) { char *dir, fpath[MAXPATHLEN]; - if (cvs_cmdop == CVS_OP_EXPORT) - return; - if (data == NULL) fatal("Missing argument for Clear-static-directory"); @@ -901,6 +905,9 @@ cvs_client_clear_static_directory(char *data) dir = cvs_remote_input(); xfree(dir); + if (cvs_cmdop == CVS_OP_EXPORT) + return; + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_STATICENTRIES); @@ -913,9 +920,6 @@ cvs_client_set_sticky(char *data) FILE *fp; char *dir, *tag, tagpath[MAXPATHLEN]; - if (cvs_cmdop == CVS_OP_EXPORT) - return; - if (data == NULL) fatal("Missing argument for Set-sticky"); @@ -925,6 +929,9 @@ cvs_client_set_sticky(char *data) xfree(dir); tag = cvs_remote_input(); + if (cvs_cmdop == CVS_OP_EXPORT) + goto out; + client_check_directory(data); (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_TAG); @@ -945,9 +952,6 @@ cvs_client_clear_sticky(char *data) { char *dir, tagpath[MAXPATHLEN]; - if (cvs_cmdop == CVS_OP_EXPORT) - return; - if (data == NULL) fatal("Missing argument for Clear-sticky"); @@ -956,6 +960,9 @@ cvs_client_clear_sticky(char *data) dir = cvs_remote_input(); xfree(dir); + if (cvs_cmdop == CVS_OP_EXPORT) + return; + client_check_directory(data); (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_TAG); diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 749c33ca662..20ad6350a08 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.209 2008/01/10 11:21:34 tobias Exp $ */ +/* $OpenBSD: file.c,v 1.210 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -371,14 +371,14 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) /* * If we do not have a admin directory inside here, dont bother, - * unless we are running import. + * unless we are running export, import, rlog or rtag. */ (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); l = stat(fpath, &st); - if (cvs_cmdop != CVS_OP_IMPORT && cvs_cmdop != CVS_OP_RLOG && - cvs_cmdop != CVS_OP_RTAG && + if (cvs_cmdop != CVS_OP_EXPORT && cvs_cmdop != CVS_OP_IMPORT && + cvs_cmdop != CVS_OP_RLOG && cvs_cmdop != CVS_OP_RTAG && (l == -1 || (l == 0 && !S_ISDIR(st.st_mode)))) { return; } diff --git a/usr.bin/cvs/remote.h b/usr.bin/cvs/remote.h index 100061f9204..f351e151a94 100644 --- a/usr.bin/cvs/remote.h +++ b/usr.bin/cvs/remote.h @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.h,v 1.27 2008/01/10 11:20:29 tobias Exp $ */ +/* $OpenBSD: remote.h,v 1.28 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -101,6 +101,7 @@ void cvs_server_annotate(char *); void cvs_server_commit(char *); void cvs_server_checkout(char *); void cvs_server_diff(char *); +void cvs_server_export(char *); void cvs_server_init(char *); void cvs_server_log(char *); void cvs_server_release(char *); diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index 13278dffcbe..2264a86d120 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.75 2008/01/10 11:20:29 tobias Exp $ */ +/* $OpenBSD: server.c,v 1.76 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -574,6 +574,16 @@ cvs_server_diff(char *data) } void +cvs_server_export(char *data) +{ if (chdir(server_currentdir) == -1) + fatal("cvs_server_checkout: %s", strerror(errno)); + + cvs_cmdop = CVS_OP_EXPORT; + cvs_checkout(server_argc, server_argv); + cvs_server_send_response("ok"); +} + +void cvs_server_init(char *data) { if (data == NULL) diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index caa1f569459..7c58b93ac60 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.113 2008/01/10 10:08:22 tobias Exp $ */ +/* $OpenBSD: update.c,v 1.114 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -163,12 +163,14 @@ cvs_update_enterdir(struct cvs_file *cf) fatal("cvs_update_enterdir: `%s': %s", cf->file_path, strerror(errno)); - (void)xasprintf(&entry, "D/%s////", cf->file_name); + if (cvs_cmdop != CVS_OP_EXPORT) { + (void)xasprintf(&entry, "D/%s////", cf->file_name); - entlist = cvs_ent_open(cf->file_wd); - cvs_ent_add(entlist, entry); - cvs_ent_close(entlist, ENT_SYNC); - xfree(entry); + 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) || cf->file_status == FILE_UNKNOWN) { cf->file_status = FILE_SKIP; @@ -196,22 +198,9 @@ cvs_update_leavedir(struct cvs_file *cf) struct cvs_ent *ent; struct cvs_ent_line *line; CVSENTRIES *entlist; - char export[MAXPATHLEN]; cvs_log(LP_TRACE, "cvs_update_leavedir(%s)", cf->file_path); - if (cvs_cmdop == CVS_OP_EXPORT) { - (void)xsnprintf(export, MAXPATHLEN, "%s/%s", - cf->file_path, CVS_PATH_CVSDIR); - - /* XXX */ - if (cvs_rmdir(export) == -1) - fatal("cvs_update_leavedir: %s: %s:", export, - strerror(errno)); - - return; - } - if (cvs_server_active == 1 && !strcmp(cf->file_name, ".")) return; @@ -276,7 +265,7 @@ cvs_update_leavedir(struct cvs_file *cf) /* XXX */ cvs_rmdir(cf->file_path); - if (cvs_server_active == 0) { + 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); @@ -295,8 +284,11 @@ cvs_update_local(struct cvs_file *cf) cvs_log(LP_TRACE, "cvs_update_local(%s)", cf->file_path); if (cf->file_type == CVS_DIR) { - if (cf->file_status == FILE_SKIP) + if (cf->file_status == FILE_SKIP) { + if (cvs_cmdop == CVS_OP_EXPORT && verbosity > 0) + cvs_printf("? %s\n", cf->file_path); return; + } if (cf->file_status != FILE_UNKNOWN && verbosity > 1) diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index fbf95c8b91e..e5d76a25b2f 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.124 2008/01/10 10:09:27 tobias Exp $ */ +/* $OpenBSD: util.c,v 1.125 2008/01/21 16:36:46 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -505,7 +505,8 @@ cvs_get_repository_name(const char *dir, char *dst, size_t len) } } } else { - if (cvs_cmdop != CVS_OP_CHECKOUT) { + if ((cvs_cmdop == CVS_OP_EXPORT && strcmp(dir, ".")) || + cvs_cmdop != CVS_OP_CHECKOUT) { if (strlcat(dst, dir, len) >= len) fatal("cvs_get_repository_name: " "truncation"); @@ -616,6 +617,9 @@ cvs_mkpath(const char *path, char *tag) if (mkdir(rpath, 0755) == -1 && errno != EEXIST) fatal("cvs_mkpath: %s: %s", rpath, strerror(errno)); + if (cvs_cmdop == CVS_OP_EXPORT && !cvs_server_active) + continue; + cvs_mkadmin(rpath, current_cvsroot->cr_str, repo, tag, NULL, 0); |