diff options
Diffstat (limited to 'contrib/cvs/src/remove.c')
-rw-r--r-- | contrib/cvs/src/remove.c | 84 |
1 files changed, 71 insertions, 13 deletions
diff --git a/contrib/cvs/src/remove.c b/contrib/cvs/src/remove.c index 2911bf4..1571250 100644 --- a/contrib/cvs/src/remove.c +++ b/contrib/cvs/src/remove.c @@ -17,8 +17,14 @@ #include "cvs.h" -static int remove_fileproc PROTO((struct file_info *finfo)); -static Dtype remove_dirproc PROTO((char *dir, char *repos, char *update_dir)); +#ifdef CLIENT_SUPPORT +static int remove_force_fileproc PROTO ((void *callerdat, + struct file_info *finfo)); +#endif +static int remove_fileproc PROTO ((void *callerdat, struct file_info *finfo)); +static Dtype remove_dirproc PROTO ((void *callerdat, char *dir, + char *repos, char *update_dir, + List *entries)); static int force; static int local; @@ -45,7 +51,7 @@ cvsremove (argc, argv) usage (remove_usage); optind = 1; - while ((c = getopt (argc, argv, "flR")) != -1) + while ((c = getopt (argc, argv, "+flR")) != -1) { switch (c) { @@ -71,12 +77,31 @@ cvsremove (argc, argv) #ifdef CLIENT_SUPPORT if (client_active) { + /* Call expand_wild so that the local removal of files will + work. It's ok to do it always because we have to send the + file names expanded anyway. */ + expand_wild (argc, argv, &argc, &argv); + + if (force) + { + if (!noexec) + { + start_recursion (remove_force_fileproc, (FILESDONEPROC) NULL, + (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, + (void *) NULL, argc, argv, local, W_LOCAL, + 0, 0, (char *) NULL, 0); + } + /* else FIXME should probably act as if the file doesn't exist + in doing the following checks. */ + } + start_server (); ign_setup (); if (local) send_arg("-l"); - send_file_names (argc, argv, SEND_EXPAND_WILD); - send_files (argc, argv, local, 0); + send_file_names (argc, argv, 0); + /* FIXME: Can't we set SEND_NO_CONTENTS here? Needs investigation. */ + send_files (argc, argv, local, 0, 0); send_to_server ("remove\012", 0); return get_responses_and_close (); } @@ -84,8 +109,9 @@ cvsremove (argc, argv) /* start the recursion processor */ err = start_recursion (remove_fileproc, (FILESDONEPROC) NULL, - remove_dirproc, (DIRLEAVEPROC) NULL, argc, argv, - local, W_LOCAL, 0, 1, (char *) NULL, 1, 0); + remove_dirproc, (DIRLEAVEPROC) NULL, NULL, + argc, argv, + local, W_LOCAL, 0, 1, (char *) NULL, 1); if (removed_files) error (0, 0, "use '%s commit' to remove %s permanently", program_name, @@ -101,22 +127,42 @@ cvsremove (argc, argv) return (err); } +#ifdef CLIENT_SUPPORT + +/* + * This is called via start_recursion if we are running as the client + * and the -f option was used. We just physically remove the file. + */ + +/*ARGSUSED*/ +static int +remove_force_fileproc (callerdat, finfo) + void *callerdat; + struct file_info *finfo; +{ + if (CVS_UNLINK (finfo->file) < 0 && ! existence_error (errno)) + error (0, errno, "unable to remove %s", finfo->fullname); + return 0; +} + +#endif + /* * remove the file, only if it has already been physically removed */ /* ARGSUSED */ static int -remove_fileproc (finfo) +remove_fileproc (callerdat, finfo) + void *callerdat; struct file_info *finfo; { - char fname[PATH_MAX]; Vers_TS *vers; if (force) { if (!noexec) { - if (unlink (finfo->file) < 0 && ! existence_error (errno)) + if ( CVS_UNLINK (finfo->file) < 0 && ! existence_error (errno)) { error (0, errno, "unable to remove %s", finfo->fullname); } @@ -125,8 +171,7 @@ remove_fileproc (finfo) in doing the following checks. */ } - vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL, (char *) NULL, - finfo->file, 0, 0, finfo->entries, finfo->rcs); + vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0); if (vers->ts_user != NULL) { @@ -142,11 +187,17 @@ remove_fileproc (finfo) } else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') { + char *fname; + /* * It's a file that has been added, but not commited yet. So, * remove the ,t file for it and scratch it from the * entries file. */ Scratch_Entry (finfo->entries, finfo->file); + fname = xmalloc (strlen (finfo->file) + + sizeof (CVSADM) + + sizeof (CVSEXT_LOG) + + 10); (void) sprintf (fname, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG); (void) unlink_file (fname); if (!quiet) @@ -156,6 +207,7 @@ remove_fileproc (finfo) if (server_active) server_checked_in (finfo->file, finfo->update_dir, finfo->repository); #endif + free (fname); } else if (vers->vn_user[0] == '-') { @@ -165,7 +217,10 @@ remove_fileproc (finfo) } else { + char *fname; + /* Re-register it with a negative version number. */ + fname = xmalloc (strlen (vers->vn_user) + 5); (void) strcpy (fname, "-"); (void) strcat (fname, vers->vn_user); Register (finfo->entries, finfo->file, fname, vers->ts_rcs, vers->options, @@ -178,6 +233,7 @@ remove_fileproc (finfo) if (server_active) server_checked_in (finfo->file, finfo->update_dir, finfo->repository); #endif + free (fname); } freevers_ts (&vers); @@ -189,10 +245,12 @@ remove_fileproc (finfo) */ /* ARGSUSED */ static Dtype -remove_dirproc (dir, repos, update_dir) +remove_dirproc (callerdat, dir, repos, update_dir, entries) + void *callerdat; char *dir; char *repos; char *update_dir; + List *entries; { if (!quiet) error (0, 0, "Removing %s", update_dir); |