From f58045fbd8e6599859a773544d3d00818b930c9f Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Tue, 30 May 2006 19:16:52 +0000 Subject: look inside the Attic if a specified RCS file cannot be found in the normal repository, and a way to identify an RCS file in the Attic in the RCSFILE struct. will come in handy later on. --- usr.bin/cvs/file.c | 25 +++++++++++++++++++++---- usr.bin/cvs/rcs.c | 3 ++- usr.bin/cvs/rcs.h | 3 ++- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'usr.bin/cvs') diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 5d889b680ab..01303ce9658 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.151 2006/05/30 07:00:30 joris Exp $ */ +/* $OpenBSD: file.c,v 1.152 2006/05/30 19:16:51 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau @@ -616,10 +616,27 @@ cvs_file_classify(struct cvs_file *cf, int loud) if (cf->repo_fd != -1) { cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd, rflags); if (cf->file_rcs == NULL) - fatal("cvs_file_classify: rcs_open failed while it " - "shouldn't"); + fatal("cvs_file_classify: failed to parse RCS"); + cf->file_rcs->rf_inattic = 0; } else { - cf->file_rcs = NULL; + xfree(cf->file_rpath); + l = snprintf(rcsfile, MAXPATHLEN, "%s/%s/%s%s", + repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); + if (l == -1 || l >= MAXPATHLEN) + fatal("cvs_file_classify: overflow"); + + cf->file_rpath = xstrdup(rcsfile); + + cf->repo_fd = open(cf->file_rpath, O_RDONLY); + if (cf->repo_fd != -1) { + cf->file_rcs = rcs_open(cf->file_rpath, + cf->repo_fd, rflags); + if (cf->file_rcs == NULL) + fatal("cvs_file_classify: failed to parse RCS"); + cf->file_rcs->rf_inattic = 1; + } else { + cf->file_rcs = NULL; + } } if (cf->file_ent != NULL) diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 39663f425b0..7b27255a8a1 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.176 2006/05/29 07:15:52 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.177 2006/05/30 19:16:51 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -265,6 +265,7 @@ rcs_open(const char *path, int fd, int flags, ...) rfp->rf_mode = fmode; rfp->fd = fd; rfp->rf_dead = 0; + rfp->rf_inattic = 0; TAILQ_INIT(&(rfp->rf_delta)); TAILQ_INIT(&(rfp->rf_access)); diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h index f6926a6f2c9..52b379f7b9d 100644 --- a/usr.bin/cvs/rcs.h +++ b/usr.bin/cvs/rcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.h,v 1.65 2006/05/29 07:15:52 joris Exp $ */ +/* $OpenBSD: rcs.h,v 1.66 2006/05/30 19:16:51 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -195,6 +195,7 @@ struct rcs_delta { typedef struct rcs_file { int fd; int rf_dead; + int rf_inattic; char *rf_path; mode_t rf_mode; u_int rf_flags; -- cgit v1.2.3