version 1.57, 2006/05/27 16:10:01 |
version 1.58, 2006/05/28 01:24:28 |
|
|
cvs_file_freelist(&dl); |
cvs_file_freelist(&dl); |
} |
} |
|
|
int |
void |
cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int flags) |
cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, BUF *bp, int flags) |
{ |
{ |
BUF *bp; |
BUF *nbp; |
int l, oflags, exists; |
int l, oflags, exists; |
time_t rcstime; |
time_t rcstime; |
CVSENTRIES *ent; |
CVSENTRIES *ent; |
struct timeval tv[2]; |
struct timeval tv[2]; |
char *entry, rev[16], timebuf[32]; |
char *entry, rev[16], timebuf[64], tbuf[32]; |
|
|
rcsnum_tostr(rnum, rev, sizeof(rev)); |
rcsnum_tostr(rnum, rev, sizeof(rev)); |
|
|
cvs_log(LP_TRACE, "cvs_checkout_file(%s, %s, %d)", |
cvs_log(LP_TRACE, "cvs_checkout_file(%s, %s, %d)", |
cf->file_path, rev, flags); |
cf->file_path, rev, flags); |
|
|
if ((bp = rcs_getrev(cf->file_rcs, rnum)) == NULL) { |
nbp = rcs_kwexp_buf(bp, cf->file_rcs, rnum); |
cvs_log(LP_ERR, "%s: cannot find revision %s", |
|
cf->file_path, rev); |
|
return (0); |
|
} |
|
|
|
bp = rcs_kwexp_buf(bp, cf->file_rcs, rnum); |
|
|
|
oflags = O_WRONLY | O_TRUNC; |
oflags = O_WRONLY | O_TRUNC; |
if (cf->fd != -1) { |
if (cf->fd != -1) { |
exists = 1; |
exists = 1; |
|
|
if (cf->fd == -1) |
if (cf->fd == -1) |
fatal("cvs_checkout_file: open: %s", strerror(errno)); |
fatal("cvs_checkout_file: open: %s", strerror(errno)); |
|
|
if (cvs_buf_write_fd(bp, cf->fd) == -1) |
if (cvs_buf_write_fd(nbp, cf->fd) == -1) |
fatal("cvs_checkout_file: %s", strerror(errno)); |
fatal("cvs_checkout_file: %s", strerror(errno)); |
|
|
cvs_buf_free(bp); |
cvs_buf_free(nbp); |
|
|
if (fchmod(cf->fd, 0644) == -1) |
if (fchmod(cf->fd, 0644) == -1) |
fatal("cvs_checkout_file: fchmod: %s", strerror(errno)); |
fatal("cvs_checkout_file: fchmod: %s", strerror(errno)); |
|
|
if ((rcstime = cvs_hack_time(rcstime, 1)) == 0) |
if ((rcstime = cvs_hack_time(rcstime, 1)) == 0) |
fatal("cvs_checkout_file: to gmt failed"); |
fatal("cvs_checkout_file: to gmt failed"); |
|
|
ctime_r(&rcstime, timebuf); |
ctime_r(&rcstime, tbuf); |
if (timebuf[strlen(timebuf) - 1] == '\n') |
if (tbuf[strlen(tbuf) - 1] == '\n') |
timebuf[strlen(timebuf) - 1] = '\0'; |
tbuf[strlen(tbuf) - 1] = '\0'; |
|
|
|
if (flags & CO_MERGE) { |
|
l = snprintf(timebuf, sizeof(timebuf), "Result of merge+%s", |
|
tbuf); |
|
if (l == -1 || l >= (int)sizeof(timebuf)) |
|
fatal("cvs_checkout_file: overflow"); |
|
} else { |
|
strlcpy(timebuf, tbuf, sizeof(timebuf)); |
|
} |
|
|
entry = xmalloc(CVS_ENT_MAXLINELEN); |
entry = xmalloc(CVS_ENT_MAXLINELEN); |
l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//", cf->file_name, |
l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//", cf->file_name, |
rev, timebuf); |
rev, timebuf); |
|
|
cvs_ent_close(ent, ENT_SYNC); |
cvs_ent_close(ent, ENT_SYNC); |
|
|
xfree(entry); |
xfree(entry); |
|
|
return (1); |
|
} |
} |