version 1.28, 2005/10/15 18:26:24 |
version 1.29, 2005/10/15 19:45:23 |
|
|
#define DATE_MTIME -2 |
#define DATE_MTIME -2 |
|
|
static char * checkin_diff_file(RCSFILE *, RCSNUM *, const char *); |
static char * checkin_diff_file(RCSFILE *, RCSNUM *, const char *); |
static char * checkin_getlogmsg(char *, char *, RCSNUM *, RCSNUM *); |
static char * checkin_getlogmsg(char *, RCSNUM *, RCSNUM *); |
|
|
void |
void |
checkin_usage(void) |
checkin_usage(void) |
{ |
{ |
fprintf(stderr, |
fprintf(stderr, |
"usage: ci [-jMNqV] [-d [date]] [-k mode] [-l [rev]] [-m msg]\n" |
"usage: ci [-jMNqV] [-d[date]] [-f[rev]] [-kmode] [-l[rev]]\n" |
" [-r [rev]] [-u [rev]] file ...\n"); |
" [-mmsg] [-r[rev]] [-u[rev]] file ...\n"); |
} |
} |
|
|
/* |
/* |
|
|
int |
int |
checkin_main(int argc, char **argv) |
checkin_main(int argc, char **argv) |
{ |
{ |
int i, ch, flags, lkmode, interactive, rflag, status; |
int i, ch, flags, force, lkmode, interactive, rflag, status; |
mode_t fmode; |
mode_t fmode; |
time_t date; |
time_t date; |
RCSFILE *file; |
RCSFILE *file; |
|
|
file = NULL; |
file = NULL; |
rcs_msg = NULL; |
rcs_msg = NULL; |
newrev = NULL; |
newrev = NULL; |
fmode = lkmode = verbose = rflag = status = 0; |
fmode = force = lkmode = verbose = rflag = status = 0; |
interactive = 1; |
interactive = 1; |
|
|
if ((username = getlogin()) == NULL) { |
if ((username = getlogin()) == NULL) { |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
while ((ch = rcs_getopt(argc, argv, "j:l::M:N:qu::d::r::m:k:V")) != -1) { |
while ((ch = rcs_getopt(argc, argv, "f::j:l::M:N:qu::d::r::m:k:V")) != -1) { |
switch (ch) { |
switch (ch) { |
case 'd': |
case 'd': |
if (rcs_optarg == NULL) |
if (rcs_optarg == NULL) |
|
|
exit(1); |
exit(1); |
} |
} |
break; |
break; |
|
case 'f': |
|
if (rcs_optarg != NULL) { |
|
if ((newrev = rcsnum_parse(rcs_optarg)) == NULL) { |
|
cvs_log(LP_ERR, "bad revision number"); |
|
exit(1); |
|
} |
|
} |
|
force = 1; |
|
break; |
case 'h': |
case 'h': |
(usage)(); |
(usage)(); |
exit(0); |
exit(0); |
|
|
cvs_log(LP_ERR, "failed to open rcsfile '%s'", fpath); |
cvs_log(LP_ERR, "failed to open rcsfile '%s'", fpath); |
exit(1); |
exit(1); |
} |
} |
|
|
/* |
/* |
* If rev is not specified on the command line, |
* If rev is not specified on the command line, |
* assume HEAD. |
* assume HEAD. |
*/ |
*/ |
frev = file->rf_head; |
frev = file->rf_head; |
|
cvs_printf("%s <-- %s\n", fpath, argv[i]); |
|
|
/* |
/* |
* If revision passed on command line is less than HEAD, bail. |
* If revision passed on command line is less than HEAD, bail. |
*/ |
*/ |
|
|
filec = (char *)cvs_buf_release(bp); |
filec = (char *)cvs_buf_release(bp); |
|
|
/* |
/* |
|
* Get RCS patch |
|
*/ |
|
if ((deltatext = checkin_diff_file(file, frev, argv[i])) == NULL) { |
|
cvs_log(LP_ERR, "failed to get diff"); |
|
exit(1); |
|
} |
|
|
|
/* |
|
* If -f is not specified and there are no differences, tell the |
|
* user and revert to latest version. |
|
*/ |
|
if ((!force) && (strlen(deltatext) < 1)) { |
|
char buf[16]; |
|
rcsnum_tostr(frev, buf, sizeof(buf)); |
|
cvs_log(LP_WARN, |
|
"file is unchanged; reverting to previous revision %s", |
|
buf); |
|
(void)unlink(argv[i]); |
|
if (lkmode != 0) |
|
checkout_rev(file, frev, argv[i], lkmode, username); |
|
rcs_close(file); |
|
cvs_printf("done\n"); |
|
continue; |
|
} |
|
|
|
/* |
* Check for a lock belonging to this user. If none, |
* Check for a lock belonging to this user. If none, |
* abort check-in. |
* abort check-in. |
*/ |
*/ |
|
|
cvs_log(LP_ERR, "%s: no lock set by %s", fpath, |
cvs_log(LP_ERR, "%s: no lock set by %s", fpath, |
username); |
username); |
status = 1; |
status = 1; |
|
rcs_close(file); |
continue; |
continue; |
} else { |
} else { |
TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) { |
TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) { |
|
|
"%s: no lock set by %s", fpath, |
"%s: no lock set by %s", fpath, |
username); |
username); |
status = 1; |
status = 1; |
|
rcs_close(file); |
continue; |
continue; |
} |
} |
} |
} |
|
|
* If no log message specified, get it interactively. |
* If no log message specified, get it interactively. |
*/ |
*/ |
if (rcs_msg == NULL) |
if (rcs_msg == NULL) |
rcs_msg = checkin_getlogmsg(fpath, argv[i], frev, newrev); |
rcs_msg = checkin_getlogmsg(fpath, frev, newrev); |
|
|
/* |
/* |
* Remove the lock |
* Remove the lock |
|
|
} |
} |
|
|
/* |
/* |
* Get RCS patch |
|
*/ |
|
if ((deltatext = checkin_diff_file(file, frev, argv[i])) == NULL) { |
|
cvs_log(LP_ERR, "failed to get diff"); |
|
exit(1); |
|
} |
|
|
|
/* |
|
* Current head revision gets the RCS patch as rd_text |
* Current head revision gets the RCS patch as rd_text |
*/ |
*/ |
if (rcs_deltatext_set(file, frev, deltatext) == -1) { |
if (rcs_deltatext_set(file, frev, deltatext) == -1) { |
|
|
*/ |
*/ |
if (date == DATE_MTIME) { |
if (date == DATE_MTIME) { |
struct stat sb; |
struct stat sb; |
tzset(); |
|
if (stat(argv[i], &sb) != 0) { |
if (stat(argv[i], &sb) != 0) { |
cvs_log(LP_ERRNO, "failed to stat: `%s'", argv[i]); |
cvs_log(LP_ERRNO, "failed to stat: `%s'", argv[i]); |
rcs_close(file); |
rcs_close(file); |
|
|
* Get log message from user interactively. |
* Get log message from user interactively. |
*/ |
*/ |
static char * |
static char * |
checkin_getlogmsg(char *rcsfile, char *workingfile, RCSNUM *rev, RCSNUM *rev2) |
checkin_getlogmsg(char *rcsfile, RCSNUM *rev, RCSNUM *rev2) |
{ |
{ |
char *rcs_msg, buf[128], nrev[16], prev[16]; |
char *rcs_msg, buf[128], nrev[16], prev[16]; |
BUF *logbuf; |
BUF *logbuf; |
|
|
cvs_log(LP_ERR, "failed to allocate log buffer"); |
cvs_log(LP_ERR, "failed to allocate log buffer"); |
return (NULL); |
return (NULL); |
} |
} |
cvs_printf("%s <-- %s\n", rcsfile, workingfile); |
|
cvs_printf("new revision: %s; previous revision: %s\n", nrev, prev); |
cvs_printf("new revision: %s; previous revision: %s\n", nrev, prev); |
cvs_printf("enter log message, terminated with single " |
cvs_printf("enter log message, terminated with single " |
"'.' or end of file:\n"); |
"'.' or end of file:\n"); |