version 1.36, 2006/01/25 08:15:05 |
version 1.37, 2006/01/27 10:39:49 |
|
|
return (CVS_EX_USAGE); |
return (CVS_EX_USAGE); |
|
|
if ((imp_brnum == NULL) && |
if ((imp_brnum == NULL) && |
((imp_brnum = rcsnum_parse(CVS_IMPORT_DEFBRANCH)) == NULL)) { |
((imp_brnum = rcsnum_parse(CVS_IMPORT_DEFBRANCH)) == NULL)) |
cvs_log(LP_ERR, "failed to parse default import branch"); |
fatal("cvs_import_init: rcsnum_parse failed"); |
return (CVS_EX_DATA); |
|
} |
|
|
|
module = argv[0]; |
module = argv[0]; |
vendor = argv[1]; |
vendor = argv[1]; |
|
|
static int |
static int |
cvs_import_pre_exec(struct cvsroot *root) |
cvs_import_pre_exec(struct cvsroot *root) |
{ |
{ |
size_t len; |
|
char numbuf[64], repodir[MAXPATHLEN]; |
char numbuf[64], repodir[MAXPATHLEN]; |
|
|
if (root->cr_method == CVS_METHOD_LOCAL) { |
if (root->cr_method == CVS_METHOD_LOCAL) { |
len = cvs_path_cat(root->cr_dir, module, repodir, |
if (cvs_path_cat(root->cr_dir, module, repodir, |
sizeof(repodir)); |
sizeof(repodir)) >= sizeof(repodir)) |
if (len >= sizeof(repodir)) |
fatal("cvs_import_pre_exec: cvs_path_cat overflow"); |
return (CVS_EX_DATA); |
|
|
|
if (mkdir(repodir, 0700) == -1) { |
if (mkdir(repodir, 0700) == -1) |
cvs_log(LP_ERRNO, "failed to create %s", repodir); |
fatal("cvs_import_pre_exec: mkdir `%s': %s", |
return (CVS_EX_DATA); |
repodir, strerror(errno)); |
} |
|
} else { |
} else { |
rcsnum_tostr(imp_brnum, numbuf, sizeof(numbuf)); |
rcsnum_tostr(imp_brnum, numbuf, sizeof(numbuf)); |
|
|
|
|
static int |
static int |
cvs_import_remote(CVSFILE *cf, void *arg) |
cvs_import_remote(CVSFILE *cf, void *arg) |
{ |
{ |
size_t len, sz; |
size_t sz; |
struct cvsroot *root; |
struct cvsroot *root; |
char fpath[MAXPATHLEN], repodir[MAXPATHLEN]; |
char fpath[MAXPATHLEN], repodir[MAXPATHLEN]; |
char repo[MAXPATHLEN], date[32]; |
char repo[MAXPATHLEN], date[32]; |
|
|
root = CVS_DIR_ROOT(cf); |
root = CVS_DIR_ROOT(cf); |
|
|
len = cvs_path_cat(root->cr_dir, module, repo, sizeof(repo)); |
if (cvs_path_cat(root->cr_dir, module, repo, sizeof(repo)) >= |
if (len >= sizeof(repo)) |
sizeof(repo)) |
return (CVS_EX_DATA); |
fatal("cvs_import_remove: cvs_path_cat overflow"); |
|
|
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
|
|
|
|
if (!strcmp(cf->cf_name, ".")) |
if (!strcmp(cf->cf_name, ".")) |
strlcpy(repodir, repo, sizeof(repodir)); |
strlcpy(repodir, repo, sizeof(repodir)); |
else { |
else { |
len = cvs_path_cat(repo, fpath, repodir, |
if(cvs_path_cat(repo, fpath, repodir, |
sizeof(repodir)); |
sizeof(repodir)) >= sizeof(repodir)) |
if (len >= sizeof(repodir)) |
fatal("cvs_import_remove: cvs_path_cat overflow"); |
return (CVS_EX_DATA); |
|
} |
} |
|
|
cvs_sendreq(root, CVS_REQ_DIRECTORY, fpath); |
cvs_sendreq(root, CVS_REQ_DIRECTORY, fpath); |
|
|
static int |
static int |
cvs_import_local(CVSFILE *cf, void *arg) |
cvs_import_local(CVSFILE *cf, void *arg) |
{ |
{ |
size_t len; |
|
time_t stamp; |
time_t stamp; |
char *fcont; |
char *fcont; |
char fpath[MAXPATHLEN], rpath[MAXPATHLEN], repo[MAXPATHLEN]; |
char fpath[MAXPATHLEN], rpath[MAXPATHLEN], repo[MAXPATHLEN]; |
|
|
|
|
root = CVS_DIR_ROOT(cf); |
root = CVS_DIR_ROOT(cf); |
|
|
len = cvs_path_cat(root->cr_dir, module, repo, sizeof(repo)); |
if (cvs_path_cat(root->cr_dir, module, repo, sizeof(repo)) >= |
if (len >= sizeof(repo)) |
sizeof(repo)) |
return (CVS_EX_DATA); |
fatal("cvs_import_local: cvs_path_cat overflow"); |
|
|
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
|
|
|
|
if (!strcmp(cf->cf_name, ".")) |
if (!strcmp(cf->cf_name, ".")) |
strlcpy(rpath, repo, sizeof(rpath)); |
strlcpy(rpath, repo, sizeof(rpath)); |
else { |
else { |
len = cvs_path_cat(repo, fpath, rpath, sizeof(rpath)); |
if (cvs_path_cat(repo, fpath, rpath, |
if (len >= sizeof(rpath)) |
sizeof(rpath)) >= sizeof(rpath)) |
return (CVS_EX_DATA); |
fatal("cvs_import_local: cvs_path_cat overflow"); |
|
|
cvs_printf("Importing %s\n", rpath); |
cvs_printf("Importing %s\n", rpath); |
if (mkdir(rpath, 0700) == -1) { |
if (mkdir(rpath, 0700) == -1) { |
|
|
* timestamps for the initial revisions. |
* timestamps for the initial revisions. |
*/ |
*/ |
if (dflag == 1) { |
if (dflag == 1) { |
if (stat(fpath, &fst) == -1) { |
if (stat(fpath, &fst) == -1) |
cvs_log(LP_ERRNO, "failed to stat `%s'", fpath); |
fatal("cvs_import_local: stat failed on `%s': %s", |
return (CVS_EX_DATA); |
fpath, strerror(errno)); |
} |
|
stamp = (time_t)fst.st_mtime; |
stamp = (time_t)fst.st_mtime; |
|
|
ts[0].tv_sec = stamp; |
ts[0].tv_sec = stamp; |
|
|
|
|
cvs_printf("N %s\n", fpath); |
cvs_printf("N %s\n", fpath); |
|
|
rf = rcs_open(rpath, RCS_RDWR|RCS_CREATE); |
if ((rf = rcs_open(rpath, RCS_RDWR|RCS_CREATE)) == NULL); |
if (rf == NULL) { |
fatal("cvs_import_local: rcs_open: `%s': %s", rpath, |
cvs_log(LP_ERR, "failed to create RCS file: %s", |
|
strerror(rcs_errno)); |
strerror(rcs_errno)); |
return (CVS_EX_DATA); |
|
} |
|
|
|
comment = rcs_comment_lookup(cf->cf_name); |
comment = rcs_comment_lookup(cf->cf_name); |
if ((comment != NULL) && (rcs_comment_set(rf, comment) < 0)) { |
if ((comment != NULL) && (rcs_comment_set(rf, comment) < 0)) { |
|
|
|
|
rev = rcsnum_brtorev(imp_brnum); |
rev = rcsnum_brtorev(imp_brnum); |
if (rcs_rev_add(rf, rev, cvs_msg, stamp, NULL) < 0) { |
if (rcs_rev_add(rf, rev, cvs_msg, stamp, NULL) < 0) { |
cvs_log(LP_ERR, "failed to add revision: %s", |
|
rcs_errstr(rcs_errno)); |
|
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: rcs_rev_add failed: %s", |
|
rcs_errstr(rcs_errno)); |
} |
} |
|
|
if (rcs_sym_add(rf, release, rev) < 0) { |
if (rcs_sym_add(rf, release, rev) < 0) { |
cvs_log(LP_ERR, "failed to set RCS symbol: %s", |
|
strerror(rcs_errno)); |
|
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: rcs_sym_add failed: %s", |
|
strerror(rcs_errno)); |
} |
} |
|
|
rcsnum_cpy(imp_brnum, rev, 2); |
rcsnum_cpy(imp_brnum, rev, 2); |
if (rcs_rev_add(rf, rev, cvs_msg, stamp, NULL) < 0) { |
if (rcs_rev_add(rf, rev, cvs_msg, stamp, NULL) < 0) { |
cvs_log(LP_ERR, "failed to add revision: %s", |
|
rcs_errstr(rcs_errno)); |
|
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: rcs_rev_add failed: %s", |
|
rcs_errstr(rcs_errno)); |
} |
} |
|
|
if (rcs_head_set(rf, rev) < 0) { |
if (rcs_head_set(rf, rev) < 0) { |
cvs_log(LP_ERR, "failed to set RCS head: %s", |
|
rcs_errstr(rcs_errno)); |
|
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: rcs_head_set failed: %s", |
|
rcs_errstr(rcs_errno)); |
} |
} |
|
|
if (rcs_branch_set(rf, imp_brnum) < 0) { |
if (rcs_branch_set(rf, imp_brnum) < 0) { |
cvs_log(LP_ERR, "failed to set RCS default branch: %s", |
(void)unlink(rpath); |
|
fatal("cvs_import_local: rcs_branch_set failed: %s", |
strerror(rcs_errno)); |
strerror(rcs_errno)); |
return (CVS_EX_DATA); |
|
} |
} |
|
|
if (rcs_sym_add(rf, vendor, imp_brnum) < 0) { |
if (rcs_sym_add(rf, vendor, imp_brnum) < 0) { |
cvs_log(LP_ERR, "failed to set RCS symbol: %s", |
|
strerror(rcs_errno)); |
|
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: rcs_sym_add failed: %s", |
|
strerror(rcs_errno)); |
} |
} |
|
|
if ((bp = cvs_buf_load(fpath, BUF_AUTOEXT)) == NULL) { |
if ((bp = cvs_buf_load(fpath, BUF_AUTOEXT)) == NULL) { |
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: cvs_buf_load failed"); |
} |
} |
|
|
cvs_buf_putc(bp, '\0'); |
cvs_buf_putc(bp, '\0'); |
|
|
fcont = cvs_buf_release(bp); |
fcont = cvs_buf_release(bp); |
|
|
if (rcs_deltatext_set(rf, rev, fcont) < 0) { |
if (rcs_deltatext_set(rf, rev, fcont) < 0) { |
rcs_close(rf); |
|
(void)unlink(rpath); |
(void)unlink(rpath); |
return (CVS_EX_DATA); |
fatal("cvs_import_local: rcs_deltatext_set failed"); |
} |
} |
|
|
/* add the vendor tag and release tag as symbols */ |
/* add the vendor tag and release tag as symbols */ |
|
|
if ((dflag ==1) && (utimes(rpath, ts) == -1)) |
if ((dflag ==1) && (utimes(rpath, ts) == -1)) |
cvs_log(LP_ERRNO, "failed to timestamp RCS file"); |
cvs_log(LP_ERRNO, "failed to timestamp RCS file"); |
|
|
return (CVS_EX_OK); |
return (0); |
} |
} |
|
|
static int |
static int |