#include "cvs.h"
#include "fileattr.h"
#include "edit.h"
int
Checkin (int type, struct file_info *finfo, char *rev, char *tag,
char *options, char *message)
{
Vers_TS *vers;
int set_time;
char *tocvsPath = NULL;
tocvsPath = wrap_tocvs_process_file (finfo->file);
if (!noexec)
{
if (tocvsPath)
{
if (unlink_file_dir (finfo->file) < 0)
if (! existence_error (errno))
error (1, errno, "cannot remove %s", finfo->fullname);
rename_file (tocvsPath, finfo->file);
}
}
assert (finfo->rcs != NULL);
switch (RCS_checkin (finfo->rcs, finfo->update_dir, finfo->file, message,
rev, 0, RCS_FLAGS_KEEPFILE))
{
case 0:
if (strcmp (options, "-V4") == 0)
options[0] = '\0';
if ((1
#ifdef PRESERVE_PERMISSIONS_SUPPORT
!config->preserve_perms
#endif
&& options
&& (!strcmp (options, "-ko") || !strcmp (options, "-kb")))
|| !RCS_cmp_file (finfo->rcs, rev, NULL, NULL,
options, finfo->file))
{
set_time = 0;
}
else
{
if (RCS_checkout (finfo->rcs, finfo->file, rev, NULL,
options, RUN_TTY, NULL, NULL) != 0)
error (1, 0, "failed when checking out new copy of %s",
finfo->fullname);
xchmod (finfo->file, 1);
set_time = 1;
}
wrap_fromcvs_process_file (finfo->file);
if (!cvswrite || fileattr_get (finfo->file, "_watched"))
xchmod (finfo->file, 0);
vers = Version_TS (finfo, NULL, tag, NULL, 1, set_time);
if (strcmp (vers->options, "-V4") == 0)
vers->options[0] = '\0';
Register (finfo->entries, finfo->file, vers->vn_rcs, vers->ts_user,
vers->options, vers->tag, vers->date, NULL);
history_write (type, NULL, vers->vn_rcs,
finfo->file, finfo->repository);
if (tocvsPath)
if (unlink_file_dir (tocvsPath) < 0)
error (0, errno, "cannot remove %s", tocvsPath);
break;
case -1:
if (tocvsPath)
if (unlink_file_dir (tocvsPath) < 0)
error (0, errno, "cannot remove %s", tocvsPath);
if (!noexec)
error (1, errno, "could not check in %s -- fork failed",
finfo->fullname);
return (1);
default:
if (tocvsPath)
if (unlink_file_dir (tocvsPath) < 0)
error (0, errno, "cannot remove %s", tocvsPath);
if (!noexec)
error (0, 0, "could not check in %s", finfo->fullname);
return (1);
}
if (rev)
{
(void) RCS_unlock (finfo->rcs, NULL, 1);
RCS_rewrite (finfo->rcs, NULL, NULL);
}
#ifdef SERVER_SUPPORT
if (server_active)
{
if (set_time)
server_updated (finfo, vers, SERVER_UPDATED,
(mode_t) -1, NULL, NULL);
else
server_checked_in (finfo->file, finfo->update_dir,
finfo->repository);
}
else
#endif
mark_up_to_date (finfo->file);
freevers_ts (&vers);
return 0;
}