diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2007-06-26 02:24:11 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2007-06-26 02:24:11 +0000 |
commit | 8e3a32db4fa8741f995a50b23c486c77549b0c22 (patch) | |
tree | fcf1b9dbed2b0c52204d55805bb20988ba5f08d4 /usr.bin | |
parent | 1a568e125cc00b7e8a18b68fd8716f970316ba56 (diff) |
add support for cvs rlog.
from Mickey.
ok joris@ ray@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/client.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/cmd.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 31 | ||||
-rw-r--r-- | usr.bin/cvs/getlog.c | 28 | ||||
-rw-r--r-- | usr.bin/cvs/log.c | 11 | ||||
-rw-r--r-- | usr.bin/cvs/log.h | 8 | ||||
-rw-r--r-- | usr.bin/cvs/remote.h | 3 | ||||
-rw-r--r-- | usr.bin/cvs/server.c | 21 |
8 files changed, 78 insertions, 32 deletions
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 41acdc0fb22..f5267adda4a 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.63 2007/05/26 02:50:46 ray Exp $ */ +/* $OpenBSD: client.c,v 1.64 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -74,7 +74,7 @@ struct cvs_req cvs_requests[] = { { "update", 0, cvs_server_update, 0 }, { "diff", 0, cvs_server_diff, 0 }, { "log", 0, cvs_server_log, 0 }, - { "rlog", 0, NULL, 0 }, + { "rlog", 0, cvs_server_rlog, 0 }, { "add", 0, cvs_server_add, 0 }, { "remove", 0, cvs_server_remove, 0 }, { "update-patches", 0, cvs_server_update_patches, 0 }, diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c index 3ffcd358706..2a4f906c58b 100644 --- a/usr.bin/cvs/cmd.c +++ b/usr.bin/cvs/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.58 2007/06/18 17:54:13 joris Exp $ */ +/* $OpenBSD: cmd.c,v 1.59 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -45,6 +45,7 @@ struct cvs_cmd *cvs_cdt[] = { &cvs_cmd_init, &cvs_cmd_log, &cvs_cmd_remove, + &cvs_cmd_rlog, &cvs_cmd_server, &cvs_cmd_status, &cvs_cmd_tag, @@ -60,7 +61,6 @@ struct cvs_cmd *cvs_cdt[] = { #endif &cvs_cmd_rdiff, &cvs_cmd_release, - &cvs_cmd_rlog, &cvs_cmd_rtag, &cvs_cmd_unedit, &cvs_cmd_update, diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 5e482fc5493..dc349fe22b2 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.191 2007/06/04 21:54:26 niallo Exp $ */ +/* $OpenBSD: file.c,v 1.192 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -338,7 +338,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) struct cvs_ent_line *line; struct cvs_flisthead fl, dl; CVSENTRIES *entlist; - char *buf, *ebuf, *cp, repo[MAXPATHLEN], fpath[MAXPATHLEN]; + char *p, *buf, *ebuf, *cp, repo[MAXPATHLEN], fpath[MAXPATHLEN]; cvs_log(LP_TRACE, "cvs_file_walkdir(%s)", cf->file_path); @@ -359,7 +359,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) CVS_PATH_CVSDIR); l = stat(fpath, &st); - if (cvs_cmdop != CVS_OP_IMPORT && + if (cvs_cmdop != CVS_OP_IMPORT && cvs_cmdop != CVS_OP_RLOG && (l == -1 || (l == 0 && !S_ISDIR(st.st_mode)))) { return; } @@ -414,7 +414,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) continue; } - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + len = xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, dp->d_name); /* @@ -461,17 +461,23 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) continue; } - if (!(cr->flags & CR_RECURSE_DIRS) && - type == CVS_DIR) { - cp += dp->d_reclen; - continue; - } - switch (type) { case CVS_DIR: - cvs_file_get(fpath, &dl); + if (cr->flags & CR_RECURSE_DIRS) + cvs_file_get(fpath, &dl); break; case CVS_FILE: + if ((p = strrchr(cf->file_path, '/')) && + !strcmp(p + 1, CVS_PATH_ATTIC)) { + + *p = '\0'; + len = xsnprintf(fpath, MAXPATHLEN, + "%s/%s", cf->file_path, dp->d_name); + *p = '/'; + } + if (fpath[len - 2] == ',' && + fpath[len - 1] == 'v') + fpath[len - 2] = '\0'; cvs_file_get(fpath, &fl); break; default: @@ -611,7 +617,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) if (cf->file_type == CVS_DIR) { if (cf->fd == -1 && stat(rcsfile, &st) != -1) cf->file_status = DIR_CREATE; - else if (cf->file_ent != NULL) + else if (cf->file_ent != NULL || cvs_cmdop == CVS_OP_RLOG) cf->file_status = FILE_UPTODATE; else cf->file_status = FILE_UNKNOWN; @@ -627,6 +633,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) break; case CVS_OP_IMPORT: case CVS_OP_LOG: + case CVS_OP_RLOG: rflags |= RCS_PARSE_FULLY; break; } diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c index fe2571f1338..b40e34f9155 100644 --- a/usr.bin/cvs/getlog.c +++ b/usr.bin/cvs/getlog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getlog.c,v 1.71 2007/02/22 06:42:09 otto Exp $ */ +/* $OpenBSD: getlog.c,v 1.72 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * Copyright (c) 2006 Joris Vink <joris@openbsd.org> @@ -18,16 +18,11 @@ #include <unistd.h> #include <string.h> +#include <errno.h> #include "cvs.h" #include "remote.h" -#define LOG_REVSEP \ -"----------------------------" - -#define LOG_REVEND \ - "=============================================================================" - #define L_HEAD 0x01 #define L_HEAD_DESCR 0x02 #define L_NAME 0x04 @@ -54,6 +49,16 @@ struct cvs_cmd cvs_cmd_log = { cvs_getlog }; +struct cvs_cmd cvs_cmd_rlog = { + CVS_OP_RLOG, 0, "rlog", + { "rlo" }, + "Print out history information for files", + "[-bhlNRt] [-d dates] [-r revisions] [-s states] [-w logins]", + "bd:hlNRr:s:tw:", + NULL, + cvs_getlog +}; + int cvs_getlog(int argc, char **argv) { @@ -131,6 +136,10 @@ cvs_getlog(int argc, char **argv) if (runflags & L_LOGINS) cvs_client_send_request("Argument -w%s", wlist); } else { + if (cvs_command[0] == 'r' && + chdir(current_cvsroot->cr_dir) == -1) + fatal("cvs_server_log: %s", strerror(errno)); + cr.fileproc = cvs_log_local; } @@ -144,7 +153,10 @@ cvs_getlog(int argc, char **argv) if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) { cvs_client_send_files(argv, argc); cvs_client_senddir("."); - cvs_client_send_request("log"); + if (cvs_command[0] == 'r') + cvs_client_send_request("rlog"); + else + cvs_client_send_request("log"); cvs_client_get_responses(); } diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c index 9f6f12b0829..171155840b7 100644 --- a/usr.bin/cvs/log.c +++ b/usr.bin/cvs/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.39 2007/05/10 20:58:02 xsa Exp $ */ +/* $OpenBSD: log.c,v 1.40 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -137,7 +137,6 @@ cvs_printf(const char *fmt, ...) va_start(vap, fmt); - if (cvs_server_active) { ret = vasprintf(&nstr, fmt, vap); if (ret == -1) fatal("cvs_printf: %s", strerror(errno)); @@ -147,12 +146,16 @@ cvs_printf(const char *fmt, ...) for (sp = dp; *sp != '\0'; sp++) ; - if (send_m) { + if (cvs_server_active && send_m) { send_m = 0; putc('M', stdout); putc(' ', stdout); } + if (dp != nstr && dp != sp && + !strncmp(dp, LOG_REVSEP, sp - dp)) + putc('>', stdout); + fwrite(dp, sizeof(char), (size_t)(sp - dp), stdout); if (*sp != '\n') @@ -163,8 +166,6 @@ cvs_printf(const char *fmt, ...) dp = sp + 1; } xfree(nstr); - } else - ret = vprintf(fmt, vap); va_end(vap); return (ret); diff --git a/usr.bin/cvs/log.h b/usr.bin/cvs/log.h index 7c0f1ee8a80..b6ebfe6789a 100644 --- a/usr.bin/cvs/log.h +++ b/usr.bin/cvs/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.20 2007/02/22 06:42:09 otto Exp $ */ +/* $OpenBSD: log.h,v 1.21 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -36,6 +36,12 @@ #define LP_ABORT 3 #define LP_TRACE 4 +#define LOG_REVSEP \ +"----------------------------" + +#define LOG_REVEND \ + "=============================================================================" + void cvs_log(u_int, const char *, ...) __attribute__((format(printf, 2, 3))); void cvs_vlog(u_int, const char *, va_list); int cvs_printf(const char *, ...) __attribute__((format(printf, 1, 2))); diff --git a/usr.bin/cvs/remote.h b/usr.bin/cvs/remote.h index cf1d0b9f93b..588acd80b66 100644 --- a/usr.bin/cvs/remote.h +++ b/usr.bin/cvs/remote.h @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.h,v 1.20 2007/01/18 16:45:52 joris Exp $ */ +/* $OpenBSD: remote.h,v 1.21 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -95,6 +95,7 @@ void cvs_server_checkout(char *); void cvs_server_diff(char *); void cvs_server_init(char *); void cvs_server_log(char *); +void cvs_server_rlog(char *); void cvs_server_remove(char *); void cvs_server_status(char *); void cvs_server_tag(char *); diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index 13a8f8d6c7c..b0af3d74332 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.61 2007/06/06 00:38:37 ray Exp $ */ +/* $OpenBSD: server.c,v 1.62 2007/06/26 02:24:10 niallo Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -577,6 +577,25 @@ cvs_server_log(char *data) cvs_getlog(server_argc, server_argv); cvs_server_send_response("ok"); } + +void +cvs_server_rlog(char *data) +{ + char fpath[MAXPATHLEN]; + struct cvsroot *cvsroot; + + cvsroot = cvsroot_get(NULL); + + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + cvsroot->cr_dir, server_currentdir); + + if (chdir(fpath) == -1) + fatal("cvs_server_log: %s", strerror(errno)); + + cvs_cmdop = CVS_OP_RLOG; + cvs_getlog(server_argc, server_argv); + cvs_server_send_response("ok"); +} void cvs_server_tag(char *data) |