From 308b60f66831aa65a459a7b347ea6ca14b6e4799 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 18 Mar 1999 09:21:42 +0000 Subject: Import cvs-1.10 onto vendor branch. Merge to follow shortly. Obtained from: cyclic.com --- contrib/cvs/src/ChangeLog | 712 ++++++++++++++++- contrib/cvs/src/Makefile.in | 5 +- contrib/cvs/src/add.c | 33 +- contrib/cvs/src/admin.c | 20 +- contrib/cvs/src/checkout.c | 103 ++- contrib/cvs/src/classify.c | 10 + contrib/cvs/src/client.c | 60 +- contrib/cvs/src/commit.c | 184 ++--- contrib/cvs/src/cvs.h | 7 +- contrib/cvs/src/diff.c | 18 +- contrib/cvs/src/edit.c | 20 + contrib/cvs/src/error.c | 14 +- contrib/cvs/src/fileattr.c | 8 + contrib/cvs/src/filesubr.c | 42 +- contrib/cvs/src/hardlink.c | 220 ++--- contrib/cvs/src/hardlink.h | 6 +- contrib/cvs/src/history.c | 43 +- contrib/cvs/src/import.c | 32 +- contrib/cvs/src/main.c | 41 +- contrib/cvs/src/mkmodules.c | 5 + contrib/cvs/src/options.h.in | 13 +- contrib/cvs/src/parseinfo.c | 12 + contrib/cvs/src/rcs.c | 1063 ++++++++++++++++++++++--- contrib/cvs/src/rcs.h | 9 + contrib/cvs/src/rcscmds.c | 108 ++- contrib/cvs/src/recurse.c | 47 +- contrib/cvs/src/rtag.c | 2 +- contrib/cvs/src/sanity.sh | 1814 ++++++++++++++++++++++++++++++++++++++---- contrib/cvs/src/server.c | 96 ++- contrib/cvs/src/status.c | 2 +- contrib/cvs/src/tag.c | 15 +- contrib/cvs/src/update.c | 82 +- contrib/cvs/src/version.c | 3 +- contrib/cvs/src/wrapper.c | 10 + 34 files changed, 4107 insertions(+), 752 deletions(-) (limited to 'contrib/cvs/src') diff --git a/contrib/cvs/src/ChangeLog b/contrib/cvs/src/ChangeLog index 96e1701..8077ce8 100644 --- a/contrib/cvs/src/ChangeLog +++ b/contrib/cvs/src/ChangeLog @@ -1,5 +1,709 @@ +Thu Aug 13 11:15:24 1998 Noel Cragg + + * version.c: Change version number to 1.10 and name to `Halibut'. + + * sanity.sh (rcslib): new tests to check behavior of symlinks in + the repository. + +Wed Aug 12 15:39:38 1998 Noel Cragg + + * main.c (lookup_command_attribute): the `annotate' command + shouldn't require access to the repository. Add comment about + commands that do not use the working directory. + +Mon Aug 10 10:26:38 1998 Noel Cragg + + * version.c: Change version number to 1.9.30. + +Thu Aug 6 17:44:50 1998 Noel Cragg + + * server.c (serve_rdiff): change the name of the command (for + error reporting, etc.) from "patch" to "rdiff." + (serve_remove): rename from "cvsremove" to "remove." + + * main.c (lookup_command_attribute): the `rdiff' command shouldn't + require write access to the repository. + +1998-08-06 David Masterson of kla-tencor.com + and Jim Kingdon + + * commit.c (commit_filesdoneproc): Don't call strlen ("CVSROOT") + from within the assert statement. Apparently HP's cc compiler on + HPUX 10.20 has trouble with that. + +1998-08-06 Jim Kingdon + + * rcs.c (RCS_checkin): When adding branch, if there is a lock on + the branchpoint owned by someone else, leave it alone. This + restores CVS 1.9 (RCS 5.7) behavior, fixing a core dump. + * sanity.sh (reserved): New tests reserved-16 through reserved-19 + test for this fix. + +1998-08-05 Jim Kingdon + + * sanity.sh (unedit-without-baserev): Use ${QUESTION} not "?". + This makes it work with GNU expr 1.12 as well as 1.16. + +Sun Aug 2 20:27:44 1998 Noel Cragg + + * mkmodules.c: add comment about TopLevelAdmin for the initial + contents of CVSROOT/config. + +1998-07-29 Jim Kingdon + + * rcs.c (RCS_checkin): Only try to call xreadlink if HAVE_READLINK + is defined. + +Tue Jul 28 19:33:08 1998 Noel Cragg + + * version.c: Change version number to 1.9.29. + + * rcs.c (RCS_checkin): add code to follow symbolic links in the + repository. + +Sun Jul 26 05:14:41 1998 Noel Cragg + + * This set of changes reverts the code to pre-1.9.2 behavior and + does not create CVS directories at top-level (except for the + obvious "cvs co ."). Added a new configuration option to switch + between 1.9 and 1.9.2 behavior. + + * recurse.c (do_argument_proc): new function. + (start_recursion): in the case that we've done a command from + top-level but have no CVS directory there, the behavior should be + the same as "cvs dir1 dir2 dir3...". Make sure that the + appropriate "Argument" commands are sent to the server by calling + walklist with do_argument_proc. + + * client.c (call_in_directory): only create the top-level CVS + directory when we're checking out "." explicitly. The server will + force creation of this directory in all other cases. + + * checkout.c (checkout_proc): only generate the top-level + directory when the TopLevelAdmin=yes. Also send a message to the + client to do the same. + + * parseinfo.c (parse_config): handle TopLevelAdmin option. Set + top_level_admin. + + * main.c: add new variable top_level_admin. + * cvs.h: add extern definition for above. + + * sanity.sh: since we're reverting to pre 1.9.2 behavior for + top-level CVS directories, I needed to make changes to a bunch of + tests that made assumptions about said directories. + (preamble): make sure to add read and execute access to everything + in TMPDIR before removing, since some tests make things read-only. + (basicb-1a, basicb-1b, basicb-9a, basicb-9b): use dotest_fail + because these tests check for the non-existant top-level CVS + directory. + (basicc-3, emptydir-6, emptydir-7, crerepos-6): use "rm -rf" so it + won't complain when trying to remove the non-existant top-level + CVS directory. + (106.5): remove imported-f2-orig.tmp. + (modules2-10, emptydir-4, abspath-1ba, abspath-1bb): cd into the + directory where files exist before using the "add" command so cvs + can find CVSROOT in CVS/Root. + (cvsadm-2): look at a different CVS/Repository file, since the + top-level one doesn't exist. + (taginfo-3): create the directory in the repository directly + rather than relying on the fact that the top-level CVS directory + was created in a previous test. + (serverpatch-6): update first-dir explicity, rather than relying + on the non-existant top-level CVS/Entries file. + (crerepos-18): look at CVS/Repository in a subdirectory rather + than in the non-existant top-level CVS directory. + (toplevel): add code to set TopLevelAdmin=yes. + (toplevel2): new tests -- same as toplevel, but TopLevelAdmin=no. + +1998-07-21 Jim Meyering + + * rcs.c (RCS_checkout): Hoist frees of rev and value. + Warn and return 1 in several cases rather than exiting via + `error (1, ...'. The latter could abort a multi-file commit + in mid-stream, leaving stale locks in the repository. + +1998-07-16 Jim Kingdon + + * build_src.com (rcscmds.c): Also look for include files in + [-.diff], just like Ian's 1998-06-18 change to Makefile.in + +1998-07-14 Jim Kingdon + + * tag.c (pretag_proc), rtag.c (pretag_proc): Don't pass RUN_REALLY + to run_exec. This means that taginfo does not get executed if the + global -n option is specified. Which makes it like loginfo, -i, + -e, -o, -t, -u in modules, editinfo, and verifymsg and unlike + commitinfo. The old behavior was pretty bad in the sense that it + doesn't provide any way to log only the tags which actually + happen. + * sanity.sh (taginfo): New tests taginfo-11 to taginfo-13, for this. + +1998-07-12 Jim Kingdon + + * sanity.sh (ann-id): Write the test so that it tests for the + current (buggy) behavior. + + * sanity.sh (taginfo): Also clean up cvsroot/first-dir. + +1998-07-12 Jim Meyering + + * sanity.sh (ann-id): New (currently failing) test for bug in how + rcs keywords are expanded in the output of `cvs annotate'. + +1998-07-12 Jim Kingdon + + * sanity.sh (taginfo): Write the TESTDIR into the script rather + than having the script look at the environment. This means that + it will work if TESTDIR is set by sanity.sh as well as if + sanity.sh finds TESTDIR in the environment. + +1998-07-11 Jim Kingdon + + * tag.c (check_fileproc): Calculate the revision to be tagged the + same way that tag_fileproc does. + * sanity.sh (taginfo): New tests, test for this (before this fix, + brtag had said 1.1 not 1.1.2.1). + +1998-07-10 Jim Kingdon + + * sanity.sh (unedit-without-baserev): Also clean up "2" directory. + +1998-07-08 Jim Kingdon + + * edit.c (unedit_fileproc): If the Baserev file is missing, don't + get the working file from CVS/Base. The previous code could get + you version 1.1 of the working file and put 1.2 in CVS/Entries. + * sanity.sh (unedit-without-baserev): New tests test for this. + +1998-07-02 Jim Kingdon + + * sanity.sh (unedit-without-baserev): Move the test itself to be + in the same order as in the "tests" variable. + +1998-07-02 Ian Lance Taylor + + * rcscmds.c: Don't include or . Don't + declare vasprintf. + (call_diff_printf_output): Remove. + (call_diff_stdout_callbacks): Don't initialize printf_output + field--it has been removed from the interface. + (call_diff_file_callbacks): Likewise. + +1998-07-01 Jim Meyering + + * edit.c (unedit_fileproc): Handle the case in which base_get + returns a NULL baserev. That happens when a file being `unedit'ed + exists in the CVS/Base directory, but isn't listed in the CVS/Baserev + file. The one case I've seen had no Baserev file at all. The symptom + (if you're lucky) is a segmentation fault upon unedit. If you use + SunOS4.1.4 for which printf prints NULL pointers as `(null)', your + unedit command will complete normally, but it will have corrupted + your CVS/Entries file and a subsequent update may result in an + assertion failure, a core dump, and a stale lock in the repository. + * sanity.sh (unedit-without-baserev): New test for this. + +1998-07-01 Andy Mortimer of aeat.co.uk + and Jim Kingdon + + * server.c (server_updated): Use a prototype if we are using them + for declarations. + +1998-06-29 Jim Kingdon + + * sanity.sh (commit-readonly): Protect keyword against expansion + in sanity.sh itself. Keep the keyword in the file which we check + in (or else this fails to test for the RCS_checkout change). + +1998-06-27 Jim Meyering + + * rcs.c (RCS_checkout): If opening the local workfile fails due to + lack of write access, try to chmod the file and retry the open. + Before, a commit could fail part way through merely because the + open to rewrite with newly expanded rcs keywords would fail. It's + easy to make this happen if you use `cvs -r' or CVSREAD and you + apply a patch to one of your read-only source files -- patch + preserves the read-only setting for the file and your next commit + will fail after committing that file, but before rewriting + (checking out) your working copy. + * sanity.sh (commit-readonly): New test for this. + +1998-06-25 Jim Kingdon + + * update.c (patch_file): Update comments regarding context diffs + to reflect diff library. + +1998-06-23 Jim Kingdon + + * sanity.sh (modules4): Add tests for reversing the order of the + "!first-dir/sdir" and "first-dir". + +1998-06-23 Jim Kingdon + and Dave Wolfe@Motorola. + + * sanity.sh (modes2): Touch the file before chmod'ing it. + +1998-06-21 Ian Lance Taylor + + * update.c (merge_files): Revert changes of 1998-06-19. Instead, + register a merged file with a dummy time stamp. Only set + last_register_time if we need to. + (join_file): Likewise. Always register a merged file, not just + when the merge fails. + +1998-06-21 Jim Kingdon + + * call_diff_write_output, call_diff_printf_output, + call_diff_flush_output, call_diff_write_stdout, call_diff_error, + call_diff_stdout_callbacks, call_diff_file_callbacks): Re-indent. + +1998-06-19 Ian Lance Taylor + + * update.c (merge_file): Make sure the time stamp of the file is + different from the time stamp we register in the Entries file. + (join_file): Likewise. + +1998-06-18 Ian Lance Taylor + + * rcscmds.c: Include . Include either or + . Declare vasprintf. + (call_diff_write_output): New static function. + (call_diff_printf_output): New static function. + (call_diff_flush_output): New static function. + (call_diff_write_stdout): New static function. + (call_diff_error): New static function. + (call_diff_stdout_callbacks): New static variable. + (call_diff_file_callbacks): New static variable. + (call_diff): Don't sleep. Use a callback structure when calling + the diff library. + (call_diff3): Likewise. + + * rcscmds.c: Include diffrun.h. + (call_diff, call_diff3): Pass NULL callback parameter. + (diff_run, diff3_run): Don't declare. + * Makefile.in (rcscmds.o): New target, to use -I for diff + directory. + (zlib.o): Depend upon zlib.h. + +1998-06-09 Mike Sutton@SAIC + + Make it compile with Sun's bundled K&R C compiler: + * rcs.c (count_delta_actions): Change to static to match + declaration. + * client.c (handle_wrapper_rcs_option): Rename error label to + handle_error to avoid clash with function name. + +1998-06-09 Jim Kingdon + + * rcs.c (RCS_delete_revs): If we are trying to delete all + revisions, give an error rather than assertion failed. + * sanity.sh (basicb): New tests basicb-o* test for this. + +1998-06-04 Jim Kingdon + + * add.c (add): Only send "Directory" requests if we need to. + +1998-06-02 Assar Westerlund + + * client.c: Check for HAVE_GSS_C_NT_HOSTBASED_SERVICE rather than + assuming that GSS_C_NT_HOSTBASED_SERVICE is a macro. + * server.c: Likewise. + +1998-06-02 Jim Kingdon + + * fileattr.c (fileattr_read): Check for NULL return from strchr. + * sanity.sh (devcom3): New test devcom3-10 checks for this. + +1998-06-01 Assar Westerlund + and Ian Lance Taylor + + * client.c: If HAVE_GSSAPI_H, include . Only include + if HAVE_GSSAPI_GSSAPI_H. Only include + if HAVE_GSSAPI_GSSAPI_GENERIC_H. + (GSS_C_NT_HOSTBASED_SERVICE): Define if not defined. + (connect_to_gserver): Use GSS_C_NT_HOSTBASED_SERVICE instead of + gss_nt_service_name. + * server.c: Same header file changes. + (GSS_C_NT_HOSTBASED_SERVICE): Define if not defined. + (gserver_authenticate_connection): Use GSS_C_NT_HOSTBASED_SERVICE + instead of gss_nt_service_name. + +1998-06-01 Jim Meyering + + * sanity.sh (tag8k): Add a test for the 1998-05-02 rcs.c bug fix. + +1998-05-26 Jim Kingdon + + * rcs.c (annotate): Call tag_check_valid like the other functions + which have a -r option. + * sanity.sh (ann): New test ann-14 tests for this. + +1998-05-24 Jim Kingdon + + * sanity.sh (importc): New tests importc-5 through importc-8 test + for a (fairly obscure) regression from CVS 1.9. + +1998-05-23 Jim Kingdon + + * sanity.sh (modules2): Add comment listing cvs release tests. + (info): New test info-cleanup-0 tests "cvs -n release". + + * rcs.c (rcsbuf_getid): Remove semicolon at end of #undef. I'm + kind of surprised that compilers accepted this at all, but + removing it squelches a warning for some compilers. + + * version.c: Change version number to 1.9.28.1. + + * Version 1.9.28. + +1998-05-22 Jim Kingdon + + * rcs.c (RCS_cmp_file): Check for errors from CVS_FOPEN. This + restores the CVS 1.9 behavior (fatal error if we can't open the + file), and corrects an apparent oversight in Ian's 13 Apr 1997 + change. + * sanity.sh (modes2): New test, tests for this. + +1998-05-22 Ian Lance Taylor + + * server.c (server_updated): Correct test for whether to unlink + the file. + +1998-05-20 Jim Kingdon + + * wrapper.c (wrap_add): Disable -t/-f wrappers at least until the + serious bug can be fixed. + +1998-05-15 Jim Kingdon + + * checkout.c (checkout): Call server_pathname_check on the + argument to "cvs co -d". + * server.c (server_pathname_check): Add comment about how we could + be handling absolute pathnames. + * sanity.sh (abspath): Rewrite the tests which run "cvs co -d /foo" + for remote, to reflect this. + + * sanity.sh (abspath): Also do the "cannot rename" work-around for + abspath-7d. + +1998-05-13 Jim Kingdon + + * commit.c (commit_filesdoneproc): Free admin_dir when done with it. + +1998-05-13 Jim Meyering + + * sanity.sh (editor): Change bogus sed command, `s/^/x&/g', to `s/^/x/'. + The former exercised a bug in GNU sed-3.01-beta3. + (emptydir-8): Add `Rebuilding administrative file database' message, + since now it does that. + * commit.c (commit_filesdoneproc): Pass only the admin directory + pathname to mkmodules. + Remove #if 0, now that it's fixed. + + * status.c (cvsstatus): Rename from `status' to avoid shadowing + lots of locals and parameters by the same name. + * server.c (serve_status): Update caller. + * main.c (cmds[]): Update table entry. + * cvs.h: Update prototype. + + * commit.c (commit_filesdoneproc): Remove trailing blanks. + (commit) [CLIENT_SUPPORT]: Remove unnecessary (and local-shadowing) + declaration of `err'. + Rename global `tag' to `saved_tag' to avoid overshadowing `tag' + parameters of three functions. + Rename global `message' to `saved_message' to avoid overshadowing + `message' parameter of a function. + Rename global `ulist' to `saved_ulist' and move dcl up with others. + +1998-05-12 Jim Kingdon + + * commit.c (commit_filesdoneproc): #if 0 the new code until it can + be fixed. + + * commit.c (commit_filesdoneproc): Add comment explaining last + change. + +1998-05-12 Jim Meyering + + * commit.c (commit_filesdoneproc): Call mkmodules not just when + committing a file directly under CVSROOT, but also when committing + files in subdirectories of CVSROOT. + +1998-05-08 Jim Meyering + + * filesubr.c (xreadlink): NUL-terminate the symbolic link name. + Use a much smaller initial buffer length. + Test errno only if readlink fails. + Use xstrdup then free the original link name so we don't waste space. + +1998-05-02 Jim Meyering + + * rcs.c (rcsbuf_getword): Fix off-by-one error that would result in + an abort (the first one in rcsbuf_getkey) when operating on on some + ,v files with over 8192 bytes of tag and branch info. + +1998-05-04 Jim Kingdon + + * sanity.sh (ann): New tests ann-12 and ann-13 test for specifying + a numeric branch. + +1998-05-02 Jim Kingdon + + * rcs.c: Add comments about getting rid of rcsbuf_getid, + rcsbuf_getword, and rcsbuf_getstring. + + * sanity.sh (abspath): Revise the workarounds to deal with exit + status. + +1998-04-30 Jim Kingdon + + * sanity.sh (abspath): Work around the "cannot rename" bug. + +1998-04-27 Jim Kingdon + + * classify.c (Classify_File): Add comments about checking whether + command name is "update". + +1998-04-22 Jim Kingdon + + * version.c: Change version number to 1.9.27.1. + + * Version 1.9.27. + +1998-04-20 Jim Kingdon + + (This diff was run by devel-cvs and everyone seemed to like it). + * diff.c (diff_file_nodiff): Make HEAD mean the head of the branch + which contains the sticky tag, not the sticky tag itself. + * rcs.c, rcs.h (RCS_branch_head): New function. + * sanity.sh (head): Update for this changed behavior. + +1998-04-19 Jim Kingdon + + * sanity.sh: Move emptydir tests from basicb to new test emptydir. + This is because we now need a module definition to create Emptydir; + "co -d" doesn't cut it anymore. + +1998-04-17 Petri Virkkula + + * server.c (mkdir_p): Ignore EROFS error (like for EACCES). + +1998-04-16 Jim Kingdon + + * checkout.c (checkout_proc): Don't create directories above the + last one specified in "co -d". + (build_dirs_and_chdir): Revert Noel's change of 17 Feb 1998. + (struct dir_to_build): New field just_chdir. + (build_dirs_and_chdir): Test it. + * sanity.sh (abspath): New tests abspath-7* test for a bug which + we fix, in which CVS would create bogus "D/////" entries in + CVS/Entries. + (abspath): Revise abspath-3* tests to test for the fact that we no + longer create directories above the last one specified in "co -d". + I checked that CVS 1.9 gives an error on this, so changing this + behavior back should be OK. + (cvsadm-2d3): Likewise (also checked CVS 1.9 for this case). + (cvsadm-2d3d): Likewise (also checked CVS 1.9 for this case). + (cvsadm-2d{4,5,6,7,8}, cvsadm-N2d{3,4,5,6,7,8}): Adjust for new + behavior (same case as cvsadm-2d3). + (cvsadm-2d{4,5,6,7,8}d, cvsadm-N2d{3,4,5,6,7,8}d): Remove test + (same case as cvsadm-2d3d). + (cvsadm): For remote, skip most these tests. + (abspath): When cleaning up, delete mod1 and mod2 rather than mod1 + twice (longstanding bug, apparently only becomes visible if you + run the tests in a certain order). + +1998-04-14 Wilfredo Sanchez + + * rcs.c: variable "lockfile" was being referenced after being + free'd. Bad. Moved the free() call down. + +1998-04-12 Jim Kingdon + + * sanity.sh (rcs): Add test for annotate and the year 2000. + + * server.c (do_cvs_command): If there are partial lines left when + the child process is done, send them along. + * sanity.sh (rcs, rcs2): Enable all tests for remote; tests for + this fix. + +1998-04-11 Jim Kingdon + + * client.c (client_senddate): Pass SDATEFORM not DATEFORM to + sscanf. This fixes a Y2K bug. + + * history.c (history, select_hrec): Change since_date from time_t + to RCS format. Use the usual machinery (in particular, Make_Date + and client_senddate) so that it will work on VMS too. + * main.c, cvs.h (date_from_time_t): New function. + * sanity.sh (history): New test, to test that this didn't break + anything (also tests client_senddate fix). + +1998-04-11 Norbert Kiesel + + * server.c (cvs_output_binary): Shut up "gcc -Wall" by removing + unnecessary else if test. + * server.c (check_password): Fix uninitialized memory read if + shadow passwords are used. Also added some comments. + * rcs.c (RCS_checkout): Make sure to call chown with -1 for uid or + gid if they should not be changed + +1998-04-10 Jim Kingdon + + * sanity.sh (rcs2): New test, tests for various Y2K cases. + * rcs.c (getdelta): Value for "state" keyword is optional (bug + discovered incidentally in writing rcs2 test). + +1998-04-09 Jim Kingdon + + * filesubr.c, cvs.h (link_file): Remove; no longer used. + +1998-04-08 Jim Kingdon + + * recurse.c (do_dir_proc): Restore update_dir rather than a + computation which appears to, but does not necessarily, restore it + (reported by various people; this fix is from Greg Hudson). + * sanity.sh (importc): New test, tests for this fix. + +1998-03-27 Jim Kingdon + + * rcs.c (RCS_lock): If the revision is already locked, give an + error rather than dumping core. + * sanity.sh (reserved): New test reserved-13c tests for this. + +1998-03-25 Loren J. Rittle + + * import.c (add_rev): Rewrite to use RCS_FLAGS_KEEPFILE option + of RCS_checkin() to avoid damage to imported files instead of + externally undoing damage after the fact. The side effect is + that callers of add_rev() may now incrementally walk the + entries of the current directory without seeing gratuitous + changes to the directory structure (under at least one file + system under at least one OS). + +1998-03-18 Jim Kingdon + + * error.c (error): Save and restore errno. Should fix test case + conflicts3-23 on SCO 5.0.2. Reported by Steve Cameron. + + * sanity.sh (admin): Rename admin-26-o* to admin-26-*; the "o" + stands for "cvs admin -o". Add comment about length of tests. + Use ${PLUS}. + +1998-03-05 Dan Wilder + + * Fix problem with cvs admin in which -ntag:branch + option associated tag with the branch's head revision. + Should have used branch number. Entailed in this fix, + the following. + + * Add new functions "RCS_exist_rev", "RCS_exist_tag", + "RCS_tag2rev", and "RCS_valid_rev" to rcs.c. RCS_tag2rev + is similar to RCS_gettag, but does less interpretation. + + * Plug a small memory leak. + + * Add tests admin-26 through admin-29 to sanity.sh, + to test "cvs admin -n". + +1998-03-17 Samuel Tardieu + + * server.c (server_register): protect dereferencing timestamp in + the trace message when it is null, to avoid a segmentation fault. + +1998-03-16 Jim Kingdon + + * options.h.in (MY_NDBM): Rewrite the comment explaining this + option. It was not clear to everyone who "my" referred to, for + example. + + * hardlink.c (list_linked_files_on_disk): Remove unused variables + err and p. + (list_linked_files_on_disk): Add comment about memory allocation + of return value. + * rcs.c (rcsbuf_getword): Shut up gcc -Wall with a "return 0". + (RCS_checkin): Remove unused variable fullpath. + * sanity.sh (hardlinks): Remove comment about spurious warnings; + the warnings are gone. + +1998-03-12 Tim Pierce + + New functions for parsing and writing hardlink fields. + * rcs.c [PRESERVE_PERMISSIONS_SUPPORT] (puthardlink_proc): New + function. + (putdelta) [PRESERVE_PERMISSIONS_SUPPORT]: Use it. + (rcsbuf_getid, rcsbuf_getstring, rcsbuf_getword): New functions. + (getdelta): Call them, storing `hardlinks' field in vnode->hardlinks. + (RCS_reparsercsfile): When setting rdata->desc, xstrdup value + rather than rcsbuf_valcopying it (due to changes in how getdelta + handles keys and values in newphrases). + + * sanity.sh (hardlinks): Use uglier filenames. Checking out + hardlinked files no longer produces the same spurious diagnostics, + so fix that test. + (hardlinks-2.3): Renamed from hardlinks-2.2 (duplicate test name). + + New infrastructure for managing hardlink lists internally... + * hardlink.c, hardlink.h (list_linked_files_on_disk, + compare_linkage_lists, find_checkedout_proc): New functions. + * rcs.h (struct rcsversnode) [PRESERVE_PERMISSIONS_SUPPORT]: New + member `hardlinks'. + * update.c (special_file_mismatch): Get hardlinks from + vp->hardlinks instead of from vp->other_delta. + * rcs.c (free_rcsvers_contents): Comment about freeing hardlinks + member. + (RCS_checkout) [PRESERVE_PERMISSIONS_SUPPORT]: Get hardlinks from + vers->hardlinks list instead of vers->other_delta. + + ... and removed obsolete code from earlier revs. + * hardlink.c, hardlink.h (list_files_linked_to, + cache_hardlinks_proc, list_files_proc, set_hardlink_field_proc): + Removed. + * hardlink.h: Removed `links' member from hardlink_info struct. + * commit.c (commit): Remove the call to cache_hardlinks_proc. + (check_fileproc) [PRESERVE_PERMISSIONS_SUPPORT]: Removed reference + to hlinfo->links. + * hardlink.c (update_hardlink_info): Same. + * update.c (get_linkinfo_proc): Same. + + * rcs.c (RCS_checkout) [PRESERVE_PERMISSIONS_SUPPORT]: Use + vp->hardlinks and find_checkedout_proc to find recently-updated + files that may be hardlinked. + * update.c (special_file_mismatch): Use List * structures and + compare_linkage_lists for rev1_hardlinks and rev2_hardlinks. + +1998-03-16 Larry Jones + + * server.c (check_password): If shadow passwords are supported but no + entry is found in the shadow file, check the regular password file. + +1998-03-07 Jim Kingdon + + * sanity.sh: Rename permissions test to perms since that is what + each of its individual tests are named. + * sanity.sh (perms symlinks hardlinks): Change CVSROOT to + CVSROOT_DIRNAME where appropriate. + (perms symlinks hardlinks): Disable/adjust the meat of the tests for + remote. + (symlinks): Link to ${TESTDIR}/fumble rather than + /fumble/mumble/grumble. We shouldn't be making assumptions about + what might exist in random directories outside ${TESTDIR}. + * hardlink.c (cache_hardlinks_proc): Add comment about trimming + whitespace. + +1998-03-07 Tim Pierce + + * rcs.c (RCS_checkout): Negation bug when checking out symlinks: + existence_error should be !existence_error. + * sanity.sh (permissions symlinks hardlinks): New tests, for + PreservePermissions. + 1998-03-04 Jim Kingdon + * version.c: Change version number to 1.9.26.1. + + * Version 1.9.26. + * entries.c, cvs.h (Entries_Open): New argument update_dir; use it in error message. * add.c, checkout.c, client.c, find_names.c, import.c, recurse.c, @@ -30,7 +734,7 @@ * update.c (special_file_mismatch): Compare the hard links of the two revisions. - * rcs.c (RCS_checkout): + * rcs.c (RCS_checkout): * hardlink.c, hardlink.h: New files. (hardlink_info): New struct. @@ -235,7 +939,7 @@ Tue Feb 17 02:32:21 1998 Noel Cragg [These mods make "checkout" work with "-d /absolute/pathname" once again.] - + * checkout.c (checkout_proc): the -d flag on the command line should override the -d flag in the modules file if the latter is an absolute path. The loop that assembles the list of directories @@ -255,7 +959,7 @@ Tue Feb 17 02:32:21 1998 Noel Cragg * create_adm.c (Create_Admin): include the directory in the error message. - + 1998-02-16 Jim Kingdon * diff.c (diff_fileproc), import.c (import, add_rcs_file), rcs.c @@ -294,7 +998,7 @@ Tue Feb 17 02:32:21 1998 Noel Cragg Support for device special files, symbolic links, user and group ownerships, and file permissions. - + * parseinfo.c: (parse_config): Handle new config variable `PreservePermissions'. * mkmodules.c (config_contents): Add new PreservePermissions var. diff --git a/contrib/cvs/src/Makefile.in b/contrib/cvs/src/Makefile.in index 61b4fe2..2c93ec2 100644 --- a/contrib/cvs/src/Makefile.in +++ b/contrib/cvs/src/Makefile.in @@ -177,7 +177,10 @@ cvsbug: cvsbug.sh $(srcdir)/version.c $(OBJECTS): $(HEADERS) options.h -zlib.o: zlib.c +rcscmds.o: rcscmds.c $(top_srcdir)/diff/diffrun.h + $(CC) $(CPPFLAGS) $(INCLUDES) -I$(top_srcdir)/diff $(DEFS) $(CFLAGS) -c $(srcdir)/rcscmds.c + +zlib.o: zlib.c $(top_srcdir)/zlib/zlib.h $(CC) $(CPPFLAGS) $(INCLUDES) -I$(top_srcdir)/zlib $(DEFS) $(CFLAGS) -c $(srcdir)/zlib.c subdir = src diff --git a/contrib/cvs/src/add.c b/contrib/cvs/src/add.c index d44435a..a4eed40 100644 --- a/contrib/cvs/src/add.c +++ b/contrib/cvs/src/add.c @@ -56,6 +56,9 @@ add (argc, argv) List *entries; Vers_TS *vers; struct saved_cwd cwd; + /* Nonzero if we found a slash, and are thus adding files in a + subdirectory. */ + int found_slash = 0; if (argc == 1 || argc == -1) usage (add_usage); @@ -108,6 +111,20 @@ add (argc, argv) error (0, 0, "cannot add special file `%s'; skipping", argv[i]); skip_file = 1; } + else + { + char *p; + p = argv[i]; + while (*p != '\0') + { + if (ISDIRSEP (*p)) + { + found_slash = 1; + break; + } + ++p; + } + } if (skip_file) { @@ -143,9 +160,16 @@ add (argc, argv) if (options) send_arg(options); option_with_arg ("-m", message); - repository = Name_Repository (NULL, NULL); - send_a_repository ("", repository, ""); - free (repository); + /* If !found_slash, refrain from sending "Directory", for + CVS 1.9 compatibility. If we only tried to deal with servers + which are at least CVS 1.9.26 or so, we wouldn't have to + special-case this. */ + if (found_slash) + { + repository = Name_Repository (NULL, NULL); + send_a_repository ("", repository, ""); + free (repository); + } for (i = 0; i < argc; ++i) /* FIXME: Does this erroneously call Create_Admin in error @@ -194,7 +218,8 @@ add (argc, argv) Create_Admin (p, argv[i], rcsdir, tag, date, nonbranch, 0); - send_a_repository ("", repository, update_dir); + if (found_slash) + send_a_repository ("", repository, update_dir); if (restore_cwd (&cwd, NULL)) error_exit (); diff --git a/contrib/cvs/src/admin.c b/contrib/cvs/src/admin.c index 3c50f4a..72cddac 100644 --- a/contrib/cvs/src/admin.c +++ b/contrib/cvs/src/admin.c @@ -701,15 +701,27 @@ admin_fileproc (callerdat, finfo) rcs->path, tag, n->data); status = 1; + free (tag); continue; } } - /* Expand rev if necessary. */ - rev = RCS_gettag (rcs, p, 0, NULL); - RCS_settag (rcs, tag, rev); - if (rev != NULL) + /* Attempt to perform the requested tagging. */ + + if ((*p == 0 && (rev = RCS_head (rcs))) + || (rev = RCS_tag2rev (rcs, p))) /* tag2rev may exit */ + { + RCS_check_tag (tag); /* exit if not a valid tag */ + RCS_settag (rcs, tag, rev); free (rev); + } + else + { + error (0, 0, + "%s: Symbolic name or revision %s is undefined", + rcs->path, p); + status = 1; + } free (tag); break; case 's': diff --git a/contrib/cvs/src/checkout.c b/contrib/cvs/src/checkout.c index 46151eb..c6a8122 100644 --- a/contrib/cvs/src/checkout.c +++ b/contrib/cvs/src/checkout.c @@ -242,6 +242,13 @@ checkout (argc, argv) error (1, 0, "tag `%s' must be a symbolic tag", tag); } +#ifdef SERVER_SUPPORT + if (server_active && where != NULL) + { + server_pathname_check (where); + } +#endif + if (!safe_location()) { error(1, 0, "Cannot check out files into the repository itself"); } @@ -428,11 +435,15 @@ struct dir_to_build /* The path to the directory. */ char *dirpath; + /* If set, don't build the directory, just change to it. + The caller will also want to set REPOSITORY to NULL. */ + int just_chdir; + struct dir_to_build *next; }; static int build_dirs_and_chdir PROTO ((struct dir_to_build *list, - int sticky, int check_existing_dirs)); + int sticky)); static void build_one_dir PROTO ((char *, char *, int)); @@ -723,6 +734,7 @@ internal error: %s doesn't start with %s in checkout_proc", head->repository = NULL; head->dirpath = xstrdup (where); head->next = NULL; + head->just_chdir = 0; /* Make a copy of the repository name to play with. */ @@ -760,7 +772,26 @@ internal error: %s doesn't start with %s in checkout_proc", assert (strlen (where)); strcpy (new->dirpath, "/"); } - + new->next = head; + head = new; + + /* If where consists of multiple pathname components, + then we want to just cd into it, without creating + directories or modifying CVS directories as we go. + In CVS 1.9 and earlier, the code actually does a + CVS_CHDIR up-front; I'm not going to try to go back + to that exact code but this is somewhat similar + in spirit. */ + if (where_orig != NULL + && cp - where < strlen (where_orig)) + { + new->repository = NULL; + new->just_chdir = 1; + continue; + } + + new->just_chdir = 0; + /* Now figure out what repository directory to generate. The most complete case would be something like this: @@ -771,12 +802,13 @@ internal error: %s doesn't start with %s in checkout_proc", cvs co -d what/ever -N foo The results in the CVS/Repository files should be: - . -> . (this is where we executed the cmd) - what -> Emptydir (generated dir -- not in repos) + . -> (don't touch CVS/Repository) + (I think this case might be buggy currently) + what -> (don't touch CVS/Repository) ever -> . (same as "cd what/ever; cvs co -N foo") bar -> Emptydir (generated dir -- not in repos) baz -> quux (finally!) */ - + if (strcmp (reposcopy, CVSroot_directory) == 0) { /* We can't walk up past CVSROOT. Instead, the @@ -835,9 +867,6 @@ internal error: %s doesn't start with %s in checkout_proc", } } } - - new->next = head; - head = new; } /* clean up */ @@ -852,12 +881,29 @@ internal error: %s doesn't start with %s in checkout_proc", may not have a thing to do with where the sources are being checked out. If it does, build_dirs_and_chdir will take care of creating adm files here. */ - - if (! where_is_absolute) + /* FIXME: checking where_is_absolute is a horrid kludge; + I suspect we probably can just skip the call to + build_one_dir whenever the -d command option was specified + to checkout. */ + + if (! where_is_absolute && top_level_admin) { /* It may be argued that we shouldn't set any sticky bits for the top-level repository. FIXME? */ build_one_dir (CVSroot_directory, ".", *pargc <= 1); + +#ifdef SERVER_SUPPORT + /* We _always_ want to have a top-level admin + directory. If we're running in client/server mode, + send a "Clear-static-directory" command to make + sure it is created on the client side. (See 5.10 + in cvsclient.dvi to convince yourself that this is + OK.) If this is a duplicate command being sent, it + will be ignored on the client side. */ + + if (server_active) + server_clear_entstat (".", CVSroot_directory); +#endif } @@ -866,8 +912,7 @@ internal error: %s doesn't start with %s in checkout_proc", contain a CVS subdir yet, but all the others contain CVS and Entries.Static files */ - if (build_dirs_and_chdir (head, *pargc <= 1, - where_is_absolute) != 0) + if (build_dirs_and_chdir (head, *pargc <= 1) != 0) { error (0, 0, "ignoring module %s", omodule); err = 1; @@ -1101,22 +1146,13 @@ emptydir_name () return repository; } - -/* Build all the dirs along the path to DIRS with CVS subdirs with - appropriate repositories. If ->repository is NULL, do not create a - CVSADM directory for that subdirectory; just CVS_CHDIR into it. If - check_existing_dirs is nonzero, don't create directories if they - already exist, and don't try to write adm files in directories - where we don't have write permission. We use this last option - primarily when a user has specified an absolute path for checkout - -- we will often not have permission to top-level directories, so - we shouldn't complain. */ - +/* Build all the dirs along the path to DIRS with CVS subdirs with appropriate + repositories. If ->repository is NULL, do not create a CVSADM directory + for that subdirectory; just CVS_CHDIR into it. */ static int -build_dirs_and_chdir (dirs, sticky, check_existing_dirs) +build_dirs_and_chdir (dirs, sticky) struct dir_to_build *dirs; int sticky; - int check_existing_dirs; { int retval = 0; struct dir_to_build *nextdir; @@ -1124,16 +1160,12 @@ build_dirs_and_chdir (dirs, sticky, check_existing_dirs) while (dirs != NULL) { char *dir = last_component (dirs->dirpath); - int dir_is_writeable; - if ((! check_existing_dirs) || (! isdir (dir))) + if (!dirs->just_chdir) + { mkdir_if_needed (dir); - - Subdir_Register (NULL, NULL, dir); - - /* This is an expensive call -- only make it if necessary. */ - if (check_existing_dirs) - dir_is_writeable = iswritable (dir); + Subdir_Register (NULL, NULL, dir); + } if (CVS_CHDIR (dir) < 0) { @@ -1141,14 +1173,11 @@ build_dirs_and_chdir (dirs, sticky, check_existing_dirs) retval = 1; goto out; } - - if ((dirs->repository != NULL) - && ((! check_existing_dirs) || dir_is_writeable)) + if (dirs->repository != NULL) { build_one_dir (dirs->repository, dirs->dirpath, sticky); free (dirs->repository); } - nextdir = dirs->next; free (dirs->dirpath); free (dirs); diff --git a/contrib/cvs/src/classify.c b/contrib/cvs/src/classify.c index b33c945..b0084a3 100644 --- a/contrib/cvs/src/classify.c +++ b/contrib/cvs/src/classify.c @@ -288,6 +288,14 @@ conflict: %s created independently by second party", * There is no user file, so note that it was lost and * extract a new version */ + /* Comparing the command_name against "update", in + addition to being an ugly way to operate, means + that this message does not get printed by the + server. That might be considered just a straight + bug, although there is one subtlety: that case also + gets hit when a patch fails and the client fetches + a file. I'm not sure there is currently any way + for the server to distinguish those two cases. */ if (strcmp (command_name, "update") == 0) if (!really_quiet) error (0, 0, "warning: %s was lost", finfo->fullname); @@ -367,6 +375,8 @@ conflict: %s created independently by second party", { /* There is no user file, so just get it */ + /* See comment at other "update" compare, for more + thoughts on this comparison. */ if (strcmp (command_name, "update") == 0) if (!really_quiet) error (0, 0, "warning: %s was lost", finfo->fullname); diff --git a/contrib/cvs/src/client.c b/contrib/cvs/src/client.c index aa897d5..222e7f2 100644 --- a/contrib/cvs/src/client.c +++ b/contrib/cvs/src/client.c @@ -78,8 +78,19 @@ static Key_schedule sched; #ifdef HAVE_GSSAPI +#ifdef HAVE_GSSAPI_H +#include +#endif +#ifdef HAVE_GSSAPI_GSSAPI_H #include +#endif +#ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H #include +#endif + +#ifndef HAVE_GSS_C_NT_HOSTBASED_SERVICE +#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name +#endif /* This is needed for GSSAPI encryption. */ static gss_ctx_id_t gcontext; @@ -949,17 +960,24 @@ call_in_directory (pathname, func, data) error (1, errno, "could not chdir to %s", toplevel_wd); newdir = 0; - /* Create the CVS directory at the top level if needed. - The isdir seems like an unneeded system call, but it *does* - need to be called both if the CVS_CHDIR below succeeds (e.g. - "cvs co .") or if it fails (e.g. basicb-1a in testsuite). */ + /* Create the CVS directory at the top level if needed. The + isdir seems like an unneeded system call, but it *does* + need to be called both if the CVS_CHDIR below succeeds + (e.g. "cvs co .") or if it fails (e.g. basicb-1a in + testsuite). We only need to do this for the "." case, + since the server takes care of forcing this directory to be + created in all other cases. If we don't create CVSADM + here, the call to Entries_Open below will fail. FIXME: + perhaps this means that we should change our algorithm + below that calls Create_Admin instead of having this code + here? */ if (/* I think the reposdirname_absolute case has to do with things like "cvs update /foo/bar". In any event, the code below which tries to put toplevel_repos into CVS/Repository is almost surely unsuited to the reposdirname_absolute case. */ !reposdirname_absolute - + && (strcmp (dir_name, ".") == 0) && ! isdir (CVSADM)) { char *repo; @@ -2909,19 +2927,19 @@ handle_wrapper_rcs_option (args, len) as free-form as it looks. */ p = strchr (args, ' '); if (p == NULL) - goto error; + goto handle_error; if (*++p != '-' || *++p != 'k' || *++p != ' ' || *++p != '\'') - goto error; + goto handle_error; if (strchr (p, '\'') == NULL) - goto error; + goto handle_error; /* Add server-side cvswrappers line to our wrapper list. */ wrap_add (args, 0); return; - error: + handle_error: error (0, errno, "protocol error: ignoring invalid wrappers %s", args); } @@ -3861,7 +3879,8 @@ connect_to_gserver (sock, hostinfo) sprintf (buf, "cvs@%s", hostinfo->h_name); tok_in.length = strlen (buf); tok_in.value = buf; - gss_import_name (&stat_min, &tok_in, gss_nt_service_name, &server_name); + gss_import_name (&stat_min, &tok_in, GSS_C_NT_HOSTBASED_SERVICE, + &server_name); tok_in_ptr = GSS_C_NO_BUFFER; gcontext = GSS_C_NO_CONTEXT; @@ -5442,13 +5461,16 @@ option_with_arg (option, arg) send_arg (arg); } -/* - * Send a date to the server. This will passed a string which is the - * result of Make_Date, and looks like YY.MM.DD.HH.MM.SS, where all - * the letters are single digits. The time will be GMT. getdate on - * the server can't parse that, so we turn it back into something - * which it can parse. - */ +/* Send a date to the server. The input DATE is in RCS format. + The time will be GMT. + + We then convert that to the format required in the protocol + (including the "-D" option) and send it. According to + cvsclient.texi, RFC 822/1123 format is preferred, but for now we + use the format that we always have, for + conservatism/laziness/paranoia. As far as I know all servers + support the RFC 822/1123 format, so probably there would be no + particular danger in switching. */ void client_senddate (date) @@ -5457,10 +5479,10 @@ client_senddate (date) int year, month, day, hour, minute, second; char buf[100]; - if (sscanf (date, DATEFORM, &year, &month, &day, &hour, &minute, &second) + if (sscanf (date, SDATEFORM, &year, &month, &day, &hour, &minute, &second) != 6) { - error (1, 0, "diff_client_senddate: sscanf failed on date"); + error (1, 0, "client_senddate: sscanf failed on date"); } sprintf (buf, "%d/%d/%d %d:%d:%d GMT", month, day, year, diff --git a/contrib/cvs/src/commit.c b/contrib/cvs/src/commit.c index 4aa2438..75d2e5ae 100644 --- a/contrib/cvs/src/commit.c +++ b/contrib/cvs/src/commit.c @@ -1,17 +1,17 @@ /* * Copyright (c) 1992, Brian Berliner and Jeff Polk * 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. - * + * * Commit Files - * + * * "commit" commits the present version to the RCS repository, AFTER * having done a test on conflicts. * * The call is: cvs commit [options] files... - * + * */ #include @@ -29,7 +29,7 @@ static int check_filesdoneproc PROTO ((void *callerdat, int err, char *repos, char *update_dir, List *entries)); static int checkaddfile PROTO((char *file, char *repository, char *tag, - char *options, RCSNode **rcsnode)); + char *options, RCSNode **rcsnode)); static Dtype commit_direntproc PROTO ((void *callerdat, char *dir, char *repos, char *update_dir, List *entries)); @@ -74,12 +74,13 @@ static int force_ci = 0; static int got_message; static int run_module_prog = 1; static int aflag; -static char *tag; +static char *saved_tag; static char *write_dirtag; static int write_dirnonbranch; static char *logfile; static List *mulist; -static char *message; +static List *saved_ulist; +static char *saved_message; static time_t last_register_time; static const char *const commit_usage[] = @@ -247,7 +248,7 @@ find_fileproc (callerdat, finfo) xfinfo.repository = NULL; xfinfo.rcs = NULL; - vers = Version_TS (&xfinfo, NULL, tag, NULL, 0, 0); + vers = Version_TS (&xfinfo, NULL, saved_tag, NULL, 0, 0); if (vers->ts_user == NULL && vers->vn_user != NULL && vers->vn_user[0] == '-') @@ -364,18 +365,18 @@ commit (argc, argv) #else use_editor = 0; #endif - if (message) + if (saved_message) { - free (message); - message = NULL; + free (saved_message); + saved_message = NULL; } - message = xstrdup(optarg); + saved_message = xstrdup(optarg); break; case 'r': - if (tag) - free (tag); - tag = xstrdup (optarg); + if (saved_tag) + free (saved_tag); + saved_tag = xstrdup (optarg); break; case 'l': local = 1; @@ -405,12 +406,12 @@ commit (argc, argv) argv += optind; /* numeric specified revision means we ignore sticky tags... */ - if (tag && isdigit (*tag)) + if (saved_tag && isdigit (*saved_tag)) { aflag = 1; /* strip trailing dots */ - while (tag[strlen (tag) - 1] == '.') - tag[strlen (tag) - 1] = '\0'; + while (saved_tag[strlen (saved_tag) - 1] == '.') + saved_tag[strlen (saved_tag) - 1] = '\0'; } /* some checks related to the "-F logfile" option */ @@ -419,7 +420,7 @@ commit (argc, argv) int n, logfd; struct stat statbuf; - if (message) + if (saved_message) error (1, 0, "cannot specify both a message and a log file"); /* FIXME: Why is this binary? Needs more investigation. */ @@ -429,21 +430,20 @@ commit (argc, argv) if (fstat(logfd, &statbuf) < 0) error (1, errno, "cannot find size of log file %s", logfile); - message = xmalloc (statbuf.st_size + 1); + saved_message = xmalloc (statbuf.st_size + 1); /* FIXME: Should keep reading until EOF, rather than assuming the first read gets the whole thing. */ - if ((n = read (logfd, message, statbuf.st_size + 1)) < 0) + if ((n = read (logfd, saved_message, statbuf.st_size + 1)) < 0) error (1, errno, "cannot read log message from %s", logfile); (void) close (logfd); - message[n] = '\0'; + saved_message[n] = '\0'; } #ifdef CLIENT_SUPPORT - if (client_active) + if (client_active) { - int err; struct find_data find_args; ign_setup (); @@ -458,7 +458,7 @@ commit (argc, argv) I haven't really thought about it much. Anyway, I suspect that setting it unnecessarily only causes a little unneeded network traffic. */ - find_args.force = force_ci || tag != NULL; + find_args.force = force_ci || saved_tag != NULL; err = start_recursion (find_fileproc, find_filesdoneproc, find_dirent_proc, (DIRLEAVEPROC) NULL, @@ -500,17 +500,17 @@ commit (argc, argv) * The protocol is designed this way. This is a feature. */ if (use_editor) - do_editor (".", &message, (char *)NULL, find_args.ulist); + do_editor (".", &saved_message, (char *)NULL, find_args.ulist); /* Run the user-defined script to verify/check information in *the log message */ - do_verify (message, (char *)NULL); + do_verify (saved_message, (char *)NULL); /* We always send some sort of message, even if empty. */ /* FIXME: is that true? There seems to be some code in do_editor which can leave the message NULL. */ - option_with_arg ("-m", message); + option_with_arg ("-m", saved_message); /* OK, now process all the questionable files we have been saving up. */ @@ -559,7 +559,7 @@ commit (argc, argv) send_arg("-f"); if (!run_module_prog) send_arg("-n"); - option_with_arg ("-r", tag); + option_with_arg ("-r", saved_tag); /* Sending only the names of the files which were modified, added, or removed means that the server will only do an up-to-date @@ -582,7 +582,7 @@ commit (argc, argv) send_to_server ("ci\012", 0); err = get_responses_and_close (); - if (err != 0 && use_editor && message != NULL) + if (err != 0 && use_editor && saved_message != NULL) { /* If there was an error, don't nuke the user's carefully constructed prose. This is something of a kludge; a better @@ -600,7 +600,8 @@ commit (argc, argv) fp = CVS_FOPEN (fname, "w+"); if (fp == NULL) error (1, 0, "cannot create temporary file %s", fname); - if (fwrite (message, 1, strlen (message), fp) != strlen (message)) + if (fwrite (saved_message, 1, strlen (saved_message), fp) + != strlen (saved_message)) error (1, errno, "cannot write temporary file %s", fname); if (fclose (fp) < 0) error (0, errno, "cannot close temporary file %s", fname); @@ -610,12 +611,12 @@ commit (argc, argv) } #endif - if (tag != NULL) - tag_check_valid (tag, argc, argv, local, aflag, ""); + if (saved_tag != NULL) + tag_check_valid (saved_tag, argc, argv, local, aflag, ""); /* XXX - this is not the perfect check for this */ if (argc <= 0) - write_dirtag = tag; + write_dirtag = saved_tag; wrap_setup (); @@ -651,17 +652,6 @@ commit (argc, argv) error (1, 0, "correct above errors first!"); } -#ifdef PRESERVE_PERMISSIONS_SUPPORT - if (preserve_perms) - { - /* hardlist now includes a complete index of the files - to be committed, indexed by inode. For each inode, - compile a list of the files that are linked to it, - and save this list in each file's hardlink_info node. */ - (void) walklist (hardlist, cache_hardlinks_proc, NULL); - } -#endif - /* * Run the recursion processor to commit the files */ @@ -683,7 +673,7 @@ commit (argc, argv) time_t now; (void) time (&now); - if (now == last_register_time) + if (now == last_register_time) { sleep (1); /* to avoid time-stamp races */ } @@ -713,10 +703,10 @@ classify_file_internal (finfo, vers) noexec = quiet = really_quiet = 1; /* handle specified numeric revision specially */ - if (tag && isdigit (*tag)) + if (saved_tag && isdigit (*saved_tag)) { /* If the tag is for the trunk, make sure we're at the head */ - if (numdots (tag) < 2) + if (numdots (saved_tag) < 2) { status = Classify_File (finfo, (char *) NULL, (char *) NULL, (char *) NULL, 1, aflag, vers, 0); @@ -726,7 +716,7 @@ classify_file_internal (finfo, vers) Ctype xstatus; freevers_ts (vers); - xstatus = Classify_File (finfo, tag, (char *) NULL, + xstatus = Classify_File (finfo, saved_tag, (char *) NULL, (char *) NULL, 1, aflag, vers, 0); if (xstatus == T_REMOVE_ENTRY) status = T_MODIFIED; @@ -744,7 +734,7 @@ classify_file_internal (finfo, vers) * The revision is off the main trunk; make sure we're * up-to-date with the head of the specified branch. */ - xtag = xstrdup (tag); + xtag = xstrdup (saved_tag); if ((numdots (xtag) & 1) != 0) { cp = strrchr (xtag, '.'); @@ -765,12 +755,12 @@ classify_file_internal (finfo, vers) } /* now, muck with vers to make the tag correct */ free ((*vers)->tag); - (*vers)->tag = xstrdup (tag); + (*vers)->tag = xstrdup (saved_tag); free (xtag); } } else - status = Classify_File (finfo, tag, (char *) NULL, (char *) NULL, + status = Classify_File (finfo, saved_tag, (char *) NULL, (char *) NULL, 1, 0, vers, 0); noexec = save_noexec; quiet = save_quiet; @@ -796,7 +786,7 @@ check_fileproc (callerdat, finfo) Vers_TS *vers; struct commit_info *ci; struct logfile_info *li; - + status = classify_file_internal (finfo, &vers); /* @@ -835,7 +825,7 @@ check_fileproc (callerdat, finfo) * allow the commit if timestamp is identical or if we find * an RCS_MERGE_PAT in the file. */ - if (!tag || !isdigit (*tag)) + if (!saved_tag || !isdigit (*saved_tag)) { if (vers->date) { @@ -1047,7 +1037,6 @@ warning: file `%s' seems to still contain conflict indicators", hlinfo = (struct hardlink_info *) xmalloc (sizeof (struct hardlink_info)); hlinfo->status = status; - hlinfo->links = NULL; linkp->data = (char *) hlinfo; } } @@ -1114,7 +1103,6 @@ precommit_list_proc (p, closure) /* * Callback proc for pre-commit checking */ -static List *ulist; static int precommit_proc (repository, filter) char *repository; @@ -1124,7 +1112,7 @@ precommit_proc (repository, filter) if (isabsolute (filter)) { char *s, *cp; - + s = xstrdup (filter); for (cp = s; *cp; cp++) if (isspace (*cp)) @@ -1143,7 +1131,7 @@ precommit_proc (repository, filter) run_setup (filter); run_arg (repository); - (void) walklist (ulist, precommit_list_proc, NULL); + (void) walklist (saved_ulist, precommit_list_proc, NULL); return (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY)); } @@ -1165,12 +1153,12 @@ check_filesdoneproc (callerdat, err, repos, update_dir, entries) /* find the update list for this dir */ p = findnode (mulist, update_dir); if (p != NULL) - ulist = ((struct master_lists *) p->data)->ulist; + saved_ulist = ((struct master_lists *) p->data)->ulist; else - ulist = (List *) NULL; + saved_ulist = (List *) NULL; /* skip the checks if there's nothing to do */ - if (ulist == NULL || ulist->list->next == ulist->list) + if (saved_ulist == NULL || saved_ulist->list->next == saved_ulist->list) return (err); /* run any pre-commit checks */ @@ -1238,8 +1226,9 @@ commit_fileproc (callerdat, finfo) { got_message = 1; if (use_editor) - do_editor (finfo->update_dir, &message, finfo->repository, ulist); - do_verify (message, finfo->repository); + do_editor (finfo->update_dir, &saved_message, + finfo->repository, ulist); + do_verify (saved_message, finfo->repository); } p = findnode (cilist, finfo->file); @@ -1279,7 +1268,7 @@ commit_fileproc (callerdat, finfo) error (1, 0, "internal error: no parsed RCS file"); ci->rev = RCS_whatbranch (finfo->rcs, ci->tag); err = Checkin ('A', finfo, finfo->rcs->path, ci->rev, - ci->tag, ci->options, message); + ci->tag, ci->options, saved_message); if (err != 0) { unlockrcs (finfo->rcs); @@ -1319,7 +1308,7 @@ commit_fileproc (callerdat, finfo) { err = Checkin ('M', finfo, finfo->rcs->path, ci->rev, ci->tag, - ci->options, message); + ci->options, saved_message); (void) time (&last_register_time); @@ -1331,7 +1320,7 @@ commit_fileproc (callerdat, finfo) } else if (ci->status == T_REMOVED) { - err = remove_file (finfo, ci->tag, message); + err = remove_file (finfo, ci->tag, saved_message); #ifdef SERVER_SUPPORT if (server_active) { server_scratch_entry_only (); @@ -1371,7 +1360,7 @@ out: been removed from the archive, which is not the behavior we want for our commitlog messages; we want the old version number and then "NONE." */ - + if (ci->status != T_REMOVED) { p = findnode (ulist, finfo->file); @@ -1379,7 +1368,7 @@ out: { Vers_TS *vers; struct logfile_info *li; - + (void) classify_file_internal (finfo, &vers); li = (struct logfile_info *) p->data; li->rev_new = xstrdup (vers->vn_rcs); @@ -1415,7 +1404,7 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries) got_message = 0; - Update_Logfile (repository, message, (FILE *) 0, ulist); + Update_Logfile (repository, saved_message, (FILE *) 0, ulist); /* Build the administrative files if necessary. */ { @@ -1423,11 +1412,17 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries) if (strncmp (CVSroot_directory, repository, strlen (CVSroot_directory)) != 0) - error (0, 0, "internal error: repository (%s) doesn't begin with root (%s)", repository, CVSroot_directory); + error (0, 0, + "internal error: repository (%s) doesn't begin with root (%s)", + repository, CVSroot_directory); p = repository + strlen (CVSroot_directory); if (*p == '/') ++p; - if (strcmp ("CVSROOT", p) == 0) + if (strcmp ("CVSROOT", p) == 0 + /* Check for subdirectories because people may want to create + subdirectories and list files therein in checkoutlist. */ + || strncmp ("CVSROOT/", p, strlen ("CVSROOT/")) == 0 + ) { /* "Database" might a little bit grandiose and/or vague, but "checked-out copies of administrative files, unless @@ -1435,11 +1430,21 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries) case modules.{pag,dir,db}" is verbose and excessively focused on how the database is implemented. */ + /* mkmodules requires the absolute name of the CVSROOT directory. + Remove anything after the `CVSROOT' component -- this is + necessary when committing in a subdirectory of CVSROOT. */ + char *admin_dir = xstrdup (repository); + int cvsrootlen = strlen ("CVSROOT"); + assert (admin_dir[p - repository + cvsrootlen] == '\0' + || admin_dir[p - repository + cvsrootlen] == '/'); + admin_dir[p - repository + cvsrootlen] = '\0'; + cvs_output (program_name, 0); cvs_output (" ", 1); cvs_output (command_name, 0); cvs_output (": Rebuilding administrative file database\n", 0); - mkmodules (repository); + mkmodules (admin_dir); + free (admin_dir); } } @@ -1452,7 +1457,7 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries) char *line; int line_length; size_t line_chars_allocated; - char *repository; + char *repos; line = NULL; line_chars_allocated = 0; @@ -1462,9 +1467,9 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries) /* Remove any trailing newline. */ if (line[line_length - 1] == '\n') line[--line_length] = '\0'; - repository = Name_Repository ((char *) NULL, update_dir); + repos = Name_Repository ((char *) NULL, update_dir); run_setup (line); - run_arg (repository); + run_arg (repos); cvs_output (program_name, 0); cvs_output (" ", 1); cvs_output (command_name, 0); @@ -1472,7 +1477,7 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries) run_print (stdout); cvs_output ("'\n", 0); (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); - free (repository); + free (repos); } else { @@ -1529,8 +1534,8 @@ commit_direntproc (callerdat, dir, repos, update_dir, entries) real_repos = Name_Repository (dir, update_dir); got_message = 1; if (use_editor) - do_editor (update_dir, &message, real_repos, ulist); - do_verify (message, real_repos); + do_editor (update_dir, &saved_message, real_repos, ulist); + do_verify (saved_message, real_repos); free (real_repos); return (R_PROCESS); } @@ -1622,7 +1627,7 @@ remove_file (finfo, tag, message) if (tag && !(branch = RCS_nodeisbranch (finfo->rcs, tag))) { /* a symbolic tag is specified; just remove the tag from the file */ - if ((retcode = RCS_deltag (finfo->rcs, tag)) != 0) + if ((retcode = RCS_deltag (finfo->rcs, tag)) != 0) { if (!quiet) error (0, retcode == -1 ? errno : 0, @@ -1655,7 +1660,7 @@ remove_file (finfo, tag, message) error (0, 0, "cannot find branch \"%s\".", tag); return (1); } - + branchname = RCS_getbranch (finfo->rcs, rev, 1); if (branchname == NULL) { @@ -1676,12 +1681,12 @@ remove_file (finfo, tag, message) /* Get current head revision of file. */ prev_rev = RCS_head (finfo->rcs); } - + /* if removing without a tag or a branch, then make sure the default branch is the trunk. */ if (!tag && !branch) { - if (RCS_setbranch (finfo->rcs, NULL) != 0) + if (RCS_setbranch (finfo->rcs, NULL) != 0) { error (0, 0, "cannot change branch to default for %s", finfo->fullname); @@ -1740,7 +1745,7 @@ remove_file (finfo, tag, message) if (!branch) { /* this was the head; really move it into the Attic */ - tmp = xmalloc(strlen(finfo->repository) + + tmp = xmalloc(strlen(finfo->repository) + sizeof('/') + sizeof(CVSATTIC) + sizeof('/') + @@ -1750,8 +1755,9 @@ remove_file (finfo, tag, message) omask = umask (cvsumask); (void) CVS_MKDIR (tmp, 0777); (void) umask (omask); - (void) sprintf (tmp, "%s/%s/%s%s", finfo->repository, CVSATTIC, finfo->file, RCSEXT); - + (void) sprintf (tmp, "%s/%s/%s%s", finfo->repository, CVSATTIC, + finfo->file, RCSEXT); + if (strcmp (finfo->rcs->path, tmp) != 0 && CVS_RENAME (finfo->rcs->path, tmp) == -1 && (isreadable (finfo->rcs->path) || !isreadable (tmp))) @@ -1794,7 +1800,7 @@ finaladd (finfo, rev, tag, options) char *rcs; rcs = locate_rcs (finfo->file, finfo->repository); - ret = Checkin ('A', finfo, rcs, rev, tag, options, message); + ret = Checkin ('A', finfo, rcs, rev, tag, options, saved_message); if (ret == 0) { char *tmp = xmalloc (strlen (finfo->file) + sizeof (CVSADM) @@ -1931,7 +1937,7 @@ checkaddfile (file, repository, tag, options, rcsnode) Attic. */ oldfile = xstrdup (rcs); sprintf (rcs, "%s/%s%s", repository, file, RCSEXT); - + if (strcmp (oldfile, rcs) == 0) { error (0, 0, "internal error: confused about attic for %s", @@ -2154,7 +2160,7 @@ internal error: `%s' didn't move out of the attic", retval = 1; goto out; } - } + } if (rcsnode && *rcsnode != rcsfile) { @@ -2200,7 +2206,7 @@ lock_RCS (user, rcs, rev, repository) * For a specified, numeric revision of the form "1" or "1.1", (or when * no revision is specified ""), definitely move the branch to the trunk * before locking the RCS file. - * + * * The assumption is that if there is more than one revision on the trunk, * the head points to the trunk, not a branch... and as such, it's not * necessary to move the head in this case. diff --git a/contrib/cvs/src/cvs.h b/contrib/cvs/src/cvs.h index 3a7e9e4..f8b1552 100644 --- a/contrib/cvs/src/cvs.h +++ b/contrib/cvs/src/cvs.h @@ -385,6 +385,8 @@ extern int trace; /* Show all commands */ extern int noexec; /* Don't modify disk anywhere */ extern int logoff; /* Don't write history entry */ +extern int top_level_admin; + #ifdef AUTH_SERVER_SUPPORT extern char *Pserver_Repos; /* used to check that same repos is transmitted in pserver auth and in @@ -429,6 +431,8 @@ void Subdir_Register PROTO((List *, const char *, const char *)); void Subdir_Deregister PROTO((List *, const char *, const char *)); char *Make_Date PROTO((char *rawdate)); +char *date_from_time_t PROTO ((time_t)); + char *Name_Repository PROTO((char *dir, char *update_dir)); char *Short_Repository PROTO((char *repository)); void Sanitize_Repository_Name PROTO((char *repository)); @@ -476,7 +480,6 @@ int numdots PROTO((const char *s)); char *increment_revnum PROTO ((const char *)); int compare_revnums PROTO ((const char *, const char *)); int unlink_file PROTO((const char *f)); -int link_file PROTO ((const char *from, const char *to)); int unlink_file_dir PROTO((const char *f)); int update PROTO((int argc, char *argv[])); int xcmp PROTO((const char *file1, const char *file2)); @@ -834,7 +837,7 @@ extern int patch PROTO((int argc, char **argv)); extern int release PROTO((int argc, char **argv)); extern int cvsremove PROTO((int argc, char **argv)); extern int rtag PROTO((int argc, char **argv)); -extern int status PROTO((int argc, char **argv)); +extern int cvsstatus PROTO((int argc, char **argv)); extern int cvstag PROTO((int argc, char **argv)); extern unsigned long int lookup_command_attribute PROTO((char *)); diff --git a/contrib/cvs/src/diff.c b/contrib/cvs/src/diff.c index 7a4c105..341c04c 100644 --- a/contrib/cvs/src/diff.c +++ b/contrib/cvs/src/diff.c @@ -434,7 +434,15 @@ diff_fileproc (callerdat, finfo) exists = 0; /* special handling for TAG_HEAD */ if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0) - exists = vers->vn_rcs != NULL; + { + char *head = + (vers->vn_rcs == NULL + ? NULL + : RCS_branch_head (vers->srcfile, vers->vn_rcs)); + exists = head != NULL; + if (head != NULL) + free (head); + } else { Vers_TS *xvers; @@ -814,7 +822,9 @@ diff_file_nodiff (finfo, vers, empty_file) { /* special handling for TAG_HEAD */ if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0) - use_rev1 = xstrdup (vers->vn_rcs); + use_rev1 = ((vers->vn_rcs == NULL || vers->srcfile == NULL) + ? NULL + : RCS_branch_head (vers->srcfile, vers->vn_rcs)); else { xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1, 1, 0); @@ -827,7 +837,9 @@ diff_file_nodiff (finfo, vers, empty_file) { /* special handling for TAG_HEAD */ if (diff_rev2 && strcmp (diff_rev2, TAG_HEAD) == 0) - use_rev2 = xstrdup (vers->vn_rcs); + use_rev2 = ((vers->vn_rcs == NULL || vers->srcfile == NULL) + ? NULL + : RCS_branch_head (vers->srcfile, vers->vn_rcs)); else { xvers = Version_TS (finfo, NULL, diff_rev2, diff_date2, 1, 0); diff --git a/contrib/cvs/src/edit.c b/contrib/cvs/src/edit.c index 6c6f040..aa0f4c4 100644 --- a/contrib/cvs/src/edit.c +++ b/contrib/cvs/src/edit.c @@ -521,6 +521,26 @@ unedit_fileproc (callerdat, finfo) if (node != NULL) { entdata = (Entnode *) node->data; + if (baserev == NULL) + { + /* This can only happen if the CVS/Baserev file got + corrupted. We suspect it might be possible if the + user interrupts CVS, although I haven't verified + that. */ + error (0, 0, "%s not mentioned in %s", finfo->fullname, + CVSADM_BASEREV); + + /* Since we don't know what revision the file derives from, + keeping it around would be asking for trouble. */ + if (unlink_file (finfo->file) < 0) + error (0, errno, "cannot remove %s", finfo->fullname); + + /* This is cheesy, in a sense; why shouldn't we do the + update for the user? However, doing that would require + contacting the server, so maybe this is OK. */ + error (0, 0, "run update to complete the unedit"); + return 0; + } Register (finfo->entries, finfo->file, baserev, entdata->timestamp, entdata->options, entdata->tag, entdata->date, entdata->conflict); diff --git a/contrib/cvs/src/error.c b/contrib/cvs/src/error.c index cb69bde..9dcc162 100644 --- a/contrib/cvs/src/error.c +++ b/contrib/cvs/src/error.c @@ -89,7 +89,15 @@ error_exit PROTO ((void)) thing for the server, whether the normal server_active (child process) case or the error_use_protocol (parent process) case. The one exception is that STATUS nonzero for error_use_protocol probably doesn't work yet; - in that case still need to use the pending_error machinery in server.c. */ + in that case still need to use the pending_error machinery in server.c. + + error() does not molest errno; some code (e.g. Entries_Open) depends + on being able to say something like: + error (0, 0, "foo"); + error (0, errno, "bar"); + + */ + /* VARARGS */ void #if defined (HAVE_VPRINTF) && defined (__STDC__) @@ -102,6 +110,9 @@ error (status, errnum, message, va_alist) va_dcl #endif { + /* Prevent strtoul (via int_vasprintf) from clobbering it. */ + int save_errno = errno; + #ifdef HAVE_VPRINTF if (message[0] != '\0') { @@ -211,6 +222,7 @@ error (status, errnum, message, va_alist) if (status) error_exit (); + errno = save_errno; } /* Print the program name and error message MESSAGE, which is a printf-style diff --git a/contrib/cvs/src/fileattr.c b/contrib/cvs/src/fileattr.c index a5abea0..4042d2a 100644 --- a/contrib/cvs/src/fileattr.c +++ b/contrib/cvs/src/fileattr.c @@ -111,6 +111,10 @@ fileattr_read () Node *newnode; p = strchr (line, '\t'); + if (p == NULL) + error (1, 0, + "file attribute database corruption: tab missing in %s", + fname); *p++ = '\0'; newnode = getnode (); newnode->type = FILEATTR; @@ -130,6 +134,10 @@ fileattr_read () /* Currently nothing to skip here, but for future expansion, ignore anything located here. */ p = strchr (line, '\t'); + if (p == NULL) + error (1, 0, + "file attribute database corruption: tab missing in %s", + fname); ++p; fileattr_default_attrs = xstrdup (p); } diff --git a/contrib/cvs/src/filesubr.c b/contrib/cvs/src/filesubr.c index 0ccc3df..1c24b2f 100644 --- a/contrib/cvs/src/filesubr.c +++ b/contrib/cvs/src/filesubr.c @@ -415,29 +415,6 @@ rename_file (from, to) } /* - * link a file, if possible. Warning: the Windows NT version of this - * function just copies the file, so only use this function in ways - * that can deal with either a link or a copy. - */ -int -link_file (from, to) - const char *from; - const char *to; -{ - if (trace) -#ifdef SERVER_SUPPORT - (void) fprintf (stderr, "%c-> link(%s,%s)\n", - (server_active) ? 'S' : ' ', from, to); -#else - (void) fprintf (stderr, "-> link(%s,%s)\n", from, to); -#endif - if (noexec) - return (0); - - return (link (from, to)); -} - -/* * unlink a file, if possible. */ int @@ -770,7 +747,9 @@ xreadlink (link) const char *link; { char *file = NULL; - int buflen = BUFSIZ; + char *tfile; + int buflen = 128; + int link_name_len; if (!islink (link)) return NULL; @@ -781,18 +760,21 @@ xreadlink (link) do { file = xrealloc (file, buflen); - errno = 0; - readlink (link, file, buflen); + link_name_len = readlink (link, file, buflen - 1); buflen *= 2; } - while (errno == ENAMETOOLONG); + while (link_name_len < 0 && errno == ENAMETOOLONG); - if (errno) + if (link_name_len < 0) error (1, errno, "cannot readlink %s", link); - return file; -} + file[link_name_len] = '\0'; + tfile = xstrdup (file); + free (file); + + return tfile; +} /* Return a pointer into PATH's last component. */ diff --git a/contrib/cvs/src/hardlink.c b/contrib/cvs/src/hardlink.c index 51bd2a6..b279aa9 100644 --- a/contrib/cvs/src/hardlink.c +++ b/contrib/cvs/src/hardlink.c @@ -41,96 +41,6 @@ List *hardlist; /* Record hardlink information for working files */ char *working_dir; /* The top-level working directory, used for constructing full pathnames. */ -/* For check_link_proc: list all of the files named in an inode list. */ -static int -list_files_proc (node, vstrp) - Node *node; - void *vstrp; -{ - char **strp, *file; - int len; - - /* Get the file's basename. This is because -- VERY IMPORTANT -- - the `hardlinks' field is presently defined only to include links - within a directory. So the hardlinks field might be `foo' or - `mumble grump flink', but not `foo bar com/baz' or `wham ../bam - ../thank/you'. Someday it would be nice to extend this to - permit cross-directory links, but the issues involved are - hideous. */ - - file = strrchr (node->key, '/'); - if (file) - ++file; - else - file = node->key; - - /* Is it safe to cast vstrp to (char **) here, and then play with - the contents? I think so, since vstrp will have started out - a char ** to begin with, so we should not have alignment bugs. */ - strp = (char **) vstrp; - len = (*strp == NULL ? 0 : strlen (*strp)); - *strp = (char *) xrealloc (*strp, len + strlen (file) + 2); - if (*strp == NULL) - { - error (0, errno, "could not allocate memory"); - return 1; - } - if (sprintf (*strp + len, "%s ", file) < 0) - { - error (0, errno, "could not compile file list"); - return 1; - } - - return 0; -} - -/* Set the link field of each hardlink_info node to `data', which is a - list of linked files. */ -static int -set_hardlink_field_proc (node, data) - Node *node; - void *data; -{ - struct hardlink_info *hlinfo = (struct hardlink_info *) node->data; - hlinfo->links = xstrdup ((char *) data); - - return 0; -} - -/* For each file being checked in, compile a list of the files linked - to it, and cache the list in the file's hardlink_info field. */ -int -cache_hardlinks_proc (node, data) - Node *node; - void *data; -{ - List *inode_links; - char *p, *linked_files = NULL; - int err; - - inode_links = (List *) node->data; - - /* inode->data is a list of hardlink_info structures: all the - files linked to this inode. We compile a string of each file - named in this list, in alphabetical order, separated by spaces. - Then store this string in the `links' field of each - hardlink_info structure, so that RCS_checkin can easily add - it to the `hardlinks' field of a new delta node. */ - - sortlist (inode_links, fsortcmp); - err = walklist (inode_links, list_files_proc, &linked_files); - if (err) - return err; - - /* Trim trailing whitespace. */ - p = linked_files + strlen(linked_files) - 1; - while (p > linked_files && isspace (*p)) - *p-- = '\0'; - - err = walklist (inode_links, set_hardlink_field_proc, linked_files); - return err; -} - /* Return a pointer to FILEPATH's node in the hardlist. This means looking up its inode, retrieving the list of files linked to that inode, and then looking up FILE in that list. If the file doesn't @@ -237,26 +147,28 @@ update_hardlink_info (file) hlinfo = (struct hardlink_info *) n->data; hlinfo->status = T_UPTODATE; hlinfo->checked_out = 1; - hlinfo->links = NULL; } -/* Return a string listing all the files known to be linked to FILE in +/* Return a List with all the files known to be linked to FILE in the working directory. Used by special_file_mismatch, to determine - whether it is safe to merge two files. */ -char * -list_files_linked_to (file) - const char *file; + whether it is safe to merge two files. + + FIXME: What is the memory allocation for the return value? We seem + to sometimes allocate a new list (getlist() call below) and sometimes + return an existing list (where we return n->data). */ +List * +list_linked_files_on_disk (file) + char *file; { - char *inodestr, *filelist, *path; + char *inodestr, *path; struct stat sb; Node *n; - int err; /* If hardlist is NULL, we have not been doing an operation that would permit us to know anything about the file's hardlinks - (cvs update, cvs commit, etc). Return an empty string. */ + (cvs update, cvs commit, etc). Return an empty list. */ if (hardlist == NULL) - return xstrdup (""); + return getlist(); /* Get the full pathname of file (assuming the working directory) */ if (file[0] == '/') @@ -288,11 +200,107 @@ list_files_linked_to (file) n = findnode (hardlist, inodestr); sortlist ((List *) n->data, fsortcmp); - filelist = NULL; - err = walklist ((List *) n->data, list_files_proc, &filelist); - if (err) - error (1, 0, "cannot get list of hardlinks for %s", file); - free (inodestr); - return filelist; + return (List *) n->data; } + +/* Compare the files in the `key' fields of two lists, returning 1 if + the lists are equivalent and 0 otherwise. + + Only the basenames of each file are compared. This is an awful hack + that exists because list_linked_files_on_disk returns full paths + and the `hardlinks' structure of a RCSVers node contains only + basenames. That in turn is a result of the awful hack that only + basenames are stored in the RCS file. If anyone ever solves the + problem of correctly managing cross-directory hardlinks, this + function (along with most functions in this file) must be fixed. */ + +int +compare_linkage_lists (links1, links2) + List *links1; + List *links2; +{ + Node *n1, *n2; + char *p1, *p2; + + sortlist (links1, fsortcmp); + sortlist (links2, fsortcmp); + + n1 = links1->list->next; + n2 = links2->list->next; + + while (n1 != links1->list && n2 != links2->list) + { + /* Get the basenames of both files. */ + p1 = strrchr (n1->key, '/'); + if (p1 == NULL) + p1 = n1->key; + else + ++p1; + + p2 = strrchr (n2->key, '/'); + if (p2 == NULL) + p2 = n2->key; + else + ++p2; + + /* Compare the files' basenames. */ + if (strcmp (p1, p2) != 0) + return 0; + + n1 = n1->next; + n2 = n2->next; + } + + /* At this point we should be at the end of both lists; if not, + one file has more links than the other, and return 1. */ + return (n1 == links1->list && n2 == links2->list); +} + +/* Find a checked-out file in a list of filenames. Used by RCS_checkout + when checking out a new hardlinked file, to decide whether this file + can be linked to any others that already exist. The return value + is not currently used. */ + +int +find_checkedout_proc (node, data) + Node *node; + void *data; +{ + Node **uptodate = (Node **) data; + Node *link; + char *dir = xgetwd(); + char *path; + struct hardlink_info *hlinfo; + + /* If we have already found a file, don't do anything. */ + if (*uptodate != NULL) + return 0; + + /* Look at this file in the hardlist and see whether the checked_out + field is 1, meaning that it has been checked out during this CVS run. */ + path = (char *) + xmalloc (sizeof(char) * (strlen (dir) + strlen (node->key) + 2)); + sprintf (path, "%s/%s", dir, node->key); + link = lookup_file_by_inode (path); + free (path); + free (dir); + + if (link == NULL) + { + /* We haven't seen this file -- maybe it hasn't been checked + out yet at all. */ + return 0; + } + + hlinfo = (struct hardlink_info *) link->data; + if (hlinfo->checked_out) + { + /* This file has been checked out recently, so it's safe to + link to it. */ + *uptodate = link; + } + + return 0; +} + diff --git a/contrib/cvs/src/hardlink.h b/contrib/cvs/src/hardlink.h index cce3f33..f9df344 100644 --- a/contrib/cvs/src/hardlink.h +++ b/contrib/cvs/src/hardlink.h @@ -21,13 +21,13 @@ struct hardlink_info { Ctype status; /* as returned from Classify_File() */ int checked_out; /* has this file been checked out lately? */ - char *links; /* contents of `hardlinks' RCS field */ }; extern List *hardlist; extern char *working_dir; -int cache_hardlinks_proc PROTO ((Node *, void *)); Node *lookup_file_by_inode PROTO ((const char *)); void update_hardlink_info PROTO ((const char *)); -char *list_files_linked_to PROTO ((const char *)); +List *list_linked_files_on_disk PROTO ((char *)); +int compare_linkage_lists PROTO ((List *, List *)); +int find_checkedout_proc PROTO ((Node *, void *)); diff --git a/contrib/cvs/src/history.c b/contrib/cvs/src/history.c index 223e5a7..8f1e254 100644 --- a/contrib/cvs/src/history.c +++ b/contrib/cvs/src/history.c @@ -200,7 +200,6 @@ static int accept_hrec PROTO((struct hrec * hr, struct hrec * lr)); static int select_hrec PROTO((struct hrec * hr)); static int sort_order PROTO((const PTR l, const PTR r)); static int within PROTO((char *find, char *string)); -static time_t date_and_time PROTO((char *date_str)); static void expand_modules PROTO((void)); static void read_hrecs PROTO((char *fname)); static void report_hrecs PROTO((void)); @@ -242,8 +241,8 @@ static char *tz_name = "+0000"; static char *since_rev; static char *since_tag; static char *backto; -/* -D option, or 0 if not specified. */ -static time_t since_date; +/* -D option, or 0 if not specified. RCS format. */ +static char * since_date; static struct hrec *last_since_tag; static struct hrec *last_backto; @@ -364,18 +363,6 @@ sort_order (l, r) return (left->idx - right->idx); } -static time_t -date_and_time (date_str) - char *date_str; -{ - time_t t; - - t = get_date (date_str, (struct timeb *) NULL); - if (t == (time_t) - 1) - error (1, 0, "Can't parse date/time: %s", date_str); - return (t); -} - int history (argc, argv) int argc; @@ -432,14 +419,16 @@ history (argc, argv) error (0, 0, "date overriding rev/tag/backto"); *since_rev = *since_tag = *backto = '\0'; } - since_date = date_and_time (optarg); + since_date = Make_Date (optarg); break; case 'b': /* Since specified file/Repos */ if (since_date || *since_rev || *since_tag) { error (0, 0, "backto overriding date/rev/tag"); *since_rev = *since_tag = '\0'; - since_date = 0; + if (since_date != NULL) + free (since_date); + since_date = NULL; } free (backto); backto = xstrdup (optarg); @@ -461,7 +450,9 @@ history (argc, argv) { error (0, 0, "rev overriding date/tag/backto"); *since_tag = *backto = '\0'; - since_date = 0; + if (since_date != NULL) + free (since_date); + since_date = NULL; } free (since_rev); since_rev = xstrdup (optarg); @@ -471,7 +462,9 @@ history (argc, argv) { error (0, 0, "tag overriding date/marker/file/repos"); *since_rev = *backto = '\0'; - since_date = 0; + if (since_date != NULL) + free (since_date); + since_date = NULL; } free (since_tag); since_tag = xstrdup (optarg); @@ -564,7 +557,7 @@ history (argc, argv) if (histfile) send_arg("-X"); if (since_date) - option_with_arg ("-D", asctime (gmtime (&since_date))); + client_senddate (since_date); if (backto[0] != '\0') option_with_arg ("-b", backto); for (f1 = file_list; f1 < &file_list[file_count]; ++f1) @@ -683,6 +676,8 @@ history (argc, argv) qsort ((PTR) hrec_head, hrec_count, sizeof (struct hrec), sort_order); report_hrecs (); free (fname); + if (since_date != NULL) + free (since_date); free (since_rev); free (since_tag); free (backto); @@ -1157,7 +1152,7 @@ select_hrec (hr) /* "Since" checking: The argument parser guarantees that only one of the * following four choices is set: * - * 1. If "since_date" is set, it contains a Unix time_t specified on the + * 1. If "since_date" is set, it contains the date specified on the * command line. hr->date fields earlier than "since_date" are ignored. * 2. If "since_rev" is set, it contains either an RCS "dotted" revision * number (which is of limited use) or a symbolic TAG. Each RCS file @@ -1177,8 +1172,12 @@ select_hrec (hr) */ if (since_date) { - if (hr->date < since_date) + char *ourdate = date_from_time_t (hr->date); + + if (RCS_datecmp (ourdate, since_date) < 0) return (0); + + free (ourdate); } else if (*since_rev) { diff --git a/contrib/cvs/src/import.c b/contrib/cvs/src/import.c index d79a10e..77c617a 100644 --- a/contrib/cvs/src/import.c +++ b/contrib/cvs/src/import.c @@ -20,8 +20,6 @@ #include "savecwd.h" #include -#define FILE_HOLDER ".#cvsxxx" - static char *get_comment PROTO((char *user)); static int add_rev PROTO((char *message, RCSNode *rcs, char *vfile, char *vers)); @@ -655,39 +653,15 @@ add_rev (message, rcs, vfile, vers) RCS_rewrite (rcs, NULL, NULL); } tocvsPath = wrap_tocvs_process_file (vfile); - if (tocvsPath == NULL) - { - /* We play with hard links rather than passing -u to ci to avoid - expanding RCS keywords (see test 106.5 in sanity.sh). */ - if (link_file (vfile, FILE_HOLDER) < 0) - { - if (errno == EEXIST) - { - (void) unlink_file (FILE_HOLDER); - (void) link_file (vfile, FILE_HOLDER); - } - else - { - ierrno = errno; - fperror (logfp, 0, ierrno, - "ERROR: cannot create link to %s", vfile); - error (0, ierrno, "ERROR: cannot create link to %s", vfile); - return (1); - } - } - } status = RCS_checkin (rcs, tocvsPath == NULL ? vfile : tocvsPath, message, vbranch, - (RCS_FLAGS_QUIET + (RCS_FLAGS_QUIET | RCS_FLAGS_KEEPFILE | (use_file_modtime ? RCS_FLAGS_MODTIME : 0))); ierrno = errno; - if (tocvsPath == NULL) - rename_file (FILE_HOLDER, vfile); - else - if (unlink_file_dir (tocvsPath) < 0) - error (0, errno, "cannot remove %s", tocvsPath); + if ((tocvsPath != NULL) && (unlink_file_dir (tocvsPath) < 0)) + error (0, errno, "cannot remove %s", tocvsPath); if (status) { diff --git a/contrib/cvs/src/main.c b/contrib/cvs/src/main.c index 9465be6..68513df 100644 --- a/contrib/cvs/src/main.c +++ b/contrib/cvs/src/main.c @@ -41,6 +41,12 @@ int quiet = 0; int trace = 0; int noexec = 0; int logoff = 0; + +/* Set if we should be writing CVSADM directories at top level. At + least for now we'll make the default be off (the CVS 1.9, not CVS + 1.9.2, behavior). */ +int top_level_admin = 0; + mode_t cvsumask = UMASK_DFLT; char *CurDir; @@ -108,7 +114,7 @@ static const struct cmd { "rdiff", "patch", "pa", patch }, { "release", "re", "rel", release }, { "remove", "rm", "delete", cvsremove }, - { "status", "st", "stat", status }, + { "status", "st", "stat", cvsstatus }, { "rtag", "rt", "rfreeze", rtag }, { "tag", "ta", "freeze", cvstag }, { "unedit", NULL, NULL, unedit }, @@ -281,6 +287,10 @@ lookup_command_attribute (cmd_name) } + /* The following commands do not use a checked-out working + directory. We conservatively assume that everything else does. + Feel free to add to this list if you are _certain_ something + something doesn't use the WD. */ if ((strcmp (cmd_name, "checkout") != 0) && (strcmp (cmd_name, "init") != 0) && (strcmp (cmd_name, "login") != 0) && @@ -296,8 +306,10 @@ lookup_command_attribute (cmd_name) /* The following commands do not modify the repository; we conservatively assume that everything else does. Feel free to add to this list if you are _certain_ something is safe. */ - if ((strcmp (cmd_name, "checkout") != 0) && + if ((strcmp (cmd_name, "annotate") != 0) && + (strcmp (cmd_name, "checkout") != 0) && (strcmp (cmd_name, "diff") != 0) && + (strcmp (cmd_name, "rdiff") != 0) && (strcmp (cmd_name, "update") != 0) && (strcmp (cmd_name, "history") != 0) && (strcmp (cmd_name, "editors") != 0) && @@ -967,20 +979,37 @@ char * Make_Date (rawdate) char *rawdate; { - struct tm *ftm; time_t unixtime; - char date[MAXDATELEN]; - char *ret; unixtime = get_date (rawdate, (struct timeb *) NULL); if (unixtime == (time_t) - 1) error (1, 0, "Can't parse date/time: %s", rawdate); + return date_from_time_t (unixtime); +} + +/* Convert a time_t to an RCS format date. This is mainly for the + use of "cvs history", because the CVSROOT/history file contains + time_t format dates; most parts of CVS will want to avoid using + time_t's directly, and instead use RCS_datecmp, Make_Date, &c. + Assuming that the time_t is in GMT (as it generally should be), + then the result will be in GMT too. + + Returns a newly malloc'd string. */ + +char * +date_from_time_t (unixtime) + time_t unixtime; +{ + struct tm *ftm; + char date[MAXDATELEN]; + char *ret; ftm = gmtime (&unixtime); if (ftm == NULL) /* This is a system, like VMS, where the system clock is in local time. Hopefully using localtime here matches the "zero timezone" - hack I added to get_date. */ + hack I added to get_date (get_date of course being the relevant + issue for Make_Date, and for history.c too I think). */ ftm = localtime (&unixtime); (void) sprintf (date, DATEFORM, diff --git a/contrib/cvs/src/mkmodules.c b/contrib/cvs/src/mkmodules.c index c3c530d..e716222 100644 --- a/contrib/cvs/src/mkmodules.c +++ b/contrib/cvs/src/mkmodules.c @@ -283,6 +283,11 @@ static const char *const config_contents[] = { "# Set `PreservePermissions' to `yes' to save file status information\n", "# in the repository.\n", "#PreservePermissions=no\n", + "\n", + "# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top\n", + "# level of the new working directory when using the `cvs checkout'\n", + "# command.\n", + "#TopLevelAdmin=no\n", NULL }; diff --git a/contrib/cvs/src/options.h.in b/contrib/cvs/src/options.h.in index 144980e..67e8c40 100644 --- a/contrib/cvs/src/options.h.in +++ b/contrib/cvs/src/options.h.in @@ -15,13 +15,12 @@ * or the configure script directly. Sorry. */ -/* - * For portability and heterogeneity reasons, CVS is shipped by - * default using my own text-file version of the ndbm database library - * in the src/myndbm.c file. If you want better performance and are - * not concerned about heterogeneous hosts accessing your modules - * file, turn this option off. - */ +/* By default, CVS stores its modules and other such items in flat + text files (MY_NDBM enables this). Turning off MY_NDBM causes CVS + to look for a system-supplied ndbm database library and use it + instead. That may speed things up, but the default setting + generally works fine too. */ + #ifndef MY_NDBM #define MY_NDBM #endif diff --git a/contrib/cvs/src/parseinfo.c b/contrib/cvs/src/parseinfo.c index a8a1b4a..9847ab9 100644 --- a/contrib/cvs/src/parseinfo.c +++ b/contrib/cvs/src/parseinfo.c @@ -346,6 +346,18 @@ warning: this CVS does not support PreservePermissions"); goto error_return; } } + else if (strcmp (line, "TopLevelAdmin") == 0) + { + if (strcmp (p, "no") == 0) + top_level_admin = 0; + else if (strcmp (p, "yes") == 0) + top_level_admin = 1; + else + { + error (0, 0, "unrecognized value '%s' for TopLevelAdmin", p); + goto error_return; + } + } else { /* We may be dealing with a keyword which was added in a diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c index 89af760..951736e 100644 --- a/contrib/cvs/src/rcs.c +++ b/contrib/cvs/src/rcs.c @@ -81,6 +81,9 @@ static void free_rcsnode_contents PROTO((RCSNode *)); static void free_rcsvers_contents PROTO((RCSVers *)); static void rcsvers_delproc PROTO((Node * p)); static char *translate_symtag PROTO((RCSNode *, const char *)); +static char *RCS_addbranch PROTO ((RCSNode *, const char *)); +static char *truncate_revnum_in_place PROTO ((char *)); +static char *truncate_revnum PROTO ((const char *)); static char *printable_date PROTO((const char *)); static char *escape_keyword_value PROTO ((const char *, int *)); static void expand_keywords PROTO((RCSNode *, RCSVers *, const char *, @@ -563,7 +566,9 @@ RCS_reparsercsfile (rdata, pfp, rcsbufp) key, rcsfile); free (rdata->desc); } - rdata->desc = rcsbuf_valcopy (&rcsbuf, value, 0, (size_t *) NULL); + /* Don't need to rcsbuf_valcopy `value' because + getdelta already did that. */ + rdata->desc = xstrdup (value); } rdata->delta_pos = rcsbuf_ftell (&rcsbuf); @@ -799,6 +804,9 @@ free_rcsnode_contents (rnode) /* free_rcsvers_contents -- free up the contents of an RCSVers node, but also free the pointer to the node itself. */ +/* Note: The `hardlinks' list is *not* freed, since it is merely a + pointer into the `hardlist' structure (defined in hardlink.c), and + that structure is freed elsewhere in the program. */ static void free_rcsvers_contents (rnode) @@ -1281,6 +1289,480 @@ rcsbuf_getkey (rcsbuf, keyp, valp) #undef my_whitespace } +/* TODO: Eliminate redundant code in rcsbuf_getkey, rcsbuf_getid, + rcsbuf_getstring, rcsbuf_getword. These last three functions were + all created by hacking monstrous swaths of code from rcsbuf_getkey, + and some engineering would make the code easier to read and + maintain. + + Note that the extreme hair in rcsbuf_getkey is because profiling + statistics show that it was worth it. + + We probably could be processing "hardlinks" by first calling + rcsbuf_getkey, and breaking up the value afterwards; the code to + break it up would not need to be hacked for speed. This would + remove the need for rcsbuf_getword, rcsbuf_getid, and + rcsbuf_getstring, as the other calls are easy to remove. */ + +/* Read an `id' (in the sense of rcsfile(5)) from RCSBUF, and store in + IDP. */ + +static int +rcsbuf_getid (rcsbuf, idp) + struct rcsbuffer *rcsbuf; + char **idp; +{ + register const char * const my_spacetab = spacetab; + register char *ptr, *ptrend; + char c; + +#define my_whitespace(c) (my_spacetab[(unsigned char)c] != 0) + + rcsbuf->vlen = 0; + rcsbuf->at_string = 0; + rcsbuf->embedded_at = 0; + + ptr = rcsbuf->ptr; + ptrend = rcsbuf->ptrend; + + /* Sanity check. */ + if (ptr < rcsbuf_buffer || ptr > rcsbuf_buffer + rcsbuf_buffer_size) + abort (); + + /* If the pointer is more than RCSBUF_BUFSIZE bytes into the + buffer, move back to the start of the buffer. This keeps the + buffer from growing indefinitely. */ + if (ptr - rcsbuf_buffer >= RCSBUF_BUFSIZE) + { + int len; + + len = ptrend - ptr; + + /* Sanity check: we don't read more than RCSBUF_BUFSIZE bytes + at a time, so we can't have more bytes than that past PTR. */ + if (len > RCSBUF_BUFSIZE) + abort (); + + /* Update the POS field, which holds the file offset of the + first byte in the RCSBUF_BUFFER buffer. */ + rcsbuf->pos += ptr - rcsbuf_buffer; + + memcpy (rcsbuf_buffer, ptr, len); + ptr = rcsbuf_buffer; + ptrend = ptr + len; + rcsbuf->ptrend = ptrend; + } + + /* Skip leading whitespace. */ + + while (1) + { + if (ptr >= ptrend) + { + ptr = rcsbuf_fill (rcsbuf, ptr, (char **) NULL, (char **) NULL); + if (ptr == NULL) + return 0; + ptrend = rcsbuf->ptrend; + } + + c = *ptr; + if (! my_whitespace (c)) + break; + + ++ptr; + } + + /* We've found the start of the key. */ + + *idp = ptr; + + if (c != ';') + { + while (1) + { + ++ptr; + if (ptr >= ptrend) + { + ptr = rcsbuf_fill (rcsbuf, ptr, idp, (char **) NULL); + if (ptr == NULL) + error (1, 0, "EOF in key in RCS file %s", + rcsbuf->filename); + ptrend = rcsbuf->ptrend; + } + c = *ptr; + if (c == ';' || my_whitespace (c)) + break; + } + } + + /* Here *IDP points to the id in the buffer, C is the character + we found at the end of the key, and PTR points to the location in + the buffer where we found C. We may not set *PTR to \0, because + it may overwrite a terminating semicolon. The calling function + must copy and terminate the id on its own. */ + + rcsbuf->ptr = ptr; + return 1; + +#undef my_whitespace +} + +/* Read an RCS @-delimited string. Store the result in STRP. */ + +static int +rcsbuf_getstring (rcsbuf, strp) + struct rcsbuffer *rcsbuf; + char **strp; +{ + register const char * const my_spacetab = spacetab; + register char *ptr, *ptrend; + char *pat; + size_t vlen; + char c; + +#define my_whitespace(c) (my_spacetab[(unsigned char)c] != 0) + + rcsbuf->vlen = 0; + rcsbuf->at_string = 0; + rcsbuf->embedded_at = 0; + + ptr = rcsbuf->ptr; + ptrend = rcsbuf->ptrend; + + /* Sanity check. */ + if (ptr < rcsbuf_buffer || ptr > rcsbuf_buffer + rcsbuf_buffer_size) + abort (); + + /* If the pointer is more than RCSBUF_BUFSIZE bytes into the + buffer, move back to the start of the buffer. This keeps the + buffer from growing indefinitely. */ + if (ptr - rcsbuf_buffer >= RCSBUF_BUFSIZE) + { + int len; + + len = ptrend - ptr; + + /* Sanity check: we don't read more than RCSBUF_BUFSIZE bytes + at a time, so we can't have more bytes than that past PTR. */ + if (len > RCSBUF_BUFSIZE) + abort (); + + /* Update the POS field, which holds the file offset of the + first byte in the RCSBUF_BUFFER buffer. */ + rcsbuf->pos += ptr - rcsbuf_buffer; + + memcpy (rcsbuf_buffer, ptr, len); + ptr = rcsbuf_buffer; + ptrend = ptr + len; + rcsbuf->ptrend = ptrend; + } + + /* Skip leading whitespace. */ + + while (1) + { + if (ptr >= ptrend) + { + ptr = rcsbuf_fill (rcsbuf, ptr, (char **) NULL, (char **) NULL); + if (ptr == NULL) + error (1, 0, "unexpected end of file reading %s", + rcsbuf->filename); + ptrend = rcsbuf->ptrend; + } + + c = *ptr; + if (! my_whitespace (c)) + break; + + ++ptr; + } + + /* PTR should now point to the start of a string. */ + if (c != '@') + error (1, 0, "expected @-string at `%c' in %s", c, rcsbuf->filename); + + /* Optimize the common case of a value composed of a single + '@' string. */ + + rcsbuf->at_string = 1; + + ++ptr; + + *strp = ptr; + + while (1) + { + while ((pat = memchr (ptr, '@', ptrend - ptr)) == NULL) + { + /* Note that we pass PTREND as the PTR value to + rcsbuf_fill, so that we will wind up setting PTR to + the location corresponding to the old PTREND, so + that we don't search the same bytes again. */ + ptr = rcsbuf_fill (rcsbuf, ptrend, NULL, strp); + if (ptr == NULL) + error (1, 0, + "EOF while looking for end of string in RCS file %s", + rcsbuf->filename); + ptrend = rcsbuf->ptrend; + } + + /* Handle the special case of an '@' right at the end of + the known bytes. */ + if (pat + 1 >= ptrend) + { + /* Note that we pass PAT, not PTR, here. */ + pat = rcsbuf_fill (rcsbuf, pat, NULL, strp); + if (pat == NULL) + { + /* EOF here is OK; it just means that the last + character of the file was an '@' terminating a + value for a key type which does not require a + trailing ';'. */ + pat = rcsbuf->ptrend - 1; + + } + ptrend = rcsbuf->ptrend; + + /* Note that the value of PTR is bogus here. This is + OK, because we don't use it. */ + } + + if (pat + 1 >= ptrend || pat[1] != '@') + break; + + /* We found an '@' pair in the string. Keep looking. */ + ++rcsbuf->embedded_at; + ptr = pat + 2; + } + + /* Here PAT points to the final '@' in the string. */ + + *pat = '\0'; + + vlen = pat - *strp; + if (vlen == 0) + *strp = NULL; + rcsbuf->vlen = vlen; + rcsbuf->ptr = pat + 1; + + return 1; + +#undef my_whitespace +} + +/* Read an RCS `word', in the sense of rcsfile(5) (an id, a num, a + @-delimited string, or `:'). Store the result in WORDP. If a + `;' is reached without reading any text, the result is NULL. */ + +static int +rcsbuf_getword (rcsbuf, wordp) + struct rcsbuffer *rcsbuf; + char **wordp; +{ + register const char * const my_spacetab = spacetab; + register char *ptr, *ptrend; + char c; + +#define my_whitespace(c) (my_spacetab[(unsigned char)c] != 0) + + rcsbuf->vlen = 0; + rcsbuf->at_string = 0; + rcsbuf->embedded_at = 0; + + ptr = rcsbuf->ptr; + ptrend = rcsbuf->ptrend; + + /* Sanity check. */ + if (ptr < rcsbuf_buffer || ptr > rcsbuf_buffer + rcsbuf_buffer_size) + abort (); + + /* If the pointer is more than RCSBUF_BUFSIZE bytes into the + buffer, move back to the start of the buffer. This keeps the + buffer from growing indefinitely. */ + if (ptr - rcsbuf_buffer >= RCSBUF_BUFSIZE) + { + int len; + + len = ptrend - ptr; + + /* Sanity check: we don't read more than RCSBUF_BUFSIZE bytes + at a time, so we can't have more bytes than that past PTR. */ + if (len > RCSBUF_BUFSIZE) + abort (); + + /* Update the POS field, which holds the file offset of the + first byte in the RCSBUF_BUFFER buffer. */ + rcsbuf->pos += ptr - rcsbuf_buffer; + + memcpy (rcsbuf_buffer, ptr, len); + ptr = rcsbuf_buffer; + ptrend = ptr + len; + rcsbuf->ptrend = ptrend; + } + + /* Skip leading whitespace. */ + + while (1) + { + if (ptr >= ptrend) + { + ptr = rcsbuf_fill (rcsbuf, ptr, (char **) NULL, (char **) NULL); + if (ptr == NULL) + error (1, 0, "unexpected end of file reading %s", + rcsbuf->filename); + ptrend = rcsbuf->ptrend; + } + + c = *ptr; + if (! my_whitespace (c)) + break; + + ++ptr; + } + + /* If we have reached `;', there is no value. */ + if (c == ';') + { + *wordp = NULL; + *ptr++ = '\0'; + rcsbuf->ptr = ptr; + rcsbuf->vlen = 0; + return 1; + } + + /* PTR now points to the start of a value. Find out whether it is + a num, an id, a string or a colon. */ + if (c == ':') + { + *wordp = ptr++; + rcsbuf->ptr = ptr; + rcsbuf->vlen = 1; + return 1; + } + + if (c == '@') + { + char *pat; + size_t vlen; + + /* Optimize the common case of a value composed of a single + '@' string. */ + + rcsbuf->at_string = 1; + + ++ptr; + + *wordp = ptr; + + while (1) + { + while ((pat = memchr (ptr, '@', ptrend - ptr)) == NULL) + { + /* Note that we pass PTREND as the PTR value to + rcsbuf_fill, so that we will wind up setting PTR to + the location corresponding to the old PTREND, so + that we don't search the same bytes again. */ + ptr = rcsbuf_fill (rcsbuf, ptrend, NULL, wordp); + if (ptr == NULL) + error (1, 0, + "EOF while looking for end of string in RCS file %s", + rcsbuf->filename); + ptrend = rcsbuf->ptrend; + } + + /* Handle the special case of an '@' right at the end of + the known bytes. */ + if (pat + 1 >= ptrend) + { + /* Note that we pass PAT, not PTR, here. */ + pat = rcsbuf_fill (rcsbuf, pat, NULL, wordp); + if (pat == NULL) + { + /* EOF here is OK; it just means that the last + character of the file was an '@' terminating a + value for a key type which does not require a + trailing ';'. */ + pat = rcsbuf->ptrend - 1; + + } + ptrend = rcsbuf->ptrend; + + /* Note that the value of PTR is bogus here. This is + OK, because we don't use it. */ + } + + if (pat + 1 >= ptrend || pat[1] != '@') + break; + + /* We found an '@' pair in the string. Keep looking. */ + ++rcsbuf->embedded_at; + ptr = pat + 2; + } + + /* Here PAT points to the final '@' in the string. */ + + *pat = '\0'; + + vlen = pat - *wordp; + if (vlen == 0) + *wordp = NULL; + rcsbuf->vlen = vlen; + rcsbuf->ptr = pat + 1; + + return 1; + } + + /* C is neither `:', `;' nor `@', so it should be the start of a num + or an id. Make sure it is not another special character. */ + if (c == '$' || c == '.' || c == ',') + { + error (1, 0, "illegal special character in RCS field in %s", + rcsbuf->filename); + } + + *wordp = ptr; + while (1) + { + if (ptr >= ptrend) + { + ptr = rcsbuf_fill (rcsbuf, ptr, (char **) NULL, wordp); + if (ptr == NULL) + error (1, 0, "unexpected end of file reading %s", + rcsbuf->filename); + ptrend = rcsbuf->ptrend; + } + + /* Legitimate ID characters are digits, dots and any `graphic + printing character that is not a special.' This test ought + to do the trick. */ + c = *ptr; + if (isprint (c) && + c != ';' && c != '$' && c != ',' && c != '@' && c != ':') + { + ++ptr; + continue; + } + break; + } + + /* PTR points to the last non-id character in this word, and C is + the character in its memory cell. Check to make sure that it + is a legitimate word delimiter -- whitespace or semicolon. */ + if (c == ';' || my_whitespace (c)) + { + rcsbuf->vlen = ptr - *wordp; + rcsbuf->ptr = ptr; + return 1; + } + + error (1, 0, "illegal special character in RCS field in %s", + rcsbuf->filename); + /* Shut up compiler warnings. */ + return 0; + +#undef my_whitespace +} + /* Read an RCS revision number from an RCS file. This sets *REVP to point to the revision number; it will point to space that is managed by the rcsbuf functions, and is only good until the next @@ -1875,6 +2357,89 @@ RCS_getversion (rcs, tag, date, force_tag_match, simple_tag) } /* + * Get existing revision number corresponding to tag or revision. + * Similar to RCS_gettag but less interpretation imposed. + * For example: + * -- If tag designates a magic branch, RCS_tag2rev + * returns the magic branch number. + * -- If tag is a branch tag, returns the branch number, not + * the revision of the head of the branch. + * If tag or revision is not valid or does not exist in file, + * exit with error. + */ +char * +RCS_tag2rev (rcs, tag) + RCSNode *rcs; + char *tag; +{ + char *rev, *pa, *pb; + int i; + + assert (rcs != NULL); + + if (rcs->flags & PARTIAL) + RCS_reparsercsfile (rcs, (FILE **) NULL, (struct rcsbuffer *) NULL); + + /* If a valid revision, try to look it up */ + if ( RCS_valid_rev (tag) ) + { + /* Make a copy so we can scribble on it */ + rev = xstrdup (tag); + + /* If revision exists, return the copy */ + if (RCS_exist_rev (rcs, tag)) + return rev; + + /* Nope, none such. If tag is not a branch we're done. */ + i = numdots (rev); + if ((i & 1) == 1 ) + { + pa = strrchr (rev, '.'); + if (i == 1 || *(pa-1) != RCS_MAGIC_BRANCH || *(pa-2) != '.') + { + free (rev); + error (1, 0, "revision `%s' does not exist", tag); + } + } + + /* Tag is branch, but does not exist, try corresponding + * magic branch tag. + * + * FIXME: assumes all magic branches are of + * form "n.n.n ... .0.n". I'll fix if somebody can + * send me a method to get a magic branch tag with + * the 0 in some other position -- + */ + pa = strrchr (rev, '.'); + pb = xmalloc (strlen (rev) + 3); + *pa++ = 0; + (void) sprintf (pb, "%s.%d.%s", rev, RCS_MAGIC_BRANCH, pa); + free (rev); + rev = pb; + if (RCS_exist_rev (rcs, rev)) + return rev; + error (1, 0, "revision `%s' does not exist", tag); + } + + + RCS_check_tag (tag); /* exit if not a valid tag */ + + /* If tag is "HEAD", special case to get head RCS revision */ + if (tag && (strcmp (tag, TAG_HEAD) == 0)) + return (RCS_head (rcs)); + + /* If valid tag let translate_symtag say yea or nay. */ + rev = translate_symtag (rcs, tag); + + if (rev) + return rev; + + error (1, 0, "tag `%s' does not exist", tag); + /* NOT REACHED -- error (1 ... ) does not return here */ + return 0; +} + +/* * Find the revision for a specific tag. * If force_tag_match is set, return NULL if an exact match is not * possible otherwise return RCS_head (). We are careful to look for @@ -2344,6 +2909,41 @@ RCS_getbranch (rcs, tag, force_tag_match) return (xstrdup (vn->version)); } +/* Returns the head of the branch which REV is on. REV can be a + branch tag or non-branch tag; symbolic or numeric. + + Returns a newly malloc'd string. Returns NULL if a symbolic name + isn't found. */ + +char * +RCS_branch_head (rcs, rev) + RCSNode *rcs; + char *rev; +{ + char *num; + char *br; + char *retval; + + assert (rcs != NULL); + + if (RCS_nodeisbranch (rcs, rev)) + return RCS_getbranch (rcs, rev, 1); + + if (isdigit (*rev)) + num = xstrdup (rev); + else + { + num = translate_symtag (rcs, rev); + if (num == NULL) + return NULL; + } + br = truncate_revnum (num); + retval = RCS_getbranch (rcs, br, 1); + free (br); + free (num); + return retval; +} + /* Get the branch point for a particular branch, that is the first revision on that branch. For example, RCS_getbranchpoint (rcs, "1.3.2") will normally return "1.3.2.1". TARGET may be either a @@ -2871,6 +3471,40 @@ RCS_check_tag (tag) } /* + * TRUE if argument has valid syntax for an RCS revision or + * branch number. All characters must be digits or dots, first + * and last characters must be digits, and no two consecutive + * characters may be dots. + * + * Intended for classifying things, so this function doesn't + * call error. + */ +int +RCS_valid_rev (rev) + char *rev; +{ + char last, c; + last = *rev++; + if (!isdigit (last)) + return 0; + while ((c = *rev++)) /* Extra parens placate -Wall gcc option */ + { + if (c == '.') + { + if (last == '.') + return 0; + continue; + } + last = c; + if (!isdigit (c)) + return 0; + } + if (!isdigit (last)) + return 0; + return 1; +} + +/* * Return true if RCS revision with TAG is a dead revision. */ int @@ -3525,11 +4159,10 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) size_t loglen; Node *vp = NULL; #ifdef PRESERVE_PERMISSIONS_SUPPORT - uid_t rcs_owner; - gid_t rcs_group; + uid_t rcs_owner = (uid_t) -1; + gid_t rcs_group = (gid_t) -1; mode_t rcs_mode; - int change_rcs_owner = 0; - int change_rcs_group = 0; + int change_rcs_owner_or_group = 0; int change_rcs_mode = 0; int special_file = 0; unsigned long devnum_long; @@ -3681,7 +4314,6 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) { RCSVers *vers; Node *info; - struct hardlink_info *hlinfo; vp = findnode (rcs->versions, rev == NULL ? rcs->head : rev); if (vp == NULL) @@ -3708,7 +4340,7 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) whether it should be considered an error for `dest' to exist at this point. If so, the unlink call should be removed and `symlink' should signal the error. -twp) */ - if (unlink (dest) < 0 && existence_error (errno)) + if (unlink (dest) < 0 && !existence_error (errno)) error (1, errno, "cannot remove %s", dest); if (symlink (info->data, dest) < 0) error (1, errno, "cannot create symbolic link from %s to %s", @@ -3730,64 +4362,36 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) if (workfile != NULL) { - info = findnode (vers->other_delta, "hardlinks"); - if (info != NULL) + List *links = vers->hardlinks; + if (links != NULL) { - char *links = xstrdup (info->data); - char *working_dir = xgetwd(); - char *p, *file = NULL; - Node *n, *uptodate_link; + Node *uptodate_link; /* For each file in the hardlinks field, check to see if it exists, and if so, if it has been checked out - this iteration. */ - uptodate_link = NULL; - for (p = strtok (links, " "); - p != NULL && uptodate_link == NULL; - p = strtok (NULL, " ")) - { - file = (char *) - xmalloc (sizeof(char) * - (strlen(working_dir) + strlen(p) + 2)); - sprintf (file, "%s/%s", working_dir, p); - n = lookup_file_by_inode (file); - if (n == NULL) - { - if (strcmp (p, workfile) != 0) - { - /* One of the files that WORKFILE should be - linked to is not even in the working directory. - The user should probably be warned. */ - error (0, 0, - "warning: %s should be hardlinked to %s, but is missing", - p, workfile); - } - free (file); - continue; - } + this iteration. When walklist returns, uptodate_link + should point to a hardlist node representing a file + in `links' which has recently been checked out, or + NULL if no file in `links' has yet been checked out. */ - /* hlinfo may be NULL if, for instance, a file is being - removed. */ - hlinfo = (struct hardlink_info *) n->data; - if (hlinfo && hlinfo->checked_out) - uptodate_link = n; - free (file); - } - free (links); - free (working_dir); + uptodate_link = NULL; + (void) walklist (links, find_checkedout_proc, &uptodate_link); + dellist (&links); /* If we've found a file that `workfile' is supposed to be linked to, and it has been checked out since CVS was - invoked, then simply link workfile to that file. + invoked, then simply link workfile to that file and return. - If one of these conditions is not met, then we're - checking out workfile to a temp file or stdout, or - workfile is the first one in its hardlink group to be - checked out. Either way we must continue with a full + If one of these conditions is not met, then + workfile is the first one in its hardlink group to + be checked out, and we must continue with a full checkout. */ if (uptodate_link != NULL) { + struct hardlink_info *hlinfo = + (struct hardlink_info *) uptodate_link->data; + if (link (uptodate_link->key, workfile) < 0) error (1, errno, "cannot link %s to %s", workfile, uptodate_link->key); @@ -3804,13 +4408,13 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) info = findnode (vers->other_delta, "owner"); if (info != NULL) { - change_rcs_owner = 1; + change_rcs_owner_or_group = 1; rcs_owner = (uid_t) strtoul (info->data, NULL, 10); } info = findnode (vers->other_delta, "group"); if (info != NULL) { - change_rcs_group = 1; + change_rcs_owner_or_group = 1; rcs_group = (gid_t) strtoul (info->data, NULL, 10); } info = findnode (vers->other_delta, "permissions"); @@ -3866,6 +4470,9 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) } } + if (free_rev) + free (rev); + if (log != NULL) { free (log); @@ -3935,9 +4542,25 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) if (islink (workfile)) if (unlink_file (workfile) < 0) error (1, errno, "cannot remove %s", workfile); + ofp = CVS_FOPEN (workfile, expand == KFLAG_B ? "wb" : "w"); + + /* If the open failed because the existing workfile was not + writable, try to chmod the file and retry the open. */ + if (ofp == NULL && errno == EACCES + && isfile (workfile) && !iswritable (workfile)) + { + xchmod (workfile, 1); + ofp = CVS_FOPEN (workfile, expand == KFLAG_B ? "wb" : "w"); + } + if (ofp == NULL) - error (1, errno, "cannot open %s", workfile); + { + error (0, errno, "cannot open %s", workfile); + if (free_value) + free (value); + return 1; + } } if (workfile == NULL && sout == RUN_TTY) @@ -3969,10 +4592,15 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) while (nleft > 0) { if (fwrite (p, 1, nstep, ofp) != nstep) - error (1, errno, "cannot write %s", + { + error (0, errno, "cannot write %s", (workfile != NULL ? workfile : (sout != RUN_TTY ? sout : "stdout"))); + if (free_value) + free (value); + return 1; + } p += nstep; nleft -= nstep; if (nleft < nstep) @@ -3981,18 +4609,24 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) } } + if (free_value) + free (value); + if (workfile != NULL) { int ret; #ifdef PRESERVE_PERMISSIONS_SUPPORT if (!special_file && fclose (ofp) < 0) - error (1, errno, "cannot close %s", workfile); + { + error (0, errno, "cannot close %s", workfile); + return 1; + } - if (change_rcs_owner || change_rcs_group) + if (change_rcs_owner_or_group) { if (chown (workfile, rcs_owner, rcs_group) < 0) - error (0, errno, "could not change file ownership on %s", + error (0, errno, "could not change owner or group of %s", workfile); } @@ -4002,7 +4636,10 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) : sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH)); #else if (fclose (ofp) < 0) - error (1, errno, "cannot close %s", workfile); + { + error (0, errno, "cannot close %s", workfile); + return 1; + } ret = chmod (workfile, sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH)); @@ -4020,7 +4657,10 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) !special_file && #endif fclose (ofp) < 0) - error (1, errno, "cannot close %s", sout); + { + error (0, errno, "cannot close %s", sout); + return 1; + } } #ifdef PRESERVE_PERMISSIONS_SUPPORT @@ -4030,11 +4670,6 @@ RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat) update_hardlink_info (workfile); #endif - if (free_value) - free (value); - if (free_rev) - free (rev); - return 0; } @@ -4361,6 +4996,7 @@ RCS_checkin (rcs, workfile, message, rev, flags) int status, checkin_quiet, allocated_workfile; struct tm *ftm; time_t modtime; + int adding_branch = 0; commitpt = NULL; @@ -4381,6 +5017,41 @@ RCS_checkin (rcs, workfile, message, rev, flags) allocated_workfile = 1; } + /* Is the backend file a symbolic link? Follow it and replace the + filename with the destination of the link. */ + + while (islink (rcs->path)) + { + char *newname; +#ifdef HAVE_READLINK + /* The clean thing to do is probably to have each filesubr.c + implement this (with an error if not supported by the + platform, in which case islink would presumably return 0). + But that would require editing each filesubr.c and so the + expedient hack seems to be looking at HAVE_READLINK. */ + newname = xreadlink (rcs->path); +#else + error (1, 0, "internal error: islink doesn't like readlink"); +#endif + + if (isabsolute (newname)) + { + free (rcs->path); + rcs->path = newname; + } + else + { + char *oldname = last_component (rcs->path); + int dirlen = oldname - rcs->path; + char *fullnewname = xmalloc (dirlen + strlen (newname) + 1); + strncpy (fullnewname, rcs->path, dirlen); + strcpy (fullnewname + dirlen, newname); + free (newname); + free (rcs->path); + rcs->path = fullnewname; + } + } + checkin_quiet = flags & RCS_FLAGS_QUIET; if (!checkin_quiet) { @@ -4427,7 +5098,6 @@ RCS_checkin (rcs, workfile, message, rev, flags) Node *np; struct stat sb; char buf[64]; /* static buffer should be safe: see usage. -twp */ - char *fullpath; delta->other_delta = getlist(); @@ -4482,25 +5152,7 @@ RCS_checkin (rcs, workfile, message, rev, flags) } /* Save hardlinks. */ - fullpath = xgetwd(); - fullpath = xrealloc (fullpath, - strlen(fullpath) + strlen(workfile) + 2); - sprintf (fullpath + strlen(fullpath), "/%s", workfile); - - np = lookup_file_by_inode (fullpath); - if (np == NULL) - { - error (1, 0, "lost information on %s's linkage", workfile); - } - else - { - struct hardlink_info *hlinfo; - hlinfo = (struct hardlink_info *) np->data; - np = getnode(); - np->key = xstrdup ("hardlinks"); - np->data = xstrdup (hlinfo->links); - (void) addnode (delta->other_delta, np); - } + delta->hardlinks = list_linked_files_on_disk (workfile); } } #endif @@ -4674,6 +5326,7 @@ RCS_checkin (rcs, workfile, message, rev, flags) goto checkin_done; } delta->version = RCS_addbranch (rcs, branch); + adding_branch = 1; p = strrchr (branch, '.'); *p = '\0'; tip = xstrdup (branch); @@ -4719,13 +5372,26 @@ RCS_checkin (rcs, workfile, message, rev, flags) { if (! STREQ (nodep->data, delta->author)) { - error (0, 0, "%s: revision %s locked by %s", - rcs->path, - nodep->key, nodep->data); - status = 1; - goto checkin_done; + /* If we are adding a branch, then leave the old lock around. + That is sensible in the sense that when adding a branch, + we don't need to use the lock to tell us where to check + in. It is fishy in the sense that if it is our own lock, + we break it. However, this is the RCS 5.7 behavior (at + the end of addbranch in ci.c in RCS 5.7, it calls + removelock only if it is our own lock, not someone + else's). */ + + if (!adding_branch) + { + error (0, 0, "%s: revision %s locked by %s", + rcs->path, + nodep->key, nodep->data); + status = 1; + goto checkin_done; + } } - delnode (nodep); + else + delnode (nodep); } dtext->version = xstrdup (delta->version); @@ -4992,6 +5658,9 @@ RCS_cmp_file (rcs, rev, options, filename) #endif { fp = CVS_FOPEN (filename, binary ? FOPEN_BINARY_READ : "r"); + if (fp == NULL) + /* FIXME-update-dir: should include update_dir in message. */ + error (1, errno, "cannot open file %s for comparing", filename); data.filename = filename; data.fp = fp; @@ -5183,8 +5852,11 @@ RCS_setbranch (rcs, rev) } /* Lock revision REV. LOCK_QUIET is 1 to suppress output. FIXME: - This is only required because the RCS ci program requires a lock. - If we eventually do the checkin ourselves, this can become a no-op. */ + Most of the callers only call us because RCS_checkin still tends to + like a lock (a relic of old behavior inherited from the RCS ci + program). If we clean this up, only "cvs admin -l" will still need + to call RCS_lock. */ + /* FIXME-twp: if a lock owned by someone else is broken, should this send mail to the lock owner? Prompt user? It seems like such an obscure situation for CVS as almost not worth worrying much @@ -5253,6 +5925,18 @@ RCS_lock (rcs, rev, lock_quiet) return 0; } +#if 0 + /* Well, first of all, "rev" below should be "xrev" to avoid + core dumps. But more importantly, should we really be + breaking the lock unconditionally? What CVS 1.9 does (via + RCS) is to prompt "Revision 1.1 is already locked by fred. + Do you want to break the lock? [ny](n): ". Well, we don't + want to interact with the user (certainly not at the + server/protocol level, and probably not in the command-line + client), but isn't it more sensible to give an error and + let the user run "cvs admin -u" if they want to break the + lock? */ + /* Break the lock. */ if (!lock_quiet) { @@ -5260,6 +5944,9 @@ RCS_lock (rcs, rev, lock_quiet) cvs_output (" unlocked\n", 0); } delnode (p); +#else + error (1, 0, "Revision %s is already locked by %s", xrev, p->data); +#endif } /* Create a new lock. */ @@ -5790,6 +6477,18 @@ RCS_delete_revs (rcs, tag1, tag2, inclusive) goto delrev_done; } + if (after == NULL && before == NULL) + { + /* The user is trying to delete all revisions. While an + RCS file without revisions makes sense to RCS (e.g. the + state after "rcs -i"), CVS has never been able to cope with + it. So at least for now we just make this an error. + + We don't include rcs->path in the message since "cvs admin" + already printed "RCS file:" and the name. */ + error (1, 0, "attempt to delete all revisions"); + } + /* The conditionals at this point get really hairy. Here is the general idea: @@ -5802,8 +6501,6 @@ RCS_delete_revs (rcs, tag1, tag2, inclusive) RCS_exec_rcsdiff with some changes, like being able to suppress diagnostic messages and to direct output. */ - assert (before != NULL || after != NULL); - if (after != NULL) { char *diffbuf; @@ -5975,6 +6672,52 @@ RCS_delete_revs (rcs, tag1, tag2, inclusive) return status; } + +/* + * TRUE if there exists a symbolic tag "tag" in file. + */ +int +RCS_exist_tag (rcs, tag) + RCSNode *rcs; + char *tag; +{ + + assert (rcs != NULL); + + if (findnode (RCS_symbols (rcs), tag)) + return 1; + return 0; + +} + +/* + * TRUE if RCS revision number "rev" exists. + * This includes magic branch revisions, not found in rcs->versions, + * but only in rcs->symbols, requiring a list walk to find them. + * Take advantage of list walk callback function already used by + * RCS_delete_revs, above. + */ +int +RCS_exist_rev (rcs, rev) + RCSNode *rcs; + char *rev; +{ + + assert (rcs != NULL); + + if (rcs->flags & PARTIAL) + RCS_reparsercsfile (rcs, (FILE **) NULL, (struct rcsbuffer *) NULL); + + if (findnode(rcs->versions, rev) != 0) + return 1; + + if (walklist (RCS_symbols(rcs), findtag, rev) != 0) + return 1; + + return 0; + +} + /* RCS_deltas and friends. Processing of the deltas in RCS files. */ @@ -6771,7 +7514,7 @@ getdelta (rcsbuf, rcsfile, keyp, valp) char **valp; { RCSVers *vnode; - char *key, *value, *cp; + char *key, *value, *keybuf, *valbuf, *cp; Node *kv; /* Get revision number if it wasn't passed in. This uses @@ -6835,7 +7578,8 @@ unable to parse %s; `author' not in the expected place", rcsfile); error (1, 0, "\ unable to parse %s; `state' not in the expected place", rcsfile); vnode->state = rcsbuf_valcopy (rcsbuf, value, 0, (size_t *) NULL); - if (STREQ (value, "dead")) + /* The value is optional, according to rcsfile(5). */ + if (value != NULL && STREQ (value, "dead")) { vnode->dead = 1; } @@ -6886,11 +7630,80 @@ unable to parse %s; `state' not in the expected place", rcsfile); */ while (1) { - if (! rcsbuf_getkey (rcsbuf, &key, &value)) + int len; + size_t valbuflen; + + key = NULL; + + if (! rcsbuf_getid (rcsbuf, &keybuf)) error (1, 0, "unexpected end of file reading %s", rcsfile); + /* rcsbuf_getid did not terminate the key, so copy it to new space. */ + len = rcsbuf->ptr - keybuf; + key = (char *) xmalloc (sizeof(char) * (len + 1)); + strncpy (key, keybuf, len); + key[len] = '\0'; + + /* The `desc' keyword has only a single string value, with no + trailing semicolon, so it must be handled specially. */ if (STREQ (key, RCSDESC)) + { + (void) rcsbuf_getstring (rcsbuf, &valbuf); + value = rcsbuf_valcopy (rcsbuf, valbuf, 1, &valbuflen); break; + } + +#ifdef PRESERVE_PERMISSIONS_SUPPORT + /* The `hardlinks' value is a group of words, which must + be parsed separately and added as a list to vnode->hardlinks. */ + if (STREQ (key, "hardlinks")) + { + Node *n; + + vnode->hardlinks = getlist(); + while (1) + { + if (! rcsbuf_getword (rcsbuf, &valbuf)) + error (1, 0, "unexpected end of file reading %s", rcsfile); + if (valbuf == NULL) + break; + n = getnode(); + n->key = rcsbuf_valcopy (rcsbuf, valbuf, 1, NULL); + addnode (vnode->hardlinks, n); + } + continue; + } +#endif + + /* Get the value. */ + value = NULL; + while (1) + { + if (! rcsbuf_getword (rcsbuf, &valbuf)) + error (1, 0, "unexpected end of file reading %s", rcsfile); + if (valbuf == NULL) + break; + + /* Copy valbuf to new space so we can polish it, then + append it to value. */ + + if (value == NULL) + { + value = rcsbuf_valcopy (rcsbuf, valbuf, 1, &valbuflen); + } + else + { + char *temp_value; + + temp_value = rcsbuf_valcopy (rcsbuf, valbuf, 1, &valbuflen); + len = strlen (value); + value = (char *) xrealloc + (value, sizeof(char) * (len + valbuflen + 2)); + value[len] = ' '; + strcpy (value + len + 1, temp_value); + free (temp_value); + } + } /* Enable use of repositories created by certain obsolete versions of CVS. This code should remain indefinately; @@ -6919,8 +7732,8 @@ unable to parse %s; `state' not in the expected place", rcsfile); vnode->other_delta = getlist (); kv = getnode (); kv->type = RCSFIELD; - kv->key = xstrdup (key); - kv->data = rcsbuf_valcopy (rcsbuf, value, 1, (size_t *) NULL); + kv->key = key; + kv->data = value; if (addnode (vnode->other_delta, kv) != 0) { /* Complaining about duplicate keys in newphrases seems @@ -7110,6 +7923,36 @@ putrcsfield_proc (node, vfp) return 0; } +#ifdef PRESERVE_PERMISSIONS_SUPPORT + +/* Save a filename in a `hardlinks' RCS field. NODE->KEY will contain + a full pathname, but currently only basenames are stored in the RCS + node. Assume that the filename includes nasty characters and + @-escape it. */ + +static int +puthardlink_proc (node, vfp) + Node *node; + void *vfp; +{ + FILE *fp = (FILE *) vfp; + char *basename = strrchr (node->key, '/'); + + if (basename == NULL) + basename = node->key; + else + ++basename; + + putc ('\t', fp); + putc ('@', fp); + (void) expand_at_signs (basename, strlen (basename), fp); + putc ('@', fp); + + return 0; +} + +#endif + /* Output the admin node for RCS into stream FP. */ static void @@ -7195,6 +8038,14 @@ putdelta (vers, fp) walklist (vers->other_delta, putrcsfield_proc, fp); +#ifdef PRESERVE_PERMISSIONS_SUPPORT + if (vers->hardlinks) + { + fprintf (fp, "\nhardlinks"); + walklist (vers->hardlinks, puthardlink_proc, fp); + putc (';', fp); + } +#endif putc ('\n', fp); } @@ -7428,7 +8279,7 @@ RCS_copydeltas (rcs, fin, rcsbufin, fout, newdtext, insertpt) to count the number of RCS revisions for which some special action is required. */ -int +static int count_delta_actions (np, ignore) Node *np; void *ignore; @@ -7524,8 +8375,6 @@ rcs_internal_lockfile (rcsfile) error (1, errno, "could not open lock file `%s'", lockfile); } - free (lockfile); - /* Force the file permissions, and return a stream object. */ /* Because we change the modes later, we don't worry about this in the non-HAVE_FCHMOD case. */ @@ -7536,6 +8385,9 @@ rcs_internal_lockfile (rcsfile) fp = fdopen (fd, FOPEN_BINARY_WRITE); if (fp == NULL) error (1, errno, "cannot fdopen %s", lockfile); + + free (lockfile); + return fp; } @@ -7767,6 +8619,9 @@ annotate (argc, argv) } #endif /* CLIENT_SUPPORT */ + if (tag != NULL) + tag_check_valid (tag, argc, argv, local, 0, ""); + return start_recursion (annotate_fileproc, (FILESDONEPROC) NULL, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, argc, argv, local, W_LOCAL, 0, 1, (char *)NULL, diff --git a/contrib/cvs/src/rcs.h b/contrib/cvs/src/rcs.h index 400d1a0..f92988f 100644 --- a/contrib/cvs/src/rcs.h +++ b/contrib/cvs/src/rcs.h @@ -154,6 +154,10 @@ struct rcsversnode List *other; /* Newphrase fields from delta nodes. */ List *other_delta; +#ifdef PRESERVE_PERMISSIONS_SUPPORT + /* Hard link information for each revision. */ + List *hardlinks; +#endif }; typedef struct rcsversnode RCSVers; @@ -185,6 +189,9 @@ char *RCS_check_kflag PROTO((const char *arg)); char *RCS_getdate PROTO((RCSNode * rcs, char *date, int force_tag_match)); char *RCS_gettag PROTO((RCSNode * rcs, char *symtag, int force_tag_match, int *simple_tag)); +int RCS_exist_rev PROTO((RCSNode *rcs, char *rev)); +int RCS_exist_tag PROTO((RCSNode *rcs, char *tag)); +char *RCS_tag2rev PROTO((RCSNode *rcs, char *tag)); char *RCS_getversion PROTO((RCSNode * rcs, char *tag, char *date, int force_tag_match, int *simple_tag)); char *RCS_magicrev PROTO((RCSNode *rcs, char *rev)); @@ -196,9 +203,11 @@ int RCS_datecmp PROTO((char *date1, char *date2)); time_t RCS_getrevtime PROTO((RCSNode * rcs, char *rev, char *date, int fudge)); List *RCS_symbols PROTO((RCSNode *rcs)); void RCS_check_tag PROTO((const char *tag)); +int RCS_valid_rev PROTO ((char *rev)); List *RCS_getlocks PROTO((RCSNode *rcs)); void freercsnode PROTO((RCSNode ** rnodep)); char *RCS_getbranch PROTO((RCSNode * rcs, char *tag, int force_tag_match)); +char *RCS_branch_head PROTO ((RCSNode *rcs, char *rev)); int RCS_isdead PROTO((RCSNode *, const char *)); char *RCS_getexpand PROTO ((RCSNode *)); diff --git a/contrib/cvs/src/rcscmds.c b/contrib/cvs/src/rcscmds.c index 3086b57..f889233 100644 --- a/contrib/cvs/src/rcscmds.c +++ b/contrib/cvs/src/rcscmds.c @@ -11,6 +11,8 @@ #include "cvs.h" #include +#include +#include "diffrun.h" /* This file, rcs.h, and rcs.c, together sometimes known as the "RCS library", are intended to define our interface to RCS files. @@ -75,6 +77,11 @@ static void call_diff_setup PROTO ((const char *prog)); static int call_diff PROTO ((char *out)); static int call_diff3 PROTO ((char *out)); +static void call_diff_write_output PROTO((const char *, size_t)); +static void call_diff_flush_output PROTO((void)); +static void call_diff_write_stdout PROTO((const char *)); +static void call_diff_error PROTO((const char *, const char *, const char *)); + /* VARARGS */ static void call_diff_setup (prog) @@ -132,51 +139,92 @@ call_diff_add_arg (s) call_diff_argv[call_diff_argc] = (char *) 0; } -/* diff_run is imported from libdiff.a. */ -extern int diff_run PROTO ((int argc, char **argv, char *out)); +/* Callback function for the diff library to write data to the output + file. This is used when we are producing output to stdout. */ + +static void +call_diff_write_output (text, len) + const char *text; + size_t len; +{ + cvs_output (text, len); +} + +/* Call back function for the diff library to flush the output file. + This is used when we are producing output to stdout. */ + +static void +call_diff_flush_output () +{ + cvs_flushout (); +} + +/* Call back function for the diff library to write to stdout. */ + +static void +call_diff_write_stdout (text) + const char *text; +{ + cvs_output (text, 0); +} + +/* Call back function for the diff library to write to stderr. */ + +static void +call_diff_error (format, a1, a2) + const char *format; + const char *a1; + const char *a2; +{ + /* FIXME: Should we somehow indicate that this error is coming from + the diff library? */ + error (0, 0, format, a1, a2); +} + +/* This set of callback functions is used if we are sending the diff + to stdout. */ + +static struct diff_callbacks call_diff_stdout_callbacks = +{ + call_diff_write_output, + call_diff_flush_output, + call_diff_write_stdout, + call_diff_error +}; + +/* This set of callback functions is used if we are sending the diff + to a file. */ + +static struct diff_callbacks call_diff_file_callbacks = +{ + (void (*) PROTO((const char *, size_t))) NULL, + (void (*) PROTO((void))) NULL, + call_diff_write_stdout, + call_diff_error +}; static int call_diff (out) char *out; { - /* Try to keep the out-of-order bugs at bay (protocol_pipe for cvs_output - with has "Index: foo" and such; stdout and/or stderr for diff's - output). I think the only reason that this used to not be such - a problem is that the time spent on the fork() and exec() of diff - slowed us down enough to let the "Index:" make it through first. - - The real fix, of course, will be to have the diff library do all - its output through callbacks (which CVS will supply as cvs_output - and cvs_outerr). */ - sleep (1); - if (out == RUN_TTY) - return diff_run (call_diff_argc, call_diff_argv, NULL); + return diff_run (call_diff_argc, call_diff_argv, NULL, + &call_diff_stdout_callbacks); else - return diff_run (call_diff_argc, call_diff_argv, out); + return diff_run (call_diff_argc, call_diff_argv, out, + &call_diff_file_callbacks); } -extern int diff3_run PROTO ((int argc, char **argv, char *out)); - static int call_diff3 (out) char *out; { - /* Try to keep the out-of-order bugs at bay (protocol_pipe for cvs_output - with has "Index: foo" and such; stdout and/or stderr for diff's - output). I think the only reason that this used to not be such - a problem is that the time spent on the fork() and exec() of diff - slowed us down enough to let the "Index:" make it through first. - - The real fix, of course, will be to have the diff library do all - its output through callbacks (which CVS will supply as cvs_output - and cvs_outerr). */ - sleep (1); - if (out == RUN_TTY) - return diff3_run (call_diff_argc, call_diff_argv, NULL); + return diff3_run (call_diff_argc, call_diff_argv, NULL, + &call_diff_stdout_callbacks); else - return diff3_run (call_diff_argc, call_diff_argv, out); + return diff3_run (call_diff_argc, call_diff_argv, out, + &call_diff_file_callbacks); } diff --git a/contrib/cvs/src/recurse.c b/contrib/cvs/src/recurse.c index 3896bc7..d88bf2b 100644 --- a/contrib/cvs/src/recurse.c +++ b/contrib/cvs/src/recurse.c @@ -13,6 +13,9 @@ #include "fileattr.h" #include "edit.h" +#ifdef CLIENT_SUPPORT +static int do_argument_proc PROTO((Node * p, void *closure)); +#endif static int do_dir_proc PROTO((Node * p, void *closure)); static int do_file_proc PROTO((Node * p, void *closure)); static void addlist PROTO((List ** listp, char *key)); @@ -58,6 +61,24 @@ struct frame_and_entries { List *entries; }; +#ifdef CLIENT_SUPPORT +/* This is a callback to send "Argument" commands to the server in the + case we've done a "cvs update" or "cvs commit" in a top-level + directory where there is no CVSADM directory. */ + +static int +do_argument_proc (p, closure) + Node *p; + void *closure; +{ + char *dir = p->key; + send_to_server ("Argument ", 0); + send_to_server (dir, 0); + send_to_server ("\012", 1); + return 0; +} +#endif + /* Start a recursive command. Command line arguments (ARGC, ARGV) dictate the directories and @@ -175,6 +196,19 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, callerdat, "there is no version here; run '%s checkout' first", program_name); } +#ifdef CLIENT_SUPPORT + else if (client_active && server_started) + { + /* In the the case "cvs update foo bar baz", a call to + send_file_names in update.c will have sent the + appropriate "Argument" commands to the server. In + this case, that won't have happened, so we need to + do it here. While this example uses "update", this + generalizes to other commands. */ + + err += walklist (dirlist, do_argument_proc, NULL); + } +#endif } else addlist (&dirlist, "."); @@ -586,7 +620,6 @@ do_dir_proc (p, closure) char *newrepos; List *sdirlist; char *srepository; - char *cp; Dtype dir_return = R_PROCESS; int stripped_dot = 0; int err = 0; @@ -790,16 +823,8 @@ but CVS uses %s for its own purposes; skipping %s directory", repository = srepository; } - /* Put back update_dir. I think this is the same as just setting - update_dir back to saved_update_dir, but there are a few cases I'm - not sure about (in particular, if DIR is "." and update_dir is - not ""), so for conservatism I'm leaving this here. */ - cp = last_component (update_dir); - if (cp > update_dir) - cp[-1] = '\0'; - else - update_dir[0] = '\0'; - free (saved_update_dir); + free (update_dir); + update_dir = saved_update_dir; return (err); } diff --git a/contrib/cvs/src/rtag.c b/contrib/cvs/src/rtag.c index 93539e2..3207c1b 100644 --- a/contrib/cvs/src/rtag.c +++ b/contrib/cvs/src/rtag.c @@ -477,7 +477,7 @@ pretag_proc(repository, filter) run_arg (delete_flag ? "del" : force_tag_move ? "mov" : "add"); run_arg (repository); walklist(tlist, pretag_list_proc, NULL); - return (run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY)); + return (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)); } static void diff --git a/contrib/cvs/src/sanity.sh b/contrib/cvs/src/sanity.sh index 1d877fe..f97e036 100755 --- a/contrib/cvs/src/sanity.sh +++ b/contrib/cvs/src/sanity.sh @@ -512,8 +512,12 @@ dotest_sort () dotest_internal "$@" } -# clean any old remnants -rm -rf ${TESTDIR} +# clean any old remnants (we need the chmod because some tests make +# directories read-only) +if test -d ${TESTDIR}; then + chmod -R a+wx ${TESTDIR} + rm -rf ${TESTDIR} +fi mkdir ${TESTDIR} cd ${TESTDIR} # This will show up in cvs history output where it prints the working @@ -549,24 +553,30 @@ RCSINIT=; export RCSINIT if test x"$*" = x; then # Basic/miscellaneous functionality - tests="basica basicb basicc basic1 deep basic2" + tests="basica basicb basicc basic1 deep basic2 commit-readonly" # Branching, tagging, removing, adding, multiple directories tests="${tests} rdiff death death2 branches branches2" - tests="${tests} rcslib multibranch import importb join join2 join3" + tests="${tests} rcslib multibranch import importb importc" + tests="${tests} join join2 join3" tests="${tests} new newb conflicts conflicts2 conflicts3" # Checking out various places (modules, checkout -d, &c) tests="${tests} modules modules2 modules3 modules4" - tests="${tests} cvsadm abspath toplevel" + tests="${tests} cvsadm emptydir abspath toplevel toplevel2" # Log messages, error messages. tests="${tests} mflag editor errmsg1 errmsg2" # Watches, binary files, history browsing, &c. tests="${tests} devcom devcom2 devcom3 watch4" + tests="${tests} unedit-without-baserev" tests="${tests} ignore binfiles binfiles2 mcopy binwrap binwrap2" - tests="${tests} binwrap3 mwrap info config" - tests="${tests} serverpatch log log2 ann crerepos rcs big modes stamps" + tests="${tests} binwrap3 mwrap info taginfo config" + tests="${tests} serverpatch log log2 ann ann-id crerepos rcs rcs2" + tests="${tests} history" + tests="${tests} big modes modes2 stamps" + # PreservePermissions stuff: permissions, symlinks et al. + tests="${tests} perms symlinks hardlinks" # More tag and branch tests, keywords. tests="${tests} sticky keyword keywordlog" - tests="${tests} head tagdate multibranch2" + tests="${tests} head tagdate multibranch2 tag8k" # "cvs admin", reserved checkouts. tests="${tests} admin reserved" # Nuts and bolts of diffing/merging (diff library, &c) @@ -888,15 +898,19 @@ done" cd .. rm -r 2 -: mkdir ${CVSROOT_DIRNAME}/first-dir dotest basicb-1 "${testcvs} -q co first-dir" '' - dotest basicb-1a "test -d CVS" '' + + # The top-level CVS directory is not created by default. + # I'm leaving basicb-1a and basicb-1b untouched, mostly, in + # case we decide that the default should be reversed... + + dotest_fail basicb-1a "test -d CVS" '' # In 1b and 1c, the first string matches if we're using absolute # paths, while the second matches if RELATIVE_REPOS is defined # (we're using relative paths). - dotest basicb-1b "cat CVS/Repository" \ +: dotest basicb-1b "cat CVS/Repository" \ "${TESTDIR}/cvsroot/\." \ "\." dotest basicb-1c "cat first-dir/CVS/Repository" \ @@ -1001,13 +1015,16 @@ U first-dir1/sdir2/sfile2' "${testcvs} -q co -d newdir -r release-1 first-dir/Emptydir first-dir/sdir2" \ 'U newdir/first-dir/Emptydir/sfile1 U newdir/first-dir/sdir2/sfile2' - dotest basicb-9a "test -d CVS" '' + + # basicb-9a and basicb-9b: see note about basicb-1a + + dotest_fail basicb-9a "test -d CVS" '' # In 9b through 9f, the first string matches if we're using # absolute paths, while the second matches if RELATIVE_REPOS # is defined (we're using relative paths). - dotest basicb-9b "cat CVS/Repository" \ +: dotest basicb-9b "cat CVS/Repository" \ "${TESTDIR}/cvsroot/\." \ "\." dotest basicb-9c "cat newdir/CVS/Repository" \ @@ -1063,33 +1080,24 @@ Checking in aa; ${TESTDIR}/cvsroot/second-dir/aa,v <-- aa initial revision: 1\.1 done" - cd ../.. - rm -r 1 + cd .. - # Let's see if we can add something to Emptydir. - dotest basicb-18 "${testcvs} -q co -d t2/t3 first-dir second-dir" \ -"U t2/t3/first-dir/Emptydir/sfile1 -U t2/t3/first-dir/sdir2/sfile2 -U t2/t3/second-dir/aa" - cd t2 - touch emptyfile - # The fact that CVS lets us add a file here is a CVS bug, right? - # I can just make this an error message (on the add and/or the - # commit) without getting flamed, right? - # Right? - # Right? - dotest basicb-19 "${testcvs} add emptyfile" \ -"${PROG} [a-z]*: scheduling file .emptyfile. for addition -${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" - dotest basicb-20 "${testcvs} -q ci -m add" \ -"RCS file: ${TESTDIR}/cvsroot/CVSROOT/Emptydir/emptyfile,v -done -Checking in emptyfile; -${TESTDIR}/cvsroot/CVSROOT/Emptydir/emptyfile,v <-- emptyfile -initial revision: 1\.1 -done" + # Try to remove all revisions in a file. + dotest_fail basicb-o1 "${testcvs} admin -o1.1 topfile" \ +"RCS file: ${TESTDIR}/cvsroot/topfile,v +deleting revision 1\.1 +${PROG} \[[a-z]* aborted\]: attempt to delete all revisions" + dotest basicb-o2 "${testcvs} -q update -d first-dir" \ +"U first-dir/Emptydir/sfile1 +U first-dir/sdir2/sfile2" + dotest_fail basicb-o3 \ +"${testcvs} admin -o1.1:1.2 first-dir/sdir2/sfile2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/sdir2/sfile2,v +deleting revision 1\.2 +deleting revision 1\.1 +${PROG} \[[a-z]* aborted\]: attempt to delete all revisions" cd .. - rm -r t2 + rm -r 1 mkdir 1; cd 1 # Note that -H is an illegal option. @@ -1105,18 +1113,6 @@ ${PROG} \[admin aborted\]: specify ${PROG} -H admin for usage information" cd .. rmdir 1 - # OK, while we have an Emptydir around, test a few obscure - # things about it. - mkdir edir; cd edir - dotest basicb-edir-1 "${testcvs} -q co -l CVSROOT" \ -"U CVSROOT${DOTSTAR}" - cd CVSROOT - dotest_fail basicb-edir-2 "test -d Emptydir" '' - # This tests the code in find_dirs which skips Emptydir. - dotest basicb-edir-3 "${testcvs} -q -n update -d -P" '' - cd ../.. - rm -r edir - if test "$keep" = yes; then echo Keeping ${TESTDIR} and exiting due to --keep exit 0 @@ -1124,7 +1120,6 @@ ${PROG} \[admin aborted\]: specify ${PROG} -H admin for usage information" rm -rf ${CVSROOT_DIRNAME}/first-dir rm -rf ${CVSROOT_DIRNAME}/second-dir - rm -rf ${CVSROOT_DIRNAME}/CVSROOT/Emptydir rm -f ${CVSROOT_DIRNAME}/topfile,v ;; @@ -1141,10 +1136,11 @@ ${PROG} \[[a-z]* aborted\]: there is no version here; run .${PROG} checkout. fir Directory ${TESTDIR}/cvsroot/second-dir added to the repository" # Old versions of CVS often didn't create this top-level CVS # directory in the first place. I think that maybe the only - # way to get avoid it currently is to let CVS create it, and - # then blow it away. But that is perfectly legal; people who - # are used to the old behavior especially may be interested. - rm -r CVS + # way to get it to work currently is to let CVS create it, + # and then blow it away (don't complain if it does not + # exist). But that is perfectly legal; people who are used + # to the old behavior especially may be interested. + rm -rf CVS dotest basicc-4 "echo *" "first-dir second-dir" dotest basicc-5 "${testcvs} update" \ "${PROG} [a-z]*: Updating first-dir @@ -2051,6 +2047,47 @@ O [0-9/]* [0-9:]* ${PLUS}0000 ${username} \[1\.1\] first-dir =first-di rm -rf ${CVSROOT_DIRNAME}/second-dir ;; + commit-readonly) + mkdir 1; cd 1 + module=x + + : > junk + dotest commit-readonly-1 "$testcvs -Q import -m . $module X Y" '' + dotest commit-readonly-2 "$testcvs -Q co $module" '' + cd $module + + file=m + + # Include an rcs keyword to be expanded. + echo '$Id''$' > $file + + dotest commit-readonly-3 "$testcvs add $file" \ +"${PROG} [a-z]*: scheduling file .$file. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest commit-readonly-4 "$testcvs -Q ci -m . $file" \ +"RCS file: ${TESTDIR}/cvsroot/$module/$file,v +done +Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +initial revision: 1\.1 +done" + + echo line2 >> $file + # Make the file read-only. + chmod a-w $file + + dotest commit-readonly-5 "$testcvs -Q ci -m . $file" \ +"Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +new revision: 1\.2; previous revision: 1\.1 +done" + + cd ../.. + rm -rf 1 + rm -rf ${CVSROOT_DIRNAME}/$module + ;; + + rdiff) # Test rdiff # XXX for now this is just the most essential test... @@ -3557,6 +3594,17 @@ two 3 [>]>>>>>> 1\.2" + # Test behavior of symlinks in the repository. + dotest rcslib-symlink-1 "ln -s file1,v ${CVSROOT_DIRNAME}/first-dir/file2,v" + dotest rcslib-symlink-2 "${testcvs} update file2" "U file2" + echo "This is a change" >> file2 + dotest rcslib-symlink-3 "${testcvs} ci -m because file2" \ +"Checking in file2; +${TESTDIR}/cvsroot/first-dir/file1,v <-- file2 +new revision: 1\.1\.2\.2; previous revision: 1\.1\.2\.1 +done" + dotest rcslib-symlink-4 "test -L ${CVSROOT_DIRNAME}/first-dir/file2,v" + cd .. if test "$keep" = yes; then @@ -3657,6 +3705,7 @@ modify-on-br1 # rdiff -- imports with keywords # import -- more tests of imports with keywords # importb -- -b option. + # importc -- bunch o' files in bunch o' directories # modules3 # mflag -- various -m messages # ignore -- import and cvsignore @@ -3787,6 +3836,7 @@ modify-on-br1 fail 106.5 fi cd .. + rm imported-f2-orig.tmp # co if ${CVS} co first-dir ; then @@ -3972,6 +4022,83 @@ add rm -rf ${CVSROOT_DIRNAME}/first-dir ${CVSROOT_DIRNAME}/second-dir ;; + importc) + # Test importing a bunch o' files in a bunch o' directories. + mkdir 1; cd 1 + mkdir adir bdir cdir + mkdir adir/sub1 adir/sub2 + mkdir adir/sub1/ssdir + mkdir bdir/subdir + touch adir/sub1/file1 adir/sub2/file2 adir/sub1/ssdir/ssfile + touch bdir/subdir/file1 + touch cdir/cfile + dotest_sort importc-1 \ +"${testcvs} import -m import-it first-dir vendor release" \ +" + +N first-dir/adir/sub1/file1 +N first-dir/adir/sub1/ssdir/ssfile +N first-dir/adir/sub2/file2 +N first-dir/bdir/subdir/file1 +N first-dir/cdir/cfile +No conflicts created by this import +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/adir +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/adir/sub1 +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/adir/sub1/ssdir +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/adir/sub2 +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/bdir +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/bdir/subdir +${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/first-dir/cdir" + cd .. + mkdir 2; cd 2 + dotest importc-2 "${testcvs} -q co first-dir" \ +"U first-dir/adir/sub1/file1 +U first-dir/adir/sub1/ssdir/ssfile +U first-dir/adir/sub2/file2 +U first-dir/bdir/subdir/file1 +U first-dir/cdir/cfile" + cd first-dir + dotest importc-3 "${testcvs} update adir/sub1" \ +"${PROG} [a-z]*: Updating adir/sub1 +${PROG} [a-z]*: Updating adir/sub1/ssdir" + dotest importc-4 "${testcvs} update adir/sub1 bdir/subdir" \ +"${PROG} [a-z]*: Updating adir/sub1 +${PROG} [a-z]*: Updating adir/sub1/ssdir +${PROG} [a-z]*: Updating bdir/subdir" + + echo modify >>cdir/cfile + dotest importc-5 \ +"${testcvs} -q rtag -b -r release wip_test first-dir" "" + dotest importc-6 "${testcvs} -q update -r wip_test" "M cdir/cfile" + + if test "$remote" = no; then + # This checkin should just succeed. That it doesn't is a + # bug (CVS 1.9.16 through the present seem to have it; CVS + # 1.9 did not). + dotest_fail importc-7 "${testcvs} -q ci -m modify -r wip_test" \ +"${PROG} [a-z]*: in directory adir/sub1/ssdir: +${PROG} \[[a-z]* aborted\]: there is no version here; do .cvs checkout. first" + # The workaround is to leave off the "-r wip_test". + dotest importc-8 "${testcvs} -q ci -m modify" \ +"Checking in cdir/cfile; +${TESTDIR}/cvsroot/first-dir/cdir/cfile,v <-- cfile +new revision: 1\.1\.1\.1\.2\.1; previous revision: 1\.1\.1\.1 +done" + else + # Remote doesn't have the bug in the first place. + dotest importc-7 "${testcvs} -q ci -m modify -r wip_test" \ +"Checking in cdir/cfile; +${TESTDIR}/cvsroot/first-dir/cdir/cfile,v <-- cfile +new revision: 1\.1\.1\.1\.2\.1; previous revision: 1\.1\.1\.1 +done" + fi + cd .. + + cd .. + rm -r 1 2 + rm -rf ${CVSROOT_DIRNAME}/first-dir + ;; + join) # Test doing joins which involve adding and removing files. # Variety of scenarios (see list below), in the context of: @@ -5779,6 +5906,10 @@ ${PROG} [a-z]*: Rebuilding administrative file database" dotest modules2-5 "test -d ampermodule/second-dir" '' # Test ability of cvs release to handle multiple arguments + # Other CVS release tests: + # info-cleanup-0 for "cvs -n release". + # ignore-193 for the text of the question that cvs release asks. + # Also for interactions with cvsignore. cd ampermodule if ${testcvs} release -d first-dir second-dir <>${LOGFILE} yes @@ -5803,9 +5934,11 @@ EOF "${PROG} [a-z]*: Updating first-dir ${PROG} [a-z]*: Updating second-dir" touch ampermodule/first-dir/amper1 - dotest modules2-10 "${testcvs} add ampermodule/first-dir/amper1" \ -"${PROG} [a-z]*: scheduling file .ampermodule/first-dir/amper1. for addition + cd ampermodule + dotest modules2-10 "${testcvs} add first-dir/amper1" \ +"${PROG} [a-z]*: scheduling file .first-dir/amper1. for addition ${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + cd .. # As with the "Updating xxx" message, the "U first-dir/amper1" # message (instead of "U ampermodule/first-dir/amper1") is @@ -6131,6 +6264,7 @@ done" cat >modules <config + dotest cvsadm-setup-2 "${testcvs} -q ci -m yes-top-level" \ +"Checking in config; +${TESTDIR}/cvsroot/CVSROOT/config,v <-- config +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd ../.. + rm -r 1 + + # Second, check out the modules file and edit it. mkdir 1; cd 1 dotest cvsadm-1 "${testcvs} co CVSROOT/modules" \ "U CVSROOT/modules" @@ -6278,26 +6443,27 @@ ${PROG} [a-z]*: Rebuilding administrative file database" rm -rf CVS CVSROOT; # Create the various modules - mkdir ${CVSROOT_DIRNAME}/mod1 - mkdir ${CVSROOT_DIRNAME}/mod1-2 - mkdir ${CVSROOT_DIRNAME}/mod2 - mkdir ${CVSROOT_DIRNAME}/mod2/sub2 - mkdir ${CVSROOT_DIRNAME}/mod2-2 - mkdir ${CVSROOT_DIRNAME}/mod2-2/sub2-2 - dotest cvsadm-2 "${testcvs} co mod1 mod1-2 mod2 mod2-2" \ -"${PROG} [a-z]*: Updating mod1 -${PROG} [a-z]*: Updating mod1-2 -${PROG} [a-z]*: Updating mod2 -${PROG} [a-z]*: Updating mod2/sub2 -${PROG} [a-z]*: Updating mod2-2 -${PROG} [a-z]*: Updating mod2-2/sub2-2" + dotest cvsadm-2 "${testcvs} -q co -l ." '' + mkdir mod1 + mkdir mod1-2 + mkdir mod2 + mkdir mod2/sub2 + mkdir mod2-2 + mkdir mod2-2/sub2-2 + dotest cvsadm-2a "${testcvs} add mod1 mod1-2 mod2 mod2/sub2 mod2-2 mod2-2/sub2-2" \ +"Directory ${TESTDIR}/cvsroot/mod1 added to the repository +Directory ${TESTDIR}/cvsroot/mod1-2 added to the repository +Directory ${TESTDIR}/cvsroot/mod2 added to the repository +Directory ${TESTDIR}/cvsroot/mod2/sub2 added to the repository +Directory ${TESTDIR}/cvsroot/mod2-2 added to the repository +Directory ${TESTDIR}/cvsroot/mod2-2/sub2-2 added to the repository" # Populate the directories for the halibut echo "file1" > mod1/file1 echo "file1-2" > mod1-2/file1-2 echo "file2" > mod2/sub2/file2 echo "file2-2" > mod2-2/sub2-2/file2-2 - dotest cvsadm-2a "${testcvs} add mod1/file1 mod1-2/file1-2 mod2/sub2/file2 mod2-2/sub2-2/file2-2" \ + dotest cvsadm-2aa "${testcvs} add mod1/file1 mod1-2/file1-2 mod2/sub2/file2 mod2-2/sub2-2/file2-2" \ "${PROG} [a-z]*: scheduling file .mod1/file1. for addition ${PROG} [a-z]*: scheduling file .mod1-2/file1-2. for addition ${PROG} [a-z]*: scheduling file .mod2/sub2/file2. for addition @@ -7287,68 +7453,71 @@ U dir/dir2d2-2/sub2d2-2/file2-2" ## on the command line, but use a longer path. ################################################## + dotest_fail cvsadm-2d3-1 "${testcvs} co -d dir/dir2 1mod" \ +"${PROG} [a-z]*: cannot chdir to dir: No such file or directory +${PROG} [a-z]*: ignoring module 1mod" + + if test "$remote" = no; then + # Remote can't handle this, even with the "mkdir dir". + # This was also true of CVS 1.9. + + mkdir dir dotest cvsadm-2d3 "${testcvs} co -d dir/dir2 1mod" \ "${PROG} [a-z]*: Updating dir/dir2 U dir/dir2/file1" dotest cvsadm-2d3b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-2d3d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" + dotest_fail cvsadm-2d3d "test -f dir/CVS/Repository" "" dotest cvsadm-2d3f "cat dir/dir2/CVS/Repository" \ "${AREP}mod1" rm -rf CVS dir + mkdir dir dotest cvsadm-2d4 "${testcvs} co -d dir/dir2 2mod" \ "${PROG} [a-z]*: Updating dir/dir2 U dir/dir2/file2" dotest cvsadm-2d4b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-2d4d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-2d4f "cat dir/dir2/CVS/Repository" \ "${AREP}mod2/sub2" rm -rf CVS dir + mkdir dir dotest cvsadm-2d5 "${testcvs} co -d dir/dir2 1d1mod" \ "${PROG} [a-z]*: Updating dir/dir2 U dir/dir2/file1" dotest cvsadm-2d5b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-2d5d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-2d5f "cat dir/dir2/CVS/Repository" \ "${AREP}mod1" rm -rf CVS dir + mkdir dir dotest cvsadm-2d6 "${testcvs} co -d dir/dir2 1d2mod" \ "${PROG} [a-z]*: Updating dir/dir2 U dir/dir2/file2" dotest cvsadm-2d6b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-2d6d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-2d6f "cat dir/dir2/CVS/Repository" \ "${AREP}mod2/sub2" rm -rf CVS dir + mkdir dir dotest cvsadm-2d7 "${testcvs} co -d dir/dir2 2d1mod" \ "${PROG} [a-z]*: Updating dir/dir2 U dir/dir2/file1" dotest cvsadm-2d7b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-2d7d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-2d7f "cat dir/dir2/CVS/Repository" \ "${AREP}mod1" rm -rf CVS dir + mkdir dir dotest cvsadm-2d8 "${testcvs} co -d dir/dir2 2d2mod" \ "${PROG} [a-z]*: Updating dir/dir2 U dir/dir2/file2" dotest cvsadm-2d8b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-2d8d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-2d8f "cat dir/dir2/CVS/Repository" \ "${AREP}mod2/sub2" rm -rf CVS dir @@ -7490,65 +7659,60 @@ U dir/dir2d2/sub2d2/file2" ## the ones in two-deep directories + mkdir dir dotest cvsadm-N2d3 "${testcvs} co -N -d dir/dir2 1mod" \ "${PROG} [a-z]*: Updating dir/dir2/1mod U dir/dir2/1mod/file1" dotest cvsadm-N2d3b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-N2d3d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-N2d3f "cat dir/dir2/CVS/Repository" \ "${AREP}\." dotest cvsadm-N2d3h "cat dir/dir2/1mod/CVS/Repository" \ "${AREP}mod1" rm -rf CVS dir + mkdir dir dotest cvsadm-N2d4 "${testcvs} co -N -d dir/dir2 2mod" \ "${PROG} [a-z]*: Updating dir/dir2/2mod U dir/dir2/2mod/file2" dotest cvsadm-N2d4b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-N2d4d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-N2d4f "cat dir/dir2/CVS/Repository" \ "${AREP}\." dotest cvsadm-N2d4h "cat dir/dir2/2mod/CVS/Repository" \ "${AREP}mod2/sub2" rm -rf CVS dir + mkdir dir dotest cvsadm-N2d5 "${testcvs} co -N -d dir/dir2 1d1mod" \ "${PROG} [a-z]*: Updating dir/dir2/dir1d1 U dir/dir2/dir1d1/file1" dotest cvsadm-N2d5b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-N2d5d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-N2d5f "cat dir/dir2/CVS/Repository" \ "${AREP}\." dotest cvsadm-N2d5h "cat dir/dir2/dir1d1/CVS/Repository" \ "${AREP}mod1" rm -rf CVS dir + mkdir dir dotest cvsadm-N2d6 "${testcvs} co -N -d dir/dir2 1d2mod" \ "${PROG} [a-z]*: Updating dir/dir2/dir1d2 U dir/dir2/dir1d2/file2" dotest cvsadm-N2d6b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-N2d6d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-N2d6f "cat dir/dir2/CVS/Repository" \ "${AREP}\." dotest cvsadm-N2d6h "cat dir/dir2/dir1d2/CVS/Repository" \ "${AREP}mod2/sub2" rm -rf CVS dir + mkdir dir dotest cvsadm-N2d7 "${testcvs} co -N -d dir/dir2 2d1mod" \ "${PROG} [a-z]*: Updating dir/dir2/dir2d1/sub2d1 U dir/dir2/dir2d1/sub2d1/file1" dotest cvsadm-N2d7b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-N2d7d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-N2d7f "cat dir/dir2/CVS/Repository" \ "${AREP}\." dotest cvsadm-N2d7f "cat dir/dir2/dir2d1/CVS/Repository" \ @@ -7557,13 +7721,12 @@ U dir/dir2/dir2d1/sub2d1/file1" "${AREP}mod1" rm -rf CVS dir + mkdir dir dotest cvsadm-N2d8 "${testcvs} co -N -d dir/dir2 2d2mod" \ "${PROG} [a-z]*: Updating dir/dir2/dir2d2/sub2d2 U dir/dir2/dir2d2/sub2d2/file2" dotest cvsadm-N2d8b "cat CVS/Repository" \ "${AREP}\." - dotest cvsadm-N2d8d "cat dir/CVS/Repository" \ -"${AREP}CVSROOT/Emptydir" dotest cvsadm-N2d8f "cat dir/dir2/CVS/Repository" \ "${AREP}\." dotest cvsadm-N2d8h "cat dir/dir2/dir2d2/CVS/Repository" \ @@ -7572,10 +7735,25 @@ U dir/dir2/dir2d2/sub2d2/file2" "${AREP}mod2/sub2" rm -rf CVS dir + fi # end of tests to be skipped for remote + ################################################## ## That's enough of that, thank you very much. ################################################## + dotest cvsadm-cleanup-1 "${testcvs} -q co CVSROOT/config" \ +"U CVSROOT/config" + cd CVSROOT + echo "# empty file" >config + dotest cvsadm-cleanup-2 "${testcvs} -q ci -m cvsadm-cleanup" \ +"Checking in config; +${TESTDIR}/cvsroot/CVSROOT/config,v <-- config +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd .. + rm -rf CVSROOT CVS + # remove our junk cd .. rm -rf 1 @@ -7589,6 +7767,90 @@ U dir/dir2/dir2d2/sub2d2/file2" rm -rf ${CVSROOT_DIRNAME}/mod2-2 ;; + emptydir) + # Various tests of the Emptydir (CVSNULLREPOS) code. See also: + # cvsadm: tests of Emptydir in various module definitions + # basicb: Test that "Emptydir" is non-special in ordinary contexts + + mkdir 1; cd 1 + dotest emptydir-1 "${testcvs} co CVSROOT/modules" \ +"U CVSROOT/modules" + echo "# Module defs for emptydir tests" > CVSROOT/modules + echo "2d1mod -d dir2d1/sub2d1 mod1" >> CVSROOT/modules + + dotest emptydir-2 "${testcvs} ci -m add-modules" \ +"${PROG} [a-z]*: Examining CVSROOT +Checking in CVSROOT/modules; +${CVSROOT_DIRNAME}/CVSROOT/modules,v <-- modules +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + rm -rf CVS CVSROOT + + mkdir ${CVSROOT_DIRNAME}/mod1 + # Populate. Not sure we really need to do this. + dotest emptydir-3 "${testcvs} co mod1" \ +"${PROG} [a-z]*: Updating mod1" + echo "file1" > mod1/file1 + cd mod1 + dotest emptydir-4 "${testcvs} add file1" \ +"${PROG} [a-z]*: scheduling file .file1. for addition +${PROG} [a-z]*: use '${PROG} commit' to add this file permanently" + cd .. + dotest emptydir-5 "${testcvs} -q ci -m yup mod1" \ +"RCS file: ${CVSROOT_DIRNAME}/mod1/file1,v +done +Checking in mod1/file1; +${CVSROOT_DIRNAME}/mod1/file1,v <-- file1 +initial revision: 1\.1 +done" + rm -rf mod1 CVS + # End Populate. + + dotest emptydir-6 "${testcvs} co 2d1mod" \ +"${PROG} [a-z]*: Updating dir2d1/sub2d1 +U dir2d1/sub2d1/file1" + cd dir2d1 + touch emptyfile + # The fact that CVS lets us add a file here is a CVS bug, right? + # I can just make this an error message (on the add and/or the + # commit) without getting flamed, right? + # Right? + # Right? + dotest emptydir-7 "${testcvs} add emptyfile" \ +"${PROG} [a-z]*: scheduling file .emptyfile. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest emptydir-8 "${testcvs} -q ci -m add" \ +"RCS file: ${TESTDIR}/cvsroot/CVSROOT/Emptydir/emptyfile,v +done +Checking in emptyfile; +${TESTDIR}/cvsroot/CVSROOT/Emptydir/emptyfile,v <-- emptyfile +initial revision: 1\.1 +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd .. + rm -rf CVS dir2d1 + + # OK, while we have an Emptydir around, test a few obscure + # things about it. + mkdir edir; cd edir + dotest emptydir-9 "${testcvs} -q co -l CVSROOT" \ +"U CVSROOT${DOTSTAR}" + cd CVSROOT + dotest_fail emptydir-10 "test -d Emptydir" '' + # This tests the code in find_dirs which skips Emptydir. + dotest emptydir-11 "${testcvs} -q -n update -d -P" '' + cd ../.. + rm -r edir + + cd .. + + rm -r 1 + rm -rf ${CVSROOT_DIRNAME}/mod1 + # I guess for the moment the convention is going to be + # that we don't need to remove ${CVSROOT_DIRNAME}/CVSROOT/Emptydir + ;; + abspath) # These tests test the thituations thin thwitch thoo theck @@ -7607,10 +7869,16 @@ ${PROG} [a-z]*: Updating mod2" # Populate the module echo "file1" > mod1/file1 echo "file2" > mod2/file2 - dotest abspath-1b "${testcvs} add mod1/file1 mod2/file2" \ -"${PROG} [a-z]*: scheduling file .mod1/file1. for addition -${PROG} [a-z]*: scheduling file .mod2/file2. for addition -${PROG} [a-z]*: use '${PROG} commit' to add these files permanently" + cd mod1 + dotest abspath-1ba "${testcvs} add file1" \ +"${PROG} [a-z]*: scheduling file .file1. for addition +${PROG} [a-z]*: use '${PROG} commit' to add this file permanently" + cd .. + cd mod2 + dotest abspath-1bb "${testcvs} add file2" \ +"${PROG} [a-z]*: scheduling file .file2. for addition +${PROG} [a-z]*: use '${PROG} commit' to add this file permanently" + cd .. dotest abspath-1c "${testcvs} ci -m yup mod1 mod2" \ "${PROG} [a-z]*: Examining mod1 @@ -7632,9 +7900,17 @@ done" # Done. # Try checking out the module in a local directory + if test "$remote" = yes; then + dotest_fail abspath-2a "${testcvs} co -d ${TESTDIR}/1 mod1" \ +"${PROG} \[server aborted\]: absolute pathname .${TESTDIR}/1. illegal for server" + dotest abspath-2a-try2 "${testcvs} co -d 1 mod1" \ +"${PROG} [a-z]*: Updating 1 +U 1/file1" + else dotest abspath-2a "${testcvs} co -d ${TESTDIR}/1 mod1" \ "${PROG} [a-z]*: Updating ${TESTDIR}/1 U ${TESTDIR}/1/file1" + fi # remote workaround # Are we relative or absolute in our Repository file? echo "${CVSROOT_DIRNAME}/mod1" > ${TESTDIR}/dotest.abs @@ -7658,11 +7934,47 @@ U ${TESTDIR}/1/file1" # Now try in a subdirectory. We're not covering any more # code here, but we might catch a future error if someone # changes the checkout code. + + # Note that for the same reason that the shell command + # "touch 1/2/3" requires directories 1 and 1/2 to already + # exist, we expect ${TESTDIR}/1 to already exist. I believe + # this is the behavior of CVS 1.9 and earlier. + if test "$remote" = no; then + dotest_fail abspath-3.1 "${testcvs} co -d ${TESTDIR}/1/2 mod1" \ +"${PROG} [a-z]*: cannot chdir to 1: No such file or directory +${PROG} [a-z]*: ignoring module mod1" + fi + dotest_fail abspath-3.2 "${testcvs} co -d 1/2 mod1" \ +"${PROG} [a-z]*: cannot chdir to 1: No such file or directory +${PROG} [a-z]*: ignoring module mod1" + mkdir 1 + + if test "$remote" = yes; then + # The server wants the directory to exist, but that is + # a bug, it should only need to exist on the client side. + # See also cvsadm-2d3. + dotest_fail abspath-3a "${testcvs} co -d 1/2 mod1" \ +"${PROG} [a-z]*: cannot chdir to 1: No such file or directory +${PROG} [a-z]*: ignoring module mod1" + cd 1 + dotest abspath-3a-try2 "${testcvs} co -d 2 mod1" \ +"${PROG} [a-z]*: Updating 2 +U 2/file1" + cd .. + rm -rf 1/CVS + else dotest abspath-3a "${testcvs} co -d ${TESTDIR}/1/2 mod1" \ "${PROG} [a-z]*: Updating ${TESTDIR}/1/2 U ${TESTDIR}/1/2/file1" + fi # remote workaround dotest abspath-3b "cat ${TESTDIR}/1/2/CVS/Repository" \ "${AREP}mod1" + + # For all the same reasons that we want "1" to already + # exist, we don't to mess with it to traverse it, for + # example by creating a CVS directory. + + dotest_fail abspath-3c "test -d ${TESTDIR}/1/CVS" '' # Done. Clean up. rm -rf ${TESTDIR}/1 @@ -7670,19 +7982,32 @@ U ${TESTDIR}/1/2/file1" # Now try someplace where we don't have permission. mkdir ${TESTDIR}/barf chmod -w ${TESTDIR}/barf - dotest_fail abspath-4 "${testcvs} co -d ${TESTDIR}/barf/sub mod1" \ + if test "$remote" = yes; then + dotest_fail abspath-4 "${testcvs} co -d ${TESTDIR}/barf/sub mod1" \ +"${PROG} \[server aborted\]: absolute pathname .${TESTDIR}/barf/sub. illegal for server" + else + dotest_fail abspath-4 "${testcvs} co -d ${TESTDIR}/barf/sub mod1" \ "${PROG} \[[a-z]* aborted\]: cannot make directory sub: No such file or directory" + fi chmod +w ${TESTDIR}/barf rmdir ${TESTDIR}/barf # Done. Nothing to clean up. # Try checking out two modules into the same directory. - dotest abspath-5a "${testcvs} co -d ${TESTDIR}/1 mod1 mod2" \ + if test "$remote" = yes; then + dotest abspath-5a "${testcvs} co -d 1 mod1 mod2" \ +"${PROG} [a-z]*: Updating 1/mod1 +U 1/mod1/file1 +${PROG} [a-z]*: Updating 1/mod2 +U 1/mod2/file2" + else + dotest abspath-5a "${testcvs} co -d ${TESTDIR}/1 mod1 mod2" \ "${PROG} [a-z]*: Updating ${TESTDIR}/1/mod1 U ${TESTDIR}/1/mod1/file1 ${PROG} [a-z]*: Updating ${TESTDIR}/1/mod2 U ${TESTDIR}/1/mod2/file2" + fi # end remote workaround dotest abspath-5b "cat ${TESTDIR}/1/CVS/Repository" \ "${AREP}." dotest abspath-5c "cat ${TESTDIR}/1/mod1/CVS/Repository" \ @@ -7694,7 +8019,17 @@ U ${TESTDIR}/1/mod2/file2" # Try checking out the top-level module. - dotest abspath-6a "${testcvs} co -d ${TESTDIR}/1 ." \ + if test "$remote" = yes; then + dotest abspath-6a "${testcvs} co -d 1 ." \ +"${PROG} [a-z]*: Updating 1 +${PROG} [a-z]*: Updating 1/CVSROOT +${DOTSTAR} +${PROG} [a-z]*: Updating 1/mod1 +U 1/mod1/file1 +${PROG} [a-z]*: Updating 1/mod2 +U 1/mod2/file2" + else + dotest abspath-6a "${testcvs} co -d ${TESTDIR}/1 ." \ "${PROG} [a-z]*: Updating ${TESTDIR}/1 ${PROG} [a-z]*: Updating ${TESTDIR}/1/CVSROOT ${DOTSTAR} @@ -7702,6 +8037,7 @@ ${PROG} [a-z]*: Updating ${TESTDIR}/1/mod1 U ${TESTDIR}/1/mod1/file1 ${PROG} [a-z]*: Updating ${TESTDIR}/1/mod2 U ${TESTDIR}/1/mod2/file2" + fi # end of remote workaround dotest abspath-6b "cat ${TESTDIR}/1/CVS/Repository" \ "${AREP}." dotest abspath-6c "cat ${TESTDIR}/1/CVSROOT/CVS/Repository" \ @@ -7713,17 +8049,45 @@ U ${TESTDIR}/1/mod2/file2" # Done. Clean up. rm -rf ${TESTDIR}/1 + # Test that an absolute pathname to some other directory + # doesn't mess with the current working directory. + mkdir 1 + cd 1 + if test "$remote" = yes; then + dotest_fail abspath-7a "${testcvs} -q co -d ../2 mod2" \ +"${PROG} server: protocol error: .\.\./2. contains more leading \.\. +${PROG} \[server aborted\]: than the 0 which Max-dotdot specified" + cd .. + dotest abspath-7a-try2 "${testcvs} -q co -d 2 mod2" \ +"U 2/file2" + cd 1 + else + dotest abspath-7a "${testcvs} -q co -d ${TESTDIR}/2 mod2" \ +"U ${TESTDIR}/2/file2" + fi # remote workaround + dotest abspath-7b "ls" "" + dotest abspath-7c "${testcvs} -q co mod1" \ +"U mod1/file1" + cd mod1 + if test "$remote" = yes; then + cd ../.. + dotest abspath-7d "${testcvs} -q co -d 3 mod2" \ +"U 3/file2" + cd 1/mod1 + else + dotest abspath-7d "${testcvs} -q co -d ${TESTDIR}/3 mod2" \ +"U ${TESTDIR}/3/file2" + fi # remote workaround + dotest abspath-7e "${testcvs} -q update -d" "" + cd ../.. + rm -r 1 2 3 + # # FIXME: do other functions here (e.g. update /tmp/foo) # # Finished with all tests. Remove the module. - rm -rf ${CVSROOT_DIRNAME}/mod1 ${CVSROOT_DIRNAME}/mod1 - - # FIXME: the absolute pathname fixes create CVS directories - # wherever they can. That means for the standard TESTDIR, a - # /tmp/CVS directory will be created as well. It's not safe - # to remove it, however. + rm -rf ${CVSROOT_DIRNAME}/mod1 ${CVSROOT_DIRNAME}/mod2 ;; @@ -7733,9 +8097,26 @@ U ${TESTDIR}/1/mod2/file2" # Some test, somewhere, is creating Emptydir. That test # should, perhaps, clean up for itself, but I don't know which - # one it is. + # one it is (cvsadm, emptydir, &c). + # (On the other hand, should CVS care whether there is an + # Emptydir? That would seem a bit odd). rm -rf ${CVSROOT_DIRNAME}/CVSROOT/Emptydir + # First set the TopLevelAdmin setting. + mkdir 1; cd 1 + dotest toplevel-1a "${testcvs} -q co CVSROOT/config" \ +"U CVSROOT/config" + cd CVSROOT + echo "TopLevelAdmin=yes" >config + dotest toplevel-1b "${testcvs} -q ci -m yes-top-level" \ +"Checking in config; +${TESTDIR}/cvsroot/CVSROOT/config,v <-- config +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd ../.. + rm -r 1 + mkdir 1; cd 1 dotest toplevel-1 "${testcvs} -q co -l ." '' mkdir top-dir second-dir @@ -7806,6 +8187,7 @@ ${PROG} [a-z]*: Updating top-dir" dotest toplevel-10 "${testcvs} co top-dir" \ "${PROG} [a-z]*: Updating top-dir U top-dir/file1" + # This tests more or less the same thing, in a particularly # "real life" example. dotest toplevel-11 "${testcvs} -q update -d second-dir" \ @@ -7819,28 +8201,140 @@ U top-dir/file1" # Now set the permissions so we can't recreate it. chmod -w ../1 # Now see whether CVS has trouble because it can't create CVS. + # First string is for local, second is for remote. dotest toplevel-12 "${testcvs} co top-dir" \ "${PROG} [a-z]*: warning: cannot make directory CVS in \.: Permission denied +${PROG} [a-z]*: Updating top-dir" \ +"${PROG} [a-z]*: warning: cannot make directory CVS in \.: Permission denied +${PROG} [a-z]*: in directory \.: +${PROG} [a-z]*: cannot open CVS/Entries for reading: No such file or directory ${PROG} [a-z]*: Updating top-dir" + chmod +w ../1 - cd .. + dotest toplevel-cleanup-1 "${testcvs} -q co CVSROOT/config" \ +"U CVSROOT/config" + cd CVSROOT + echo "# empty file" >config + dotest toplevel-cleanup-2 "${testcvs} -q ci -m toplevel-cleanup" \ +"Checking in config; +${TESTDIR}/cvsroot/CVSROOT/config,v <-- config +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + + cd ../.. rm -r 1 rm -rf ${CVSROOT_DIRNAME}/top-dir ${CVSROOT_DIRNAME}/second-dir ;; - mflag) - for message in '' ' ' ' - ' ' test' ; do - # Set up - mkdir a-dir; cd a-dir - # Test handling of -m during import - echo testa >>test - if ${testcvs} import -m "$message" a-dir A A1 >>${LOGFILE} 2>&1;then - pass 156 - else - fail 156 - fi + toplevel2) + # Similar to toplevel, but test the case where TopLevelAdmin=no. + + # First set the TopLevelAdmin setting. + mkdir 1; cd 1 + dotest toplevel2-1a "${testcvs} -q co CVSROOT/config" \ +"U CVSROOT/config" + cd CVSROOT + echo "TopLevelAdmin=no" >config + dotest toplevel2-1b "${testcvs} -q ci -m no-top-level" \ +"Checking in config; +${TESTDIR}/cvsroot/CVSROOT/config,v <-- config +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd ../.. + rm -r 1 + + # Now set up some directories and subdirectories + mkdir 1; cd 1 + dotest toplevel2-1 "${testcvs} -q co -l ." '' + mkdir top-dir second-dir + dotest toplevel2-2 "${testcvs} add top-dir second-dir" \ +"Directory ${TESTDIR}/cvsroot/top-dir added to the repository +Directory ${TESTDIR}/cvsroot/second-dir added to the repository" + cd top-dir + + touch file1 + dotest toplevel2-3 "${testcvs} add file1" \ +"${PROG} [a-z]*: scheduling file .file1. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest toplevel2-4 "${testcvs} -q ci -m add" \ +"RCS file: ${TESTDIR}/cvsroot/top-dir/file1,v +done +Checking in file1; +${TESTDIR}/cvsroot/top-dir/file1,v <-- file1 +initial revision: 1\.1 +done" + cd .. + + cd second-dir + touch file2 + dotest toplevel2-3s "${testcvs} add file2" \ +"${PROG} [a-z]*: scheduling file .file2. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest toplevel2-4s "${testcvs} -q ci -m add" \ +"RCS file: ${TESTDIR}/cvsroot/second-dir/file2,v +done +Checking in file2; +${TESTDIR}/cvsroot/second-dir/file2,v <-- file2 +initial revision: 1\.1 +done" + + cd ../.. + rm -r 1; mkdir 1; cd 1 + dotest toplevel2-5 "${testcvs} co top-dir" \ +"${PROG} [a-z]*: Updating top-dir +U top-dir/file1" + + dotest toplevel2-6 "${testcvs} update top-dir" \ +"${PROG} [a-z]*: Updating top-dir" + dotest toplevel2-7 "${testcvs} update" \ +"${PROG} [a-z]*: Updating top-dir" + + dotest toplevel2-8 "${testcvs} update -d top-dir" \ +"${PROG} [a-z]*: Updating top-dir" + # Contrast this with toplevel-9, which has TopLevelAdmin=yes. + dotest toplevel2-9 "${testcvs} update -d" \ +"${PROG} [a-z]*: Updating top-dir" + + cd .. + rm -r 1; mkdir 1; cd 1 + dotest toplevel2-10 "${testcvs} co top-dir" \ +"${PROG} [a-z]*: Updating top-dir +U top-dir/file1" + # This tests more or less the same thing, in a particularly + # "real life" example. With TopLevelAdmin=yes, this command + # would give us second-dir and CVSROOT directories too. + dotest toplevel2-11 "${testcvs} -q update -d" "" + + dotest toplevel2-cleanup-1 "${testcvs} -q co CVSROOT/config" \ +"U CVSROOT/config" + cd CVSROOT + echo "# empty file" >config + dotest toplevel2-cleanup-2 "${testcvs} -q ci -m toplevel2-cleanup" \ +"Checking in config; +${TESTDIR}/cvsroot/CVSROOT/config,v <-- config +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd ../.. + rm -r 1 + rm -rf ${CVSROOT_DIRNAME}/top-dir ${CVSROOT_DIRNAME}/second-dir + ;; + + mflag) + for message in '' ' ' ' + ' ' test' ; do + # Set up + mkdir a-dir; cd a-dir + # Test handling of -m during import + echo testa >>test + if ${testcvs} import -m "$message" a-dir A A1 >>${LOGFILE} 2>&1;then + pass 156 + else + fail 156 + fi # Must import twice since the first time uses inline code that # avoids RCS call. echo testb >>test @@ -7894,7 +8388,7 @@ ${PROG} [a-z]*: Updating top-dir" cat >${TESTDIR}/editme <${TESTDIR}/edit.new +sed <\$1 -e 's/^/x/' >${TESTDIR}/edit.new mv ${TESTDIR}/edit.new \$1 exit 0 EOF @@ -8619,9 +9113,20 @@ Enew line here G@#..!@#=&" cd ../.. + # OK, now change the tab to a space, and see that CVS gives + # a reasonable error (this is database corruption but CVS should + # not lose its mind). + sed -e 's/Fw2 /Fw2 /' <${CVSROOT_DIRNAME}/first-dir/CVS/fileattr \ + >${CVSROOT_DIRNAME}/first-dir/CVS/fileattr.new + mv ${CVSROOT_DIRNAME}/first-dir/CVS/fileattr.new \ + ${CVSROOT_DIRNAME}/first-dir/CVS/fileattr + mkdir 2; cd 2 + dotest_fail devcom3-10 "${testcvs} -Q co ." \ +"${PROG} \[[a-z]* aborted\]: file attribute database corruption: tab missing in ${CVSROOT_DIRNAME}/first-dir/CVS/fileattr" + cd .. # Use -f because of the readonly files. - rm -rf 1 + rm -rf 1 2 rm -rf ${CVSROOT_DIRNAME}/first-dir ;; @@ -8716,6 +9221,106 @@ C file1" rm -rf ${CVSROOT_DIRNAME}/first-dir ;; + unedit-without-baserev) + mkdir 1; cd 1 + module=x + + file=m + echo foo > $file + dotest unedit-without-baserev-1 \ + "$testcvs -Q import -m . $module X Y" '' + dotest unedit-without-baserev-2 "$testcvs -Q co $module" '' + cd $module + + dotest unedit-without-baserev-3 "$testcvs -Q edit $file" '' + + echo add a line >> $file + rm -f CVS/Baserev + + # This will fail on most systems. + if echo "yes" | ${testcvs} -Q unedit $file \ + >${TESTDIR}/test.tmp 2>&1 ; then + dotest unedit-without-baserev-4 "cat ${TESTDIR}/test.tmp" \ +"m has been modified; revert changes${QUESTION} ${PROG} unedit: m not mentioned in CVS/Baserev +${PROG} unedit: run update to complete the unedit" + else + fail unedit-without-baserev-4 + fi + + # SunOS4.1.4 systems make it this far, but with a corrupted + # CVS/Entries file. Demonstrate the corruption! + dotest unedit-without-baserev-5 "cat CVS/Entries" \ + "/$file/1\.1\.1\.1/.*" + + if test "$remote" = yes; then + dotest unedit-without-baserev-6 "${testcvs} -q update" "U m" + else + dotest unedit-without-baserev-6 "${testcvs} -q update" \ +"${PROG} update: warning: m was lost +U m" + fi + + # OK, those were the easy cases. Now tackle the hard one + # (the reason that CVS/Baserev was invented rather than just + # getting the revision from CVS/Entries). This is very + # similar to watch4-10 through watch4-18 but with Baserev + # missing. + cd ../.. + mkdir 2; cd 2 + dotest unedit-without-baserev-7 "${testcvs} -Q co x" '' + cd x + + dotest unedit-without-baserev-10 "${testcvs} edit m" '' + echo 'edited in 2' >m + cd ../.. + + cd 1/x + dotest unedit-without-baserev-11 "${testcvs} edit m" '' + echo 'edited in 1' >m + dotest unedit-without-baserev-12 "${testcvs} -q ci -m edit-in-1" \ +"Checking in m; +${TESTDIR}/cvsroot/x/m,v <-- m +new revision: 1\.2; previous revision: 1\.1 +done" + cd ../.. + cd 2/x + dotest unedit-without-baserev-13 "${testcvs} -q update" \ +"RCS file: ${TESTDIR}/cvsroot/x/m,v +retrieving revision 1\.1\.1\.1 +retrieving revision 1\.2 +Merging differences between 1\.1\.1\.1 and 1\.2 into m +rcsmerge: warning: conflicts during merge +${PROG} [a-z]*: conflicts found in m +C m" + rm CVS/Baserev + if (echo yes | ${testcvs} unedit m) >${TESTDIR}/test.tmp 2>&1; then + dotest unedit-without-baserev-14 "cat ${TESTDIR}/test.tmp" \ +"m has been modified; revert changes${QUESTION} ${PROG} unedit: m not mentioned in CVS/Baserev +${PROG} unedit: run update to complete the unedit" + else + fail unedit-without-baserev-14 + fi + if test "$remote" = yes; then + dotest unedit-without-baserev-15 "${testcvs} -q update" "U m" + else + dotest unedit-without-baserev-15 "${testcvs} -q update" \ +"${PROG} update: warning: m was lost +U m" + fi + # The following tests are kind of degenerate compared with + # watch4-16 through watch4-18 but might as well make sure that + # nothing seriously wrong has happened to the working directory. + dotest unedit-without-baserev-16 "cat m" 'edited in 1' + # Make sure CVS really thinks we are at 1.2. + dotest unedit-without-baserev-17 "${testcvs} -q update" "" + dotest unedit-without-baserev-18 "cat m" "edited in 1" + + cd ../.. + rm -rf 1 + rm -r 2 + rm -rf ${CVSROOT_DIRNAME}/$module + ;; + ignore) # On Windows, we can't check out CVSROOT, because the case # insensitivity means that this conflicts with cvsroot. @@ -9876,6 +10481,7 @@ ${PROG} [a-z]*: Rebuilding administrative file database" # cvsignore: ignore # verifymsg: info # cvswrappers: mwrap + # taginfo: taginfo # config: config # On Windows, we can't check out CVSROOT, because the case @@ -10009,6 +10615,9 @@ done ${PROG} [a-z]*: Rebuilding administrative file database" cd .. + dotest_fail info-cleanup-0 "${testcvs} -n release -d CVSROOT" \ +"${PROG} \[release aborted\]: cannot run command ${DOTSTAR}" + if echo "yes" | ${testcvs} release -d CVSROOT >>${LOGFILE} ; then pass info-cleanup else @@ -10024,6 +10633,112 @@ ${PROG} [a-z]*: Rebuilding administrative file database" rm -rf ${CVSROOT_DIRNAME}/first-dir ;; + taginfo) + # Tests of the CVSROOT/taginfo file. See the comment at the + # "info" tests for a full list of administrative file tests. + + # Tests to add: + # -F to move + # -d + # rtag + + mkdir 1; cd 1 + dotest taginfo-1 "${testcvs} -q co CVSROOT" "U CVSROOT/${DOTSTAR}" + cd CVSROOT + cat >${TESTDIR}/1/loggit <>${TESTDIR}/1/taglog + exit 0 +fi +EOF + chmod +x ${TESTDIR}/1/loggit + echo "ALL ${TESTDIR}/1/loggit" >taginfo + dotest taginfo-2 "${testcvs} -q ci -m check-in-taginfo" \ +"Checking in taginfo; +${TESTDIR}/cvsroot/CVSROOT/taginfo,v <-- taginfo +new revision: 1\.2; previous revision: 1\.1 +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd .. + + # taginfo-3 used to rely on the top-level CVS directory + # being created to add "first-dir" to the repository. Since + # that won't happen anymore, we create the directory in the + # repository. + mkdir ${CVSROOT_DIRNAME}/first-dir + dotest taginfo-3 "${testcvs} -q co first-dir" '' + + cd first-dir + echo first >file1 + dotest taginfo-4 "${testcvs} add file1" \ +"${PROG} [a-z]*: scheduling file .file1. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest taginfo-5 "${testcvs} -q ci -m add-it" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v +done +Checking in file1; +${TESTDIR}/cvsroot/first-dir/file1,v <-- file1 +initial revision: 1\.1 +done" + dotest taginfo-6 "${testcvs} -q tag tag1" "T file1" + dotest taginfo-7 "${testcvs} -q tag -b br" "T file1" + dotest taginfo-8 "${testcvs} -q update -r br" "" + echo add text on branch >>file1 + dotest taginfo-9 "${testcvs} -q ci -m modify-on-br" \ +"Checking in file1; +${TESTDIR}/cvsroot/first-dir/file1,v <-- file1 +new revision: 1\.1\.2\.1; previous revision: 1\.1 +done" + dotest taginfo-10 "${testcvs} -q tag -F -c brtag" "T file1" + + dotest_fail taginfo-11 "${testcvs} -q tag rejectme" \ +"${PROG} [a-z]*: Pre-tag check failed +${PROG} \[[a-z]* aborted\]: correct the above errors first!" + + # When we are using taginfo to allow/disallow, it would be + # convenient to be able to use "cvs -n tag" to test whether + # the allow/disallow functionality is working as expected. + dotest taginfo-12 "${testcvs} -nq tag rejectme" "T file1" + + # But when taginfo is used for logging, it is a pain for -n + # to call taginfo, since taginfo doesn't know whether -n was + # specified or not. + dotest taginfo-13 "${testcvs} -nq tag would-be-tag" "T file1" + + # The "br" example should be passing 1.1.2 or 1.1.0.2. + # But it turns out that is very hard to implement, since + # check_fileproc doesn't know what branch number it will + # get. Probably the whole thing should be re-architected + # so that taginfo only allows/denies tagging, and a new + # hook, which is done from tag_fileproc, does logging. + # That would solve this, some more subtle races, and also + # the fact that it is nice for users to run "-n tag foo" to + # see whether a tag would be allowed. Failing that, + # I suppose passing "1.1.branch" or "branch" for "br" + # would be an improvement. + dotest taginfo-examine "cat ${TESTDIR}/1/taglog" \ +"tag1 add ${TESTDIR}/cvsroot/first-dir file1 1.1 +br add ${TESTDIR}/cvsroot/first-dir file1 1.1 +brtag mov ${TESTDIR}/cvsroot/first-dir file1 1.1.2.1" + + cd .. + cd CVSROOT + echo '# Keep life simple' > taginfo + dotest taginfo-cleanup-1 "${testcvs} -q ci -m check-in-taginfo" \ +"Checking in taginfo; +${TESTDIR}/cvsroot/CVSROOT/taginfo,v <-- taginfo +new revision: 1\.3; previous revision: 1\.2 +done +${PROG} [a-z]*: Rebuilding administrative file database" + cd .. + cd .. + rm -r 1 + rm -rf ${CVSROOT_DIRNAME}/first-dir + ;; + config) # Tests of the CVSROOT/config file. See the comment at the # "info" tests for a full list of administrative file tests. @@ -10036,10 +10751,12 @@ ${PROG} [a-z]*: Rebuilding administrative file database" dotest config-1 "${testcvs} -q co CVSROOT" "U CVSROOT/${DOTSTAR}" cd CVSROOT echo 'bogus line' >config + # We can't rely on specific revisions, since other tests + # might need to modify CVSROOT/config dotest config-3 "${testcvs} -q ci -m change-to-bogus-line" \ "Checking in config; ${TESTDIR}/cvsroot/CVSROOT/config,v <-- config -new revision: 1\.2; previous revision: 1\.1 +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* done ${PROG} [a-z]*: Rebuilding administrative file database" echo 'BogusOption=yes' >config @@ -10047,7 +10764,7 @@ ${PROG} [a-z]*: Rebuilding administrative file database" "${PROG} [a-z]*: syntax error in ${TESTDIR}/cvsroot/CVSROOT/config: line 'bogus line' is missing '=' Checking in config; ${TESTDIR}/cvsroot/CVSROOT/config,v <-- config -new revision: 1\.3; previous revision: 1\.2 +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* done ${PROG} [a-z]*: Rebuilding administrative file database" echo '# No config is a good config' > config @@ -10055,7 +10772,7 @@ ${PROG} [a-z]*: Rebuilding administrative file database" "${PROG} [a-z]*: ${TESTDIR}/cvsroot/CVSROOT/config: unrecognized keyword 'BogusOption' Checking in config; ${TESTDIR}/cvsroot/CVSROOT/config,v <-- config -new revision: 1\.4; previous revision: 1\.3 +new revision: 1\.[0-9]*; previous revision: 1\.[0-9]* done ${PROG} [a-z]*: Rebuilding administrative file database" dotest config-6 "${testcvs} -q update" '' @@ -10105,7 +10822,7 @@ done" # Remove the tag. This will leave the tag string in the # expansion of the Name keyword. - dotest serverpatch-6 "${testcvs} -q update -A" '' + dotest serverpatch-6 "${testcvs} -q update -A first-dir" '' # Modify and check in the first copy. cd ../1/first-dir @@ -10520,7 +11237,9 @@ date: [0-9/]* [0-9:]*; author: ${username}; state: Exp; ;; ann) - # Tests of "cvs annotate". See also basica-10. + # Tests of "cvs annotate". See also: + # basica-10 A simple annotate test + # rcs Annotate and the year 2000 mkdir 1; cd 1 dotest ann-1 "${testcvs} -q co -l ." '' mkdir first-dir @@ -10626,12 +11345,77 @@ done" 1\.2 (${username} *[0-9a-zA-Z-]*): line 1\.2\.2\.1 (${username} *[0-9a-zA-Z-]*): and some 1\.2\.2\.1 (${username} *[0-9a-zA-Z-]*): branched content" + # FIXCVS: shouldn't "-r 1.2.0.2" be the same as "-r br"? + dotest ann-12 "${testcvs} ann -r 1.2.0.2 file1" "" + dotest ann-13 "${testcvs} ann -r 1.2.2 file1" \ +"Annotations for file1 +\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* +1\.1 (${username} *[0-9a-zA-Z-]*): this +1\.1 (${username} *[0-9a-zA-Z-]*): is +1\.2 (${username} *[0-9a-zA-Z-]*): a +1\.1 (${username} *[0-9a-zA-Z-]*): file +1\.2 (${username} *[0-9a-zA-Z-]*): +1\.2 (${username} *[0-9a-zA-Z-]*): with +1\.2 (${username} *[0-9a-zA-Z-]*): a +1\.2 (${username} *[0-9a-zA-Z-]*): blank +1\.2 (${username} *[0-9a-zA-Z-]*): line +1\.2\.2\.1 (${username} *[0-9a-zA-Z-]*): and some +1\.2\.2\.1 (${username} *[0-9a-zA-Z-]*): branched content" + dotest_fail ann-14 "${testcvs} ann -r bill-clintons-chastity file1" \ +"${PROG} \[[a-z]* aborted\]: no such tag bill-clintons-chastity" cd ../.. rm -r 1 rm -rf ${CVSROOT_DIRNAME}/first-dir ;; + ann-id) + # Demonstrate that cvs-1.9.28.1 improperly expands rcs keywords in + # the output of `cvs annotate' -- it uses values from the previous + # delta. In this case, `1.1' instead of `1.2', even though it puts + # the proper version number on the prefix to each line of output. + mkdir 1; cd 1 + dotest ann-id-1 "${testcvs} -q co -l ." '' + module=x + mkdir $module + dotest ann-id-2 "${testcvs} add $module" \ +"Directory ${TESTDIR}/cvsroot/$module added to the repository" + cd $module + + file=m + echo '$Id''$' > $file + + dotest ann-id-3 "$testcvs add $file" \ +"${PROG} [a-z]*: scheduling file .$file. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest ann-id-4 "$testcvs -Q ci -m . $file" \ +"RCS file: ${TESTDIR}/cvsroot/$module/$file,v +done +Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +initial revision: 1\.1 +done" + + echo line2 >> $file + dotest ann-id-5 "$testcvs -Q ci -m . $file" \ +"Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +new revision: 1\.2; previous revision: 1\.1 +done" + + # The version number after $file,v should be `1.2'. + # 1.9.28.1 puts `1.1' there. + dotest ann-id-6 "$testcvs -Q ann $file" \ +"Annotations for $file +\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* +1.2 ($username *[0-9a-zA-Z-]*): "'\$'"Id: $file,v 1.1 [0-9/]* [0-9:]* $username Exp "'\$'" +1.2 ($username *[0-9a-zA-Z-]*): line2" + + cd ../.. + rm -rf 1 + rm -rf ${CVSROOT_DIRNAME}/$module + ;; + crerepos) # Various tests relating to creating repositories, operating # on repositories created with old versions of CVS, etc. @@ -10673,7 +11457,7 @@ ${testcvs} -d ${TESTDIR}/crerepos release -d CVSROOT >>${LOGFILE}; then else fail crerepos-5 fi - rm -r CVS + rm -rf CVS cd .. # The directory tmp should be empty dotest crerepos-6 "rmdir tmp" '' @@ -10777,7 +11561,7 @@ U first-dir/file1" "${PROG} [a-z]*: Updating crerepos-dir U crerepos-dir/cfile" - if test x`cat CVS/Repository` = x.; then + if test x`cat crerepos-dir/CVS/Repository` = xcrerepos-dir; then # RELATIVE_REPOS # Fatal error so that we don't go traipsing through the # directories which happen to have the same names from the @@ -10984,8 +11768,33 @@ add file1 fail rcs-4 fi + # Intended behavior for "cvs annotate" is that it displays the + # last two digits of the year. Make sure it does that rather + # than some bogosity like "100". + dotest rcs-4a "${testcvs} annotate file1" \ +"Annotations for file1 +\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* +1\.1 (kingdon 24-Nov-96): This is the first line +1\.2 (kingdon 24-Nov-96): This is the third line +1\.2 (kingdon 24-Nov-96): This is the fourth line +1\.2 (kingdon 24-Nov-96): This is the fifth line +1\.2 (kingdon 24-Nov-96): This is the sixth line +1\.2 (kingdon 24-Nov-96): This is the seventh line +1\.2 (kingdon 24-Nov-96): This is the eighth line +1\.2 (kingdon 24-Nov-96): This is the ninth line +1\.2 (kingdon 24-Nov-96): This is the tenth line +1\.2 (kingdon 24-Nov-96): This is the eleventh line +1\.3 (kingdon 24-Nov-00): This is the twelfth line (and what a line it is) +1\.2 (kingdon 24-Nov-96): This is the thirteenth line" + + # Probably should split this test into two at this point (file1 + # above this line and file2 below), as the two share little + # data/setup. + # OK, here is another one. This one was written by hand based on - # doc/RCSFILES and friends. + # doc/RCSFILES and friends. One subtle point is that none of + # the lines end with newlines; that is a feature which we + # should be testing. cat <${CVSROOT_DIRNAME}/first-dir/file2,v head 1.5 ; branch 1.2.6; @@ -11018,6 +11827,8 @@ start revision@ a1 1 branch revision@ EOF + # ' Match the single quote in above here doc -- for font-lock mode. + # First test the default branch. dotest rcs-5 "${testcvs} -q update file2" "U file2" dotest rcs-6 "cat file2" "branch revision" @@ -11160,10 +11971,6 @@ a1 1 next branch revision @" - # For remote, the "update -p -D" usage seems not to work. - # I'm not sure what is going on. - if test "x$remote" = "xno"; then - if ${testcvs} -q update -p -D '1970-12-31 11:30 UT' file2 \ >${TESTDIR}/rcs4.tmp then @@ -11206,8 +12013,6 @@ next branch revision fail rcs-13 fi - fi # end of tests skipped for remote - # OK, now make sure cvs log doesn't have any trouble with the # newphrases and such. dotest rcs-14 "${testcvs} -q log file2" " @@ -11258,6 +12063,145 @@ date: 1971/01/01 08:00:05; author: joe; state: Exp; lines: ${PLUS}1 -1 rm -rf ${CVSROOT_DIRNAME}/first-dir ;; + rcs2) + # More date tests. Might as well do this as a separate + # test from "rcs", so that we don't need to perturb the + # "written by RCS 5.7" RCS file. + mkdir ${CVSROOT_DIRNAME}/first-dir + # Significance of various dates: + # * At least one Y2K standard refers to recognizing 9 Sep 1999 + # (as an example of a pre-2000 date, I guess). + # * At least one Y2K standard refers to recognizing 1 Jan 2001 + # (as an example of a post-2000 date, I guess). + # * Many Y2K standards refer to 2000 being a leap year. + cat <${CVSROOT_DIRNAME}/first-dir/file1,v +head 1.7; access; symbols; locks; strict; +1.7 date 2004.08.31.01.01.01; author sue; state; branches; next 1.6; +1.6 date 2004.02.29.01.01.01; author sue; state; branches; next 1.5; +1.5 date 2003.02.28.01.01.01; author sue; state; branches; next 1.4; +1.4 date 2001.01.01.01.01.01; author sue; state; branches; next 1.3; +1.3 date 2000.02.29.01.01.01; author sue; state; branches; next 1.2; +1.2 date 99.09.09.01.01.01; author sue; state; branches; next 1.1; +1.1 date 98.09.10.01.01.01; author sue; state; branches; next; +desc @a test file@ +1.7 log @@ text @head revision@ +1.6 log @@ text @d1 1 +a1 1 +2004 was a great year for leaping@ +1.5 log @@ text @d1 1 +a1 1 +2003 wasn't@ +1.4 log @@ text @d1 1 +a1 1 +two year hiatus@ +1.3 log @@ text @d1 1 +a1 1 +2000 is also a good year for leaping@ +1.2 log @@ text @d1 1 +a1 1 +Tonight we're going to party like it's a certain year@ +1.1 log @@ text @d1 1 +a1 1 +Need to start somewhere@ +EOF + # ' Match the 3rd single quote in the here doc -- for font-lock mode. + + dotest rcs2-1 "${testcvs} -q co first-dir" 'U first-dir/file1' + cd first-dir + + # 9 Sep 1999 + if ${testcvs} -q update -p -D '1999-09-09 11:30 UT' file1 \ + >${TESTDIR}/rcs4.tmp + then + dotest rcs2-2 "cat ${TESTDIR}/rcs4.tmp" \ +"Tonight we're going to party like it's a certain year" + else + fail rcs2-2 + fi + # 1 Jan 2001. + if ${testcvs} -q update -p -D '2001-01-01 11:30 UT' file1 \ + >${TESTDIR}/rcs4.tmp + then + dotest rcs2-3 "cat ${TESTDIR}/rcs4.tmp" \ +"two year hiatus" + else + fail rcs2-3 + fi + # 29 Feb 2000 + if ${testcvs} -q update -p -D '2000-02-29 11:30 UT' file1 \ + >${TESTDIR}/rcs4.tmp + then + dotest rcs2-4 "cat ${TESTDIR}/rcs4.tmp" \ +"2000 is also a good year for leaping" + else + fail rcs2-4 + fi + # 29 Feb 2003 is invalid + if ${testcvs} -q update -p -D '2003-02-29 11:30 UT' file1 \ + >${TESTDIR}/rcs4.tmp 2>&1 + then + fail rcs2-5 + else + dotest rcs2-5 "cat ${TESTDIR}/rcs4.tmp" \ +"${PROG} \[[a-z]* aborted\]: Can't parse date/time: 2003-02-29 11:30 UT" + fi + rm ${TESTDIR}/rcs4.tmp + + cd .. + rm -r first-dir + rm -rf ${CVSROOT_DIRNAME}/first-dir + ;; + + history) + # CVSROOT/history tests: + # history: various "cvs history" invocations + # basic2: Generating the CVSROOT/history file via CVS commands. + + # Put in some data for the history file (discarding what was + # there before). Note that this file format is fixed; the + # user may wish to analyze data from a previous version of + # CVS. If we phase out this format, it should be done + # slowly and carefully. + cat >${CVSROOT_DIRNAME}/CVSROOT/history </*0|ccvs||ccvs +M339cafae|nk||ccvs/src|1.229|sanity.sh +M339dc339|kingdon|~/work/*0|ccvs/src|1.231|sanity.sh +W33a6eada|anonymous|*4|ccvs/emx||Makefile.in +C3b235f50|kingdon||ccvs/emx|1.3|README +M3b23af50|kingdon|~/work/*0|ccvs/doc|1.281|cvs.texinfo +EOF + dotest history-1 "${testcvs} history -e -a" \ +"O 06/04 19:48 ${PLUS}0000 anonymous ccvs =ccvs= /\* +W 06/17 19:51 ${PLUS}0000 anonymous Makefile\.in ccvs/emx == /emx +M 06/10 21:12 ${PLUS}0000 kingdon 1\.231 sanity\.sh ccvs/src == ~/work/ccvs/src +C 06/10 11:51 ${PLUS}0000 kingdon 1\.3 README ccvs/emx == +M 06/10 17:33 ${PLUS}0000 kingdon 1\.281 cvs\.texinfo ccvs/doc == ~/work/ccvs/doc +M 06/10 01:36 ${PLUS}0000 nk 1\.229 sanity\.sh ccvs/src == " + if ${testcvs} history -e -a -D '10 Jun 1997 13:00 UT' \ + >${TESTDIR}/output.tmp + then + dotest history-2 "cat ${TESTDIR}/output.tmp" \ +"W 06/17 19:51 ${PLUS}0000 anonymous Makefile\.in ccvs/emx == /emx +M 06/10 21:12 ${PLUS}0000 kingdon 1\.231 sanity\.sh ccvs/src == ~/work/ccvs/src +C 06/10 11:51 ${PLUS}0000 kingdon 1\.3 README ccvs/emx == +M 06/10 17:33 ${PLUS}0000 kingdon 1\.281 cvs\.texinfo ccvs/doc == ~/work/ccvs/doc" + else + fail history-2 + fi + if ${testcvs} history -e -a -D '10 Jun 2001 13:00 UT' \ + >${TESTDIR}/output.tmp + then + # For reasons that are completely unclear to me, the number + # of spaces betwen "kingdon" and "1.281" is different than + # for the other tests. + dotest history-3 "cat ${TESTDIR}/output.tmp" \ +"M 06/10 17:33 ${PLUS}0000 kingdon 1\.281 cvs\.texinfo ccvs/doc == ~/work/ccvs/doc" + else + fail history-3 + fi + rm ${TESTDIR}/output.tmp + ;; + big) # Test ability to operate on big files. Intention is to @@ -11441,21 +12385,67 @@ done" # tests "should" not care about them... ;; - stamps) - # Test timestamps. + modes2) + # More tests of file permissions in the working directory + # and that sort of thing. + + # The usual setup, file first-dir/aa with two revisions. mkdir 1; cd 1 - dotest stamps-1 "${testcvs} -q co -l ." '' + dotest modes2-1 "${testcvs} -q co -l ." '' mkdir first-dir - dotest stamps-2 "${testcvs} add first-dir" \ + dotest modes2-2 "${testcvs} add first-dir" \ "Directory ${TESTDIR}/cvsroot/first-dir added to the repository" cd first-dir touch aa - echo '$''Id$' >kw - ls -l aa >${TESTDIR}/1/stamp.aa.touch - ls -l kw >${TESTDIR}/1/stamp.kw.touch - # "sleep 1" would suffice if we could assume ls --full-time, but - # that is as far as I know unique to GNU ls. Is there some POSIX.2 - # way to get the timestamp of a file, including the seconds? + dotest modes2-3 "${testcvs} add aa" \ +"${PROG} [a-z]*: scheduling file .aa. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest modes2-4 "${testcvs} -q ci -m add" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/aa,v +done +Checking in aa; +${TESTDIR}/cvsroot/first-dir/aa,v <-- aa +initial revision: 1\.1 +done" + echo "more money" >> aa + dotest modes2-5 "${testcvs} -q ci -m add" \ +"Checking in aa; +${TESTDIR}/cvsroot/first-dir/aa,v <-- aa +new revision: 1\.2; previous revision: 1\.1 +done" + + # OK, here is the test. The idea is to see what + # No_Difference does if it can't open the file. + # If we don't change the st_mtime, CVS doesn't even try to read + # the file. Note that some versions of "touch" require that we + # do this while the file is still writable. + touch aa + chmod a= aa + dotest_fail modes2-6 "${testcvs} -q update -r 1.1 aa" \ +"${PROG} \[update aborted\]: cannot open file aa for comparing: Permission denied" \ +"${PROG} \[update aborted\]: reading aa: Permission denied" + + chmod u+rwx aa + cd ../.. + rm -r 1 + rm -rf ${CVSROOT_DIRNAME}/first-dir + ;; + + stamps) + # Test timestamps. + mkdir 1; cd 1 + dotest stamps-1 "${testcvs} -q co -l ." '' + mkdir first-dir + dotest stamps-2 "${testcvs} add first-dir" \ +"Directory ${TESTDIR}/cvsroot/first-dir added to the repository" + cd first-dir + touch aa + echo '$''Id$' >kw + ls -l aa >${TESTDIR}/1/stamp.aa.touch + ls -l kw >${TESTDIR}/1/stamp.kw.touch + # "sleep 1" would suffice if we could assume ls --full-time, but + # that is as far as I know unique to GNU ls. Is there some POSIX.2 + # way to get the timestamp of a file, including the seconds? sleep 60 dotest stamps-3 "${testcvs} add aa kw" \ "${PROG} [a-z]*: scheduling file .aa. for addition @@ -11581,6 +12571,202 @@ done" rm -rf ${CVSROOT_DIRNAME}/first-dir ;; + perms) + # short cut around checking out and committing CVSROOT + rm -f ${CVSROOT_DIRNAME}/CVSROOT/config + echo 'PreservePermissions=yes' > ${CVSROOT_DIRNAME}/CVSROOT/config + chmod 444 ${CVSROOT_DIRNAME}/CVSROOT/config + + mkdir 1; cd 1 + dotest perms-1 "${testcvs} -q co -l ." '' + mkdir first-dir + dotest perms-2 "${testcvs} add first-dir" \ +"Directory ${TESTDIR}/cvsroot/first-dir added to the repository" + cd first-dir + + touch foo + chmod 431 foo + dotest perms-3 "${testcvs} add foo" \ +"${PROG} [a-z]*: scheduling file .foo. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest perms-4 "${testcvs} -q ci -m ''" \ +"RCS file: ${CVSROOT_DIRNAME}/first-dir/foo,v +done +Checking in foo; +${TESTDIR}/cvsroot/first-dir/foo,v <-- foo +initial revision: 1\.1 +done" + + # Test checking out files with different permissions. + cd ../.. + mkdir 2; cd 2 + dotest perms-5 "${testcvs} -q co first-dir" "U first-dir/foo" + cd first-dir + if test "$remote" = no; then + # PreservePermissions not yet implemented for remote. + dotest perms-6 "ls -l foo" "-r---wx--x .* foo" + fi + + cd ../.. + rm -rf 1 2 + rm -rf ${CVSROOT_DIRNAME}/first-dir + + rm -f ${CVSROOT_DIRNAME}/CVSROOT/config + touch ${CVSROOT_DIRNAME}/CVSROOT/config + chmod 444 ${CVSROOT_DIRNAME}/CVSROOT/config + ;; + + symlinks) + # short cut around checking out and committing CVSROOT + rm -f ${CVSROOT_DIRNAME}/CVSROOT/config + echo 'PreservePermissions=yes' > ${CVSROOT_DIRNAME}/CVSROOT/config + chmod 444 ${CVSROOT_DIRNAME}/CVSROOT/config + + mkdir 1; cd 1 + dotest symlinks-1 "${testcvs} -q co -l ." '' + mkdir first-dir + dotest symlinks-2 "${testcvs} add first-dir" \ +"Directory ${TESTDIR}/cvsroot/first-dir added to the repository" + cd first-dir + + dotest symlinks-2.1 "ln -s ${TESTDIR}/fumble slink" "" + dotest symlinks-3 "${testcvs} add slink" \ +"${PROG} [a-z]*: scheduling file .slink. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + if test "$remote" = yes; then + # Remote doesn't implement PreservePermissions, and in its + # absence the correct behavior is to follow the symlink. + dotest_fail symlinks-4 "${testcvs} -q ci -m ''" \ +"${PROG} \[commit aborted\]: reading slink: No such file or directory" + else + dotest symlinks-4 "${testcvs} -q ci -m ''" \ +"RCS file: ${CVSROOT_DIRNAME}/first-dir/slink,v +done +Checking in slink; +${TESTDIR}/cvsroot/first-dir/slink,v <-- slink +initial revision: 1\.1 +done" + + # Test checking out symbolic links. + cd ../.. + mkdir 2; cd 2 + dotest symlinks-5 "${testcvs} -q co first-dir" "U first-dir/slink" + cd first-dir + dotest symlinks-6 "ls -l slink" \ +"l[rwx\-]* .* slink -> ${TESTDIR}/fumble" + fi + + cd ../.. + rm -rf 1 2 + rm -rf ${CVSROOT_DIRNAME}/first-dir + + rm -f ${CVSROOT_DIRNAME}/CVSROOT/config + touch ${CVSROOT_DIRNAME}/CVSROOT/config + chmod 444 ${CVSROOT_DIRNAME}/CVSROOT/config + ;; + + hardlinks) + # short cut around checking out and committing CVSROOT + rm -f ${CVSROOT_DIRNAME}/CVSROOT/config + echo 'PreservePermissions=yes' > ${CVSROOT_DIRNAME}/CVSROOT/config + chmod 444 ${CVSROOT_DIRNAME}/CVSROOT/config + + mkdir 1; cd 1 + dotest hardlinks-1 "${testcvs} -q co -l ." '' + mkdir first-dir + dotest hardlinks-2 "${testcvs} add first-dir" \ +"Directory ${TESTDIR}/cvsroot/first-dir added to the repository" + cd first-dir + + # Make up some ugly filenames, to test that they get + # encoded properly in the delta nodes. Note that `dotest' screws + # up if some arguments have embedded spaces. + if touch aaaa + then + pass hardlinks-2.1 + else + fail hardlinks-2.1 + fi + + if ln aaaa b.b.b.b + then + pass hardlinks-2.2 + else + fail hardlinks-2.2 + fi + + if ln aaaa 'dd dd dd' + then + pass hardlinks-2.3 + else + fail hardlinks-2.3 + fi + + dotest hardlinks-3 "${testcvs} add [abd]*" \ +"${PROG} [a-z]*: scheduling file .aaaa. for addition +${PROG} [a-z]*: scheduling file .b\.b\.b\.b. for addition +${PROG} [a-z]*: scheduling file .dd dd dd. for addition +${PROG} [a-z]*: use .${PROG} commit. to add these files permanently" + dotest hardlinks-4 "${testcvs} -q ci -m ''" \ +"RCS file: ${CVSROOT_DIRNAME}/first-dir/aaaa,v +done +Checking in aaaa; +${TESTDIR}/cvsroot/first-dir/aaaa,v <-- aaaa +initial revision: 1\.1 +done +RCS file: ${CVSROOT_DIRNAME}/first-dir/b\.b\.b\.b,v +done +Checking in b\.b\.b\.b; +${TESTDIR}/cvsroot/first-dir/b\.b\.b\.b,v <-- b\.b\.b\.b +initial revision: 1\.1 +done +RCS file: ${CVSROOT_DIRNAME}/first-dir/dd dd dd,v +done +Checking in dd dd dd; +${TESTDIR}/cvsroot/first-dir/dd dd dd,v <-- dd dd dd +initial revision: 1\.1 +done" + # Test checking out hardlinked files. + cd ../.. + mkdir 2; cd 2 + if test "$remote" = yes; then + # Remote does not implement PreservePermissions. + dotest hardlinks-5 "${testcvs} -q co first-dir" \ +"U first-dir/aaaa +U first-dir/b\.b\.b\.b +U first-dir/dd dd dd" + cd first-dir + dotest hardlinks-6 "ls -l [abd]*" \ +"-[rwx\-]* *1 .* aaaa +-[rwx\-]* *1 .* b\.b\.b\.b +-[rwx\-]* *1 .* dd dd dd" + else + dotest hardlinks-5 "${testcvs} -q co first-dir" \ +"U first-dir/aaaa +U first-dir/b\.b\.b\.b +U first-dir/dd dd dd" + cd first-dir + # To make sure that the files are properly hardlinked, it + # would be nice to do `ls -i' and make sure all the inodes + # match. But I think that would require expr to support + # tagged regexps, and I don't think we can rely on that. + # So instead we just see that each file has the right + # number of links. -twp + dotest hardlinks-6 "ls -l [abd]*" \ +"-[rwx\-]* *3 .* aaaa +-[rwx\-]* *3 .* b\.b\.b\.b +-[rwx\-]* *3 .* dd dd dd" + fi + + cd ../.. + rm -rf 1 2 + rm -rf ${CVSROOT_DIRNAME}/first-dir + + rm -f ${CVSROOT_DIRNAME}/CVSROOT/config + touch ${CVSROOT_DIRNAME}/CVSROOT/config + chmod 444 ${CVSROOT_DIRNAME}/CVSROOT/config + ;; + sticky) # More tests of sticky tags, particularly non-branch sticky tags. # See many tests (e.g. multibranch) for ordinary sticky tag @@ -12131,24 +13317,11 @@ add a line on trunk after trunktag" "imported contents add a line on trunk add a line on trunk after trunktag" - # But diff thinks that HEAD is "brtag". Case (c) from - # cvs.texinfo (the "strange, maybe accidental" case). - dotest_fail head-brtag-diff "${testcvs} -q diff -c -r HEAD -r br1" \ -"Index: file1 -=================================================================== -RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v -retrieving revision 1\.3\.2\.1 -retrieving revision 1\.3\.2\.2 -diff -c -r1\.3\.2\.1 -r1\.3\.2\.2 -\*\*\* file1 [0-9/]* [0-9:]* 1\.3\.2\.1 ---- file1 [0-9/]* [0-9:]* 1\.3\.2\.2 -\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* -\*\*\* 2,4 \*\*\*\* ---- 2,5 ---- - add a line on trunk - add a line on trunk after trunktag - modify on branch -${PLUS} modify on branch after brtag" + + # CVS 1.9 and older thought that HEAD is "brtag" (this was + # noted as "strange, maybe accidental"). But "br1" makes a + # whole lot more sense. + dotest head-brtag-diff "${testcvs} -q diff -c -r HEAD -r br1" "" # With a nonbranch sticky tag on the trunk, HEAD is the head # of the trunk, I think. @@ -12160,24 +13333,23 @@ add a line on trunk" "imported contents add a line on trunk add a line on trunk after trunktag" - # Like head-brtag-diff, HEAD is the sticky tag. Similarly - # questionable. + # Like head-brtag-diff, there is a non-branch sticky tag. dotest_fail head-trunktag-diff \ "${testcvs} -q diff -c -r HEAD -r br1" \ "Index: file1 =================================================================== RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v -retrieving revision 1\.2 +retrieving revision 1\.3 retrieving revision 1\.3\.2\.2 -diff -c -r1\.2 -r1\.3\.2\.2 -\*\*\* file1 [0-9/]* [0-9:]* 1\.2 +diff -c -r1\.3 -r1\.3\.2\.2 +\*\*\* file1 [0-9/]* [0-9:]* 1\.3 --- file1 [0-9/]* [0-9:]* 1\.3\.2\.2 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\* -\*\*\* 1,2 \*\*\*\* +\*\*\* 1,3 \*\*\*\* --- 1,5 ---- imported contents add a line on trunk -${PLUS} add a line on trunk after trunktag + add a line on trunk after trunktag ${PLUS} modify on branch ${PLUS} modify on branch after brtag" @@ -12390,6 +13562,91 @@ done" rm -rf ${CVSROOT_DIRNAME}/first-dir ;; + tag8k) + # In cvs-1.9.27, there is a bug that can cause an abort. + # It happens when you commit a change to a ,v file that has + # just the right amount of tag/branch info to align one of the + # semicolons in the branch info to be on a 8k-byte boundary. + # The result: rcsbuf_getkey got an abort. This failure doesn't + # corrupt the ,v file -- that would be really serious. But it + # does leave stale write locks that have to be removed manually. + + mkdir 1 + cd 1 + + module=x + + : > junk + dotest tag8k-1 "$testcvs -Q import -m . $module X Y" '' + dotest tag8k-2 "$testcvs -Q co $module" '' + cd $module + + file=m + : > $file + dotest tag8k-3 "$testcvs add $file" \ +"${PROG} [a-z]*: scheduling file .$file. for addition +${PROG} [a-z]*: use .${PROG} commit. to add this file permanently" + dotest tag8k-4 "$testcvs -Q ci -m . $file" \ +"RCS file: ${TESTDIR}/cvsroot/$module/$file,v +done +Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +initial revision: 1\.1 +done" + + # It seems there have to be at least two versions. + echo a > $file + dotest tag8k-5 "$testcvs -Q ci -m . $file" \ +"Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +new revision: 1\.2; previous revision: 1\.1 +done" + + # Add just under 8K worth of tags. + t=TAG--------------------------------------------------------------------- + t=$t$t + t=$t$t$t$t$t + # Now $t is 720 bytes long. + + # Apply some tags with that long prefix. + dotest tag8k-6 "$testcvs -Q tag $t-0 $file" '' + dotest tag8k-7 "$testcvs -Q tag $t-1 $file" '' + dotest tag8k-8 "$testcvs -Q tag $t-2 $file" '' + dotest tag8k-9 "$testcvs -Q tag $t-3 $file" '' + dotest tag8k-10 "$testcvs -Q tag $t-4 $file" '' + dotest tag8k-11 "$testcvs -Q tag $t-5 $file" '' + dotest tag8k-12 "$testcvs -Q tag $t-6 $file" '' + dotest tag8k-13 "$testcvs -Q tag $t-7 $file" '' + dotest tag8k-14 "$testcvs -Q tag $t-8 $file" '' + dotest tag8k-15 "$testcvs -Q tag $t-9 $file" '' + dotest tag8k-16 "$testcvs -Q tag $t-a $file" '' + + # Determine the length of the author value. + name=`sed -n 's/.*; author \([^;]*\);.*/\1/p' ${TESTDIR}/cvsroot/$module/$file,v|head -1` + name_len=`expr length $name` + + # CAREFUL: this will lose if $name is longer than 16. + # Then, form a string of length 16 - $name_len. + add_len=`expr 16 - $name_len` + suffix=`expr substr 1234567890123456 1 $add_len` + + # Add a final tag with length chosen so that it will push the + # offset of the `;' in the 2nd occurrence of `;\tauthor' in the + # ,v file to exactly 8192. + dotest tag8k-17 "$testcvs -Q tag "x8bytes-$suffix" $file" '' + + # This commit would fail with 1.9.27. + echo a >> $file + dotest tag8k-18 "$testcvs -Q ci -m . $file" \ +"Checking in $file; +${TESTDIR}/cvsroot/$module/$file,v <-- $file +new revision: 1\.3; previous revision: 1\.2 +done" + cd ../.. + rm -r 1 + rm -rf ${CVSROOT_DIRNAME}/$module + ;; + admin) # More "cvs admin" tests. @@ -12401,6 +13658,7 @@ done" # For -o, see: # admin-22-o1 through admin-23 (various cases not involving ::) # binfiles2-o* (:rev, rev on trunk; rev:, deleting entire branch) + # basicb-o* (attempt to delete all revisions) # basica-o1 through basica-o3 (basic :: usage) # head-o1 (::branch, where this deletes a revision or is noop) # branches-o1 (::branch, similar, with different branch topology) @@ -12996,6 +14254,192 @@ text add a line on the branch @" + # Tests of cvs admin -n. Make use of the results of + # admin-1 through admin-25. + # FIXME: We probably shouldn't make use of those results; + # this test is way too long as it is. + + # tagtwo should be a revision + # + dotest admin-26-1 "${testcvs} admin -ntagtwo:tagone file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + # br1 should be a branch + # + dotest admin-26-2 "${testcvs} admin -nbr1:br file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + # Attach some tags using RCS versions + # + dotest admin-26-3 "${testcvs} admin -ntagthree:1.1 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + dotest admin-26-4 "${testcvs} admin -nbr2:1.1.2 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + dotest admin-26-5 "${testcvs} admin -nbr4:1.1.0.2 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + # Check results so far + # + dotest admin-26-6 "${testcvs} status -v file2" \ +"=================================================================== +File: file2 Status: Up-to-date + + Working revision: 1\.2.* + Repository revision: 1\.2 ${TESTDIR}/cvsroot/first-dir/file2,v + Sticky Tag: (none) + Sticky Date: (none) + Sticky Options: (none) + + Existing Tags: + br4 (branch: 1\.1\.2) + br2 (branch: 1\.1\.2) + tagthree (revision: 1\.1) + br1 (branch: 1\.1\.2) + tagtwo (revision: 1\.1) + tagone (revision: 1\.1) + br (branch: 1\.1\.2)" + + + # Add a couple more revisions + # + echo "nuthr_line" >> file2 + dotest admin-27-1 "${testcvs} commit -m nuthr_line file2" \ +"Checking in file2; +${TESTDIR}/cvsroot/first-dir/file2,v <-- file2 +new revision: 1\.3; previous revision: 1\.2 +done" + + echo "yet_another" >> file2 + dotest admin-27-2 "${testcvs} commit -m yet_another file2" \ +"Checking in file2; +${TESTDIR}/cvsroot/first-dir/file2,v <-- file2 +new revision: 1\.4; previous revision: 1\.3 +done" + + # Fail trying to reattach existing tag with -n + # + dotest admin-27-3 "${testcvs} admin -ntagfour:1.1 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + dotest_fail admin-27-4 "${testcvs} admin -ntagfour:1.3 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} [a-z]*: ${TESTDIR}/cvsroot/first-dir/file2,v: symbolic name tagfour already bound to 1\.1 +${PROG} [a-z]*: cannot modify RCS file for .file2." + + # Succeed at reattaching existing tag, using -N + # + dotest admin-27-5 "${testcvs} admin -Ntagfour:1.3 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +done" + + # Fail on some bogus operations + # Try to attach to nonexistant tag + # + dotest_fail admin-28-1 "${testcvs} admin -ntagsix:tagfive file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} \[[a-z]* aborted\]: tag .tagfive. does not exist" + + # Try a some nonexisting numeric target tags + # + dotest_fail admin-28-2 "${testcvs} admin -ntagseven:2.1 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} \[[a-z]* aborted\]: revision .2\.1. does not exist" + + dotest_fail admin-28-3 "${testcvs} admin -ntageight:2.1.2 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} \[[a-z]* aborted\]: revision .2\.1\.2. does not exist" + + # Try some invalid targets + # + dotest_fail admin-28-4 "${testcvs} admin -ntagnine:1.a.2 file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} \[[a-z]* aborted\]: tag .1\.a\.2. must start with a letter" + + dotest_fail admin-28-5 "${testcvs} admin -ntagten:BO+GUS file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} \[[a-z]* aborted\]: tag .BO${PLUS}GUS. does not exist" + + dotest_fail admin-28-6 "${testcvs} admin -nq.werty:tagfour file2" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v +${PROG} \[[a-z]* aborted\]: tag .q\.werty. must not contain the characters ..*" + + # Verify the archive + # + dotest admin-29 "cat ${TESTDIR}/cvsroot/first-dir/file2,v" \ +"head 1\.4; +access + auth3 + auth2 + foo; +symbols + tagfour:1\.3 + br4:1\.1\.0\.2 + br2:1\.1\.0\.2 + tagthree:1\.1 + br1:1\.1\.0\.2 + tagtwo:1\.1 + tagone:1\.1 + br:1\.1\.0\.2; +locks; strict; +comment @# @; + + +1\.4 +date [0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]; author ${username}; state Exp; +branches; +next 1\.3; + +1\.3 +date [0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]; author ${username}; state Exp; +branches; +next 1\.2; + +1\.2 +date [0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]; author ${username}; state Exp; +branches; +next ; + + +desc +@@ + + +1\.4 +log +@yet_another +@ +text +@add a line +nuthr_line +yet_another +@ + + +1\.3 +log +@nuthr_line +@ +text +@d3 1 +@ + + +1\.2 +log +@modify +@ +text +@d2 1 +@" + cd ../.. rm -r 1 rm -rf ${CVSROOT_DIRNAME}/first-dir @@ -13141,6 +14585,11 @@ ${PROG} [a-z]*: Rebuilding administrative file database" "fred has file a-lock locked for version 1\.1 ${PROG} [a-z]*: Pre-commit check failed ${PROG} \[[a-z]* aborted\]: correct above errors first!" + # OK, now test "cvs admin -l" in the case where someone + # else has the file locked. + dotest_fail reserved-13c "${testcvs} admin -l a-lock" \ +"RCS file: ${TESTDIR}/cvsroot/first-dir/a-lock,v +${PROG} \[[a-z]* aborted\]: Revision 1\.1 is already locked by fred" dotest reserved-14 "${testcvs} admin -u1.1 a-lock" \ "RCS file: ${TESTDIR}/cvsroot/first-dir/a-lock,v @@ -13152,10 +14601,25 @@ ${TESTDIR}/cvsroot/first-dir/a-lock,v <-- a-lock new revision: 1\.2; previous revision: 1\.1 done" + # Now test for a bug involving branches and locks + sed -e 's/locks; strict;/locks fred:1.2; strict;/' ${TESTDIR}/cvsroot/first-dir/a-lock,v > a-lock,v + chmod 644 ${TESTDIR}/cvsroot/first-dir/a-lock,v + dotest reserved-16 \ +"mv a-lock,v ${TESTDIR}/cvsroot/first-dir/a-lock,v" "" + chmod 444 ${TESTDIR}/cvsroot/first-dir/a-lock,v + dotest reserved-17 "${testcvs} -q tag -b br a-lock" "T a-lock" + dotest reserved-18 "${testcvs} -q update -r br a-lock" "" + echo edit it >>a-lock + dotest reserved-19 "${testcvs} -q ci -m modify a-lock" \ +"Checking in a-lock; +${TESTDIR}/cvsroot/first-dir/a-lock,v <-- a-lock +new revision: 1\.2\.2\.1; previous revision: 1\.2 +done" + # undo commitinfo changes cd ../CVSROOT echo '# vanilla commitinfo' >commitinfo - dotest reserved-16 "${testcvs} -q ci -m back commitinfo" \ + dotest reserved-cleanup-1 "${testcvs} -q ci -m back commitinfo" \ "Checking in commitinfo; ${TESTDIR}/cvsroot/CVSROOT/commitinfo,v <-- commitinfo new revision: 1\.3; previous revision: 1\.2 diff --git a/contrib/cvs/src/server.c b/contrib/cvs/src/server.c index a005646..f6e64a5 100644 --- a/contrib/cvs/src/server.c +++ b/contrib/cvs/src/server.c @@ -42,8 +42,20 @@ static Key_schedule sched; #ifdef HAVE_GSSAPI #include + +#ifdef HAVE_GSSAPI_H +#include +#endif +#ifdef HAVE_GSSAPI_GSSAPI_H #include +#endif +#ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H #include +#endif + +#ifndef HAVE_GSS_C_NT_HOSTBASED_SERVICE +#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name +#endif /* We use Kerberos 5 routines to map the GSSAPI credential to a user name. */ @@ -366,7 +378,8 @@ mkdir_p (dir) int saved_errno = errno; if (saved_errno != EEXIST - && (saved_errno != EACCES || !isdir (q))) + && ((saved_errno != EACCES && saved_errno != EROFS) + || !isdir (q))) { retval = saved_errno; goto done; @@ -635,6 +648,18 @@ server_pathname_check (path) and is unlikely to do us any good here. It also is probably capable of being a security hole in the anonymous readonly case. */ if (isabsolute (path)) + /* Giving an error is actually kind of a cop-out, in the sense + that it would be nice for "cvs co -d /foo/bar/baz" to work. + A quick fix in the server would be requiring Max-dotdot of + at least one if pathnames are absolute, and then putting + /abs/foo/bar/baz in the temp dir beside the /d/d/d stuff. + A cleaner fix in the server might be to decouple the + pathnames we pass back to the client from pathnames in our + temp directory (this would also probably remove the need + for Max-dotdot). A fix in the client would have the client + turn it into "cd /foo/bar; cvs co -d baz" (more or less). + This probably has some problems with pathnames which appear + in messages. */ error (1, 0, "absolute pathname `%s' illegal for server", path); if (pathname_levels (path) > max_dotdot_limit) { @@ -2256,6 +2281,9 @@ error \n"); /* We shouldn't have any partial lines from cvs_output and cvs_outerr, but we handle them here in case there is a bug. */ + /* FIXME: appending a newline, rather than using "MT" as we + do in the child process, is probably not really a very good + way to "handle" them. */ if (! buf_empty_p (saved_output)) { buf_append_char (saved_output, '\n'); @@ -2326,6 +2354,19 @@ error \n"); exitstatus = (*command) (argument_count, argument_vector); + /* Output any partial lines. If the client doesn't support + "MT", we just throw out the partial line, like old versions + of CVS did, since the protocol can't support this. */ + if (supported_response ("MT") && ! buf_empty_p (saved_output)) + { + buf_output0 (protocol, "MT text "); + buf_append_buffer (protocol, saved_output); + buf_output (protocol, "\n", 1); + buf_send_counted (protocol); + } + /* For now we just discard partial lines on stderr. I suspect + that CVS can't write such lines unless there is a bug. */ + /* * When we exit, that will close the pipes, giving an EOF to * the parent. @@ -2840,8 +2881,9 @@ server_register (name, version, timestamp, options, tag, date, conflict) (void) fprintf (stderr, "%c-> server_register(%s, %s, %s, %s, %s, %s, %s)\n", (server_active) ? 'S' : ' ', /* silly */ - name, version, timestamp, options, tag ? tag : "", - date ? date : "", conflict ? conflict : ""); + name, version, timestamp ? timestamp : "", options, + tag ? tag : "", date ? date : "", + conflict ? conflict : ""); } if (entries_line != NULL) @@ -3071,21 +3113,21 @@ static void serve_remove (arg) char *arg; { - do_cvs_command ("cvsremove", cvsremove); + do_cvs_command ("remove", cvsremove); } static void serve_status (arg) char *arg; { - do_cvs_command ("status", status); + do_cvs_command ("status", cvsstatus); } static void serve_rdiff (arg) char *arg; { - do_cvs_command ("patch", patch); + do_cvs_command ("rdiff", patch); } static void @@ -3354,6 +3396,17 @@ server_modtime (finfo, vers_ts) /* See server.h for description. */ +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +/* Need to prototype because mode_t might be smaller than int. */ +void +server_updated ( + struct file_info *finfo, + Vers_TS *vers, + enum server_updated_arg4 updated, + mode_t mode, + unsigned char *checksum, + struct buffer *filebuf) +#else void server_updated (finfo, vers, updated, mode, checksum, filebuf) struct file_info *finfo; @@ -3362,6 +3415,7 @@ server_updated (finfo, vers, updated, mode, checksum, filebuf) mode_t mode; unsigned char *checksum; struct buffer *filebuf; +#endif { if (noexec) { @@ -3580,7 +3634,7 @@ CVS server internal error: unhandled case in server_updated"); if ((updated == SERVER_UPDATED || updated == SERVER_PATCHED || updated == SERVER_RCS_DIFF) - && filebuf != NULL + && filebuf == NULL /* But if we are joining, we'll need the file when we call join_file. */ && !joining ()) @@ -4779,25 +4833,23 @@ check_password (username, password, repository) /* No cvs password found, so try /etc/passwd. */ const char *found_passwd = NULL; + struct passwd *pw; #ifdef HAVE_GETSPNAM - struct spwd *pw; + struct spwd *spw; - pw = getspnam (username); - if (pw != NULL) + spw = getspnam (username); + if (spw != NULL) { - found_passwd = pw->sp_pwdp; + found_passwd = spw->sp_pwdp; } -#else - struct passwd *pw; +#endif - pw = getpwnam (username); - if (pw != NULL) + if (found_passwd == NULL && (pw = getpwnam (username)) != NULL) { found_passwd = pw->pw_passwd; } -#endif - if (pw == NULL) + if (found_passwd == NULL) { printf ("E Fatal error, aborting.\n\ error 0 %s: no such user\n", username); @@ -4815,8 +4867,9 @@ error 0 %s: no such user\n", username); exit (EXIT_FAILURE); } - if (found_passwd && *found_passwd) + if (*found_passwd) { + /* user exists and has a password */ host_user = ((! strcmp (found_passwd, crypt (password, found_passwd))) ? username : NULL); @@ -4824,11 +4877,14 @@ error 0 %s: no such user\n", username); } else if (password && *password) { + /* user exists and has no system password, but we got + one as parameter */ host_user = username; goto handle_return; } else { + /* user exists but has no password at all */ host_user = NULL; goto handle_return; } @@ -5186,7 +5242,7 @@ gserver_authenticate_connection () tok_in.value = buf; tok_in.length = strlen (buf); - if (gss_import_name (&stat_min, &tok_in, gss_nt_service_name, + if (gss_import_name (&stat_min, &tok_in, GSS_C_NT_HOSTBASED_SERVICE, &server_name) != GSS_S_COMPLETE) error (1, 0, "could not import GSSAPI service name %s", buf); @@ -5587,7 +5643,7 @@ cvs_output_binary (str, len) if (error_use_protocol) buf = buf_to_net; - else if (server_active) + else buf = protocol; if (!supported_response ("Mbinary")) diff --git a/contrib/cvs/src/status.c b/contrib/cvs/src/status.c index 98be085..541a969 100644 --- a/contrib/cvs/src/status.c +++ b/contrib/cvs/src/status.c @@ -31,7 +31,7 @@ static const char *const status_usage[] = }; int -status (argc, argv) +cvsstatus (argc, argv) int argc; char **argv; { diff --git a/contrib/cvs/src/tag.c b/contrib/cvs/src/tag.c index a97da5c..a5b8794 100644 --- a/contrib/cvs/src/tag.c +++ b/contrib/cvs/src/tag.c @@ -275,8 +275,17 @@ check_fileproc (callerdat, finfo) error (0, 0, "nothing known about %s", finfo->file); return (1); } - p->data = RCS_getversion(vers->srcfile, numtag, date, force_tag_match, - (int *) NULL); + + /* Here we duplicate the calculation in tag_fileproc about which + version we are going to tag. There probably are some subtle races + (e.g. numtag is "foo" which gets moved between here and + tag_fileproc). */ + if (numtag == NULL && date == NULL) + p->data = xstrdup (vers->vn_user); + else + p->data = RCS_getversion (vers->srcfile, numtag, date, + force_tag_match, NULL); + if (p->data != NULL) { int addit = 1; @@ -377,7 +386,7 @@ pretag_proc(repository, filter) run_arg (delete_flag ? "del" : force_tag_move ? "mov" : "add"); run_arg (repository); walklist(tlist, pretag_list_proc, NULL); - return (run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY)); + return (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)); } static void diff --git a/contrib/cvs/src/update.c b/contrib/cvs/src/update.c index 2e7bda3..d25eeb2 100644 --- a/contrib/cvs/src/update.c +++ b/contrib/cvs/src/update.c @@ -530,7 +530,6 @@ get_linkinfo_proc (callerdat, finfo) hlinfo->status = (Ctype) 0; /* is this dumb? */ hlinfo->checked_out = 0; - hlinfo->links = NULL; linkp->data = (char *) hlinfo; @@ -1639,8 +1638,6 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum) { char *diff_options; - /* FIXME: It might be better to come up with a diff library - which can be shared with the diffutils. */ /* If the client does not support the Rcs-diff command, we send a context diff, and the client must invoke patch. That approach was problematical for various reasons. The @@ -1649,8 +1646,10 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum) program. */ if (! rcs_diff_patches) { - /* We use -c, not -u, because we have no way of knowing - which DIFF is in use. */ + /* 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"; } else @@ -1922,14 +1921,21 @@ merge_file (finfo, vers) if (strcmp (vers->options, "-V4") == 0) vers->options[0] = '\0'; - (void) time (&last_register_time); + + /* 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, vers->ts_rcs, vers->options, - vers->tag, vers->date, cp); + } + Register (finfo->entries, finfo->file, vers->vn_rcs, + "Result of merge", vers->options, vers->tag, + vers->date, cp); if (cp) free (cp); } @@ -2428,25 +2434,27 @@ join_file (finfo, vers) free (rev1); free (rev2); -#ifdef SERVER_SUPPORT - /* - * If we're in server mode, then we need to re-register the file - * even if there were no conflicts (status == 0). - * This tells server_updated() to send the modified file back to - * the client. - */ - if (status == 1 || (status == 0 && server_active)) -#else - if (status == 1) -#endif + /* The file has changed, but if we just checked it out it may + still have the same timestamp it did when it was first + registered above in checkout_file. We register it again with a + dummy timestamp to make sure that later runs of CVS will + recognize that it has changed. + + We don't actually need to register again if we called + 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->ts_rcs, vers->options, - vers->tag, vers->date, cp); + } + Register (finfo->entries, finfo->file, vers->vn_rcs, + "Result of merge", vers->options, vers->tag, + vers->date, cp); if (cp) free(cp); } @@ -2494,8 +2502,8 @@ special_file_mismatch (finfo, rev1, rev2) dev_t rev1_dev, rev2_dev; char *rev1_symlink = NULL; char *rev2_symlink = NULL; - char *rev1_hardlinks = NULL; - char *rev2_hardlinks = NULL; + List *rev1_hardlinks; + List *rev2_hardlinks; int check_uids, check_gids, check_modes; int result; @@ -2533,7 +2541,7 @@ special_file_mismatch (finfo, rev1, rev2) if (S_ISBLK (rev1_mode) || S_ISCHR (rev1_mode)) rev1_dev = sb.st_rdev; } - rev1_hardlinks = list_files_linked_to (finfo->file); + rev1_hardlinks = list_linked_files_on_disk (finfo->file); } else { @@ -2584,11 +2592,9 @@ special_file_mismatch (finfo, rev1, rev2) finfo->file, rev1, ftype); } - n = findnode (vp->other_delta, "hardlinks"); - if (n == NULL) - rev1_hardlinks = xstrdup (""); - else - rev1_hardlinks = xstrdup (n->data); + rev1_hardlinks = vp->hardlinks; + if (rev1_hardlinks == NULL) + rev1_hardlinks = getlist(); } } @@ -2608,7 +2614,7 @@ special_file_mismatch (finfo, rev1, rev2) if (S_ISBLK (rev2_mode) || S_ISCHR (rev2_mode)) rev2_dev = sb.st_rdev; } - rev2_hardlinks = list_files_linked_to (finfo->file); + rev2_hardlinks = list_linked_files_on_disk (finfo->file); } else { @@ -2659,11 +2665,9 @@ special_file_mismatch (finfo, rev1, rev2) finfo->file, rev2, ftype); } - n = findnode (vp->other_delta, "hardlinks"); - if (n == NULL) - rev2_hardlinks = xstrdup (""); - else - rev2_hardlinks = xstrdup (n->data); + rev2_hardlinks = vp->hardlinks; + if (rev2_hardlinks == NULL) + rev2_hardlinks = getlist(); } } @@ -2744,7 +2748,7 @@ special_file_mismatch (finfo, rev1, rev2) } /* Compare hard links. */ - if (strcmp (rev1_hardlinks, rev2_hardlinks) != 0) + if (compare_linkage_lists (rev1_hardlinks, rev2_hardlinks) == 0) { error (0, 0, "%s: hard linkage of %s and %s do not match", finfo->file, @@ -2759,9 +2763,9 @@ special_file_mismatch (finfo, rev1, rev2) if (rev2_symlink != NULL) free (rev2_symlink); if (rev1_hardlinks != NULL) - free (rev1_hardlinks); + dellist (&rev1_hardlinks); if (rev2_hardlinks != NULL) - free (rev2_hardlinks); + dellist (&rev2_hardlinks); return result; #else diff --git a/contrib/cvs/src/version.c b/contrib/cvs/src/version.c index f386895..479e5e6 100644 --- a/contrib/cvs/src/version.c +++ b/contrib/cvs/src/version.c @@ -12,7 +12,8 @@ #include "cvs.h" -char *version_string = "\nConcurrent Versions System (CVS) 1.9.26"; +/* NOTE: remember to remove `Halibut' when patching this code. */ +char *version_string = "\nConcurrent Versions System (CVS) 1.10 `Halibut'"; #ifdef CLIENT_SUPPORT #ifdef SERVER_SUPPORT diff --git a/contrib/cvs/src/wrapper.c b/contrib/cvs/src/wrapper.c index 645ce5c..e7c540d 100644 --- a/contrib/cvs/src/wrapper.c +++ b/contrib/cvs/src/wrapper.c @@ -395,6 +395,11 @@ wrap_add (line, isTemp) *line='\0'; switch(opt){ case 'f': + /* Before this is reenabled, need to address the problem in + commit.c (see http://www.cyclic.com/cvs/dev-wrap.txt). */ + error (1, 0, + "-t/-f wrappers not supported by this version of CVS"); + if(e.fromcvsFilter) free(e.fromcvsFilter); /* FIXME: error message should say where the bad value @@ -404,6 +409,11 @@ wrap_add (line, isTemp) error (1, 0, "Correct above errors first"); break; case 't': + /* Before this is reenabled, need to address the problem in + commit.c (see http://www.cyclic.com/cvs/dev-wrap.txt). */ + error (1, 0, + "-t/-f wrappers not supported by this version of CVS"); + if(e.tocvsFilter) free(e.tocvsFilter); /* FIXME: error message should say where the bad value -- cgit v1.1