diff options
author | obrien <obrien@FreeBSD.org> | 2008-01-13 06:13:25 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2008-01-13 06:13:25 +0000 |
commit | b33160d3d4fb099b4be43929fe82ca0af2847860 (patch) | |
tree | f90bfd9c3fed1fd1c6b00db9292d9a530f703595 /contrib/cvs | |
parent | c9aa26049ee1708b6825ac0f16db957e5cd4a024 (diff) | |
download | FreeBSD-src-b33160d3d4fb099b4be43929fe82ca0af2847860.zip FreeBSD-src-b33160d3d4fb099b4be43929fe82ca0af2847860.tar.gz |
Merge rev 1.9 (update "-T" Template support) and rev 1.2 (-D'date'
option with -r'branch' on update) into version 1.11.22.
Diffstat (limited to 'contrib/cvs')
-rw-r--r-- | contrib/cvs/src/update.c | 205 |
1 files changed, 93 insertions, 112 deletions
diff --git a/contrib/cvs/src/update.c b/contrib/cvs/src/update.c index 0ddf3bc..3d82ee4 100644 --- a/contrib/cvs/src/update.c +++ b/contrib/cvs/src/update.c @@ -1,6 +1,11 @@ /* - * Copyright (c) 1992, Brian Berliner and Jeff Polk - * Copyright (c) 1989-1992, Brian Berliner + * Copyright (C) 1986-2005 The Free Software Foundation, Inc. + * + * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, + * and others. + * + * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk + * Portions Copyright (C) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as * specified in the README file that comes with the CVS source distribution. @@ -36,6 +41,7 @@ */ #include "cvs.h" +#include <assert.h> #include "savecwd.h" #ifdef SERVER_SUPPORT # include "md5.h" @@ -180,11 +186,9 @@ update (argc, argv) break; case 'Q': case 'q': -#ifdef SERVER_SUPPORT /* The CVS 1.5 client sends these options (in addition to Global_option requests), so we must ignore them. */ if (!server_active) -#endif error (1, 0, "-q or -Q must be specified before \"%s\"", cvs_cmd_name); @@ -202,6 +206,7 @@ update (argc, argv) tag = optarg; break; case 'D': + if (date) free (date); date = Make_Date (optarg); break; case 'P': @@ -521,13 +526,8 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag, argc, argv, local, which, aflag, CVS_LOCK_READ, preload_update_dir, 1, repository); -#ifdef SERVER_SUPPORT - if (server_active) - return err; -#endif - /* see if we need to sleep before returning to avoid time-stamp races */ - if (last_register_time) + if (!server_active && last_register_time) { sleep_past (last_register_time); } @@ -683,11 +683,7 @@ update_fileproc (callerdat, finfo) bakname = backup_file (finfo->file, vers->vn_user); /* This behavior is sufficiently unexpected to justify overinformativeness, I think. */ -#ifdef SERVER_SUPPORT - if ((! really_quiet) && (! server_active)) -#else /* ! SERVER_SUPPORT */ - if (! really_quiet) -#endif /* SERVER_SUPPORT */ + if (!really_quiet && !server_active) (void) printf ("(Locally modified %s moved to %s)\n", finfo->file, bakname); free (bakname); @@ -702,8 +698,7 @@ update_fileproc (callerdat, finfo) { if (vers->ts_conflict) { - if (file_has_conflict (finfo, vers->ts_conflict) - || file_has_markers (finfo)) + if (file_has_markers (finfo)) { write_letter (finfo, 'C'); retval = 1; @@ -854,11 +849,7 @@ update_filesdone_proc (callerdat, err, repository, update_dir, entries) if (unlink_file_dir (CVSADM) < 0 && !existence_error (errno)) error (0, errno, "cannot remove %s directory", CVSADM); } -#ifdef SERVER_SUPPORT else if (!server_active && !pipeout) -#else - else if (!pipeout) -#endif /* SERVER_SUPPORT */ { /* If there is no CVS/Root file, add one */ if (!isfile (CVSADM_ROOT)) @@ -911,15 +902,11 @@ update_dirent_proc (callerdat, dir, repository, update_dir, entries) is when update -d is specified, and the working directory is gone but the subdirectory is still mentioned in CVS/Entries). */ - if (1 -#ifdef SERVER_SUPPORT - /* In the remote case, the client should refrain from - sending us the directory in the first place. So we - want to continue to give an error, so clients make - sure to do this. */ - && !server_active -#endif - && !isdir (repository)) + /* In the remote case, the client should refrain from + sending us the directory in the first place. So we + want to continue to give an error, so clients make + sure to do this. */ + if (!server_active && !isdir (repository)) return R_SKIP_ALL; if (noexec) @@ -1213,13 +1200,10 @@ scratch_file (finfo, vers) #endif if (unlink_file (finfo->file) < 0 && ! existence_error (errno)) error (0, errno, "unable to remove %s", finfo->fullname); - else -#ifdef SERVER_SUPPORT + else if (!server_active) + { /* skip this step when the server is running since * server_updated should have handled it */ - if (!server_active) -#endif - { /* keep the vers structure up to date in case we do a join * - if there isn't a file, it can't very well have a version number, can it? */ @@ -1261,11 +1245,7 @@ checkout_file (finfo, vers_ts, adding, merging, update_server) /* Don't screw with backup files if we're going to stdout, or if we are the server. */ - if (!pipeout -#ifdef SERVER_SUPPORT - && ! server_active -#endif - ) + if (!pipeout && !server_active) { backup = xmalloc (strlen (finfo->file) + sizeof (CVSADM) @@ -1357,7 +1337,9 @@ VERS: ", 0); for us to stat. */ if (stat (vers_ts->srcfile->path, &sb) < 0) { +#if defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) buf_free (revbuf); +#endif /* defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) */ error (1, errno, "cannot stat %s", vers_ts->srcfile->path); } @@ -1524,8 +1506,10 @@ VERS: ", 0); free (backup); } +#if defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) if (revbuf != NULL) buf_free (revbuf); +#endif /* defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) */ return retval; } @@ -1726,7 +1710,9 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum) retcode = 0; if (! fail) { - char *diff_options; + int dargc = 0; + size_t darg_allocated = 0; + char **dargv = NULL; /* If the client does not support the Rcs-diff command, we send a context diff, and the client must invoke patch. @@ -1734,16 +1720,13 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum) new approach only requires running diff in the server; the client can handle everything without invoking an external program. */ - if (! rcs_diff_patches) - { + if (!rcs_diff_patches) /* We use -c, not -u, because that is what CVS has traditionally used. Kind of a moot point, now that Rcs-diff is preferred, so there is no point in making the compatibility issues worse. */ - diff_options = "-c"; - } + run_add_arg_p (&dargc, &darg_allocated, &dargv, "-c"); else - { /* Now that diff is librarified, we could be passing -a if we wanted to. However, it is unclear to me whether we would want to. Does diff -a, in any significant @@ -1753,10 +1736,11 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum) 'binary'. Conversely, do they tend to be much larger in the bad cases? This needs some more thought/investigation, I suspect. */ - - diff_options = "-n"; - } - retcode = diff_exec (file1, file2, NULL, NULL, diff_options, finfo->file); + run_add_arg_p (&dargc, &darg_allocated, &dargv, "-n"); + retcode = diff_exec (file1, file2, NULL, NULL, dargc, dargv, + finfo->file); + run_arg_free_p (dargc, dargv); + free (dargv); /* A retcode of 0 means no differences. 1 means some differences. */ if (retcode != 0 @@ -1947,6 +1931,47 @@ write_letter (finfo, letter) +/* Reregister a file after a merge. */ +static void +RegisterMerge PROTO((struct file_info *finfo, Vers_TS *vers, + const char *backup, int has_conflicts)); +static void +RegisterMerge (finfo, vers, backup, has_conflicts) + struct file_info *finfo; + Vers_TS *vers; + const char *backup; + int has_conflicts; +{ + /* This file is the result of a merge, which means that it has + been modified. We use a special timestamp string which will + not compare equal to any actual timestamp. */ + char *cp = NULL; + + if (has_conflicts) + { + time (&last_register_time); + cp = time_stamp (finfo->file); + } + Register (finfo->entries, finfo->file, vers->vn_rcs ? vers->vn_rcs : "0", + "Result of merge", vers->options, vers->tag, vers->date, cp); + if (cp) + free (cp); + +#ifdef SERVER_SUPPORT + /* Send the new contents of the file before the message. If we + wanted to be totally correct, we would have the client write + the message only after the file has safely been written. */ + if (server_active) + { + server_copy_file (finfo->file, finfo->update_dir, finfo->repository, + backup); + server_updated (finfo, vers, SERVER_MERGED, (mode_t) -1, NULL, NULL); + } +#endif +} + + + /* * Do all the magic associated with a file which needs to be merged */ @@ -1960,6 +1985,8 @@ merge_file (finfo, vers) int retcode = 0; int retval; + assert (vers->vn_user); + /* * The users currently modified file is moved to a backup file name * ".#filename.version", so that it will stay around for a few days @@ -1997,13 +2024,21 @@ merge_file (finfo, vers) thought needs to go into this, and in the meantime it is safe to treat any such mismatch as an automatic conflict. -twp */ -#ifdef SERVER_SUPPORT - if (server_active) - server_copy_file (finfo->file, finfo->update_dir, - finfo->repository, backup); -#endif + retcode = RCS_checkout (finfo->rcs, finfo->file, + vers->vn_rcs, vers->tag, + vers->options, NULL, NULL, NULL); + if (retcode) + { + error (0, 0, "failed to check out `%s' file", finfo->fullname); + error (0, 0, "restoring `%s' from backup file `%s'", + finfo->fullname, backup); + rename_file (backup, finfo->file); + retval = 1; + goto out; + } + xchmod (finfo->file, 1); - status = checkout_file (finfo, vers, 0, 1, 1); + RegisterMerge (finfo, vers, backup, 1); /* Is there a better term than "nonmergeable file"? What we really mean is, not something that CVS cannot or does not @@ -2037,24 +2072,6 @@ merge_file (finfo, vers) if (strcmp (vers->options, "-V4") == 0) vers->options[0] = '\0'; - /* This file is the result of a merge, which means that it has - been modified. We use a special timestamp string which will - not compare equal to any actual timestamp. */ - { - char *cp = 0; - - if (status) - { - (void) time (&last_register_time); - cp = time_stamp (finfo->file); - } - Register (finfo->entries, finfo->file, vers->vn_rcs, - "Result of merge", vers->options, vers->tag, - vers->date, cp); - if (cp) - free (cp); - } - /* fix up the vers structure, in case it is used by join */ if (join_rev1) { @@ -2065,19 +2082,7 @@ merge_file (finfo, vers) vers->vn_user = xstrdup (vers->vn_rcs); } -#ifdef SERVER_SUPPORT - /* Send the new contents of the file before the message. If we - wanted to be totally correct, we would have the client write - the message only after the file has safely been written. */ - if (server_active) - { - server_copy_file (finfo->file, finfo->update_dir, finfo->repository, - backup); - server_updated (finfo, vers, SERVER_MERGED, - (mode_t) -1, (unsigned char *) NULL, - (struct buffer *) NULL); - } -#endif + RegisterMerge (finfo, vers, backup, status); /* FIXME: the noexec case is broken. RCS_merge could be doing the xcmp on the temporary files without much hassle, I think. */ @@ -2671,31 +2676,7 @@ join_file (finfo, vers) RCS_checkout above, and we aren't running as the server. However, that is not the normal case, and calling Register again won't cost much in that case. */ - { - char *cp = 0; - - if (status) - { - (void) time (&last_register_time); - cp = time_stamp (finfo->file); - } - Register (finfo->entries, finfo->file, - vers->vn_rcs ? vers->vn_rcs : "0", "Result of merge", - vers->options, vers->tag, vers->date, cp); - if (cp) - free(cp); - } - -#ifdef SERVER_SUPPORT - if (server_active) - { - server_copy_file (finfo->file, finfo->update_dir, finfo->repository, - backup); - server_updated (finfo, vers, SERVER_MERGED, - (mode_t) -1, (unsigned char *) NULL, - (struct buffer *) NULL); - } -#endif + RegisterMerge (finfo, vers, backup, status); out: free (rev1); |