- •Overview
- •What is CVS?
- •What is CVS not?
- •A sample session
- •Getting the source
- •Committing your changes
- •Cleaning up
- •The Repository
- •Telling CVS where your repository is
- •How data is stored in the repository
- •File permissions
- •The attic
- •The CVS directory in the repository
- •CVS locks in the repository
- •How data is stored in the working directory
- •Multiple repositories
- •Creating a repository
- •Backing up a repository
- •Moving a repository
- •Remote repositories
- •Server requirements
- •Connecting with rsh
- •Direct connection with password authentication
- •Setting up the server for password authentication
- •Using the client with password authentication
- •Security considerations with password authentication
- •Direct connection with GSSAPI
- •Direct connection with Kerberos
- •Connecting with fork
- •Read-only repository access
- •Temporary directories for the server
- •Starting a project with CVS
- •Creating Files From Other Version Control Systems
- •Creating a directory tree from scratch
- •Revisions
- •Revision numbers
- •Versions, revisions and releases
- •Assigning revisions
- •Specifying what to tag from the working directory
- •Specifying what to tag by date or revision
- •Deleting, moving, and renaming tags
- •Sticky tags
- •Branching and merging
- •What branches are good for
- •Creating a branch
- •Accessing branches
- •Branches and revisions
- •Magic branch numbers
- •Merging an entire branch
- •Merging from a branch several times
- •Merging and keywords
- •Recursive behavior
- •Removing directories
- •The Normal way to Rename
- •Moving and renaming directories
- •History browsing
- •Log messages
- •The history database
- •Multiple developers
- •File status
- •Informing others about commits
- •Several developers simultaneously attempting to run CVS
- •Telling CVS to notify you
- •Information about who is watching and editing
- •Using watches with old versions of CVS
- •Choosing between reserved or unreserved checkouts
- •Revision management
- •When to commit?
- •Keyword substitution
- •Keyword List
- •Using keywords
- •Avoiding substitution
- •Substitution modes
- •Problems with the $Log$ keyword.
- •Tracking third-party sources
- •Updating with the import command
- •Reverting to the latest vendor release
- •How to handle keyword substitution with cvs import
- •Multiple vendor branches
- •How your build system interacts with CVS
- •Special Files
- •Index
Chapter 7: Adding, removing, and renaming files and directories |
55 |
$ cd test
$ cvs remove -f *.c
cvs remove: scheduling a.c for removal cvs remove: scheduling b.c for removal
cvs remove: use ’cvs commit’ to remove these files permanently $ cvs ci -m "Removed unneeded files"
cvs commit: Examining . cvs commit: Committing .
If you execute remove for a file, and then change your mind before you commit, you can undo the remove with an add command.
$ ls
CVS ja.h oj.c $ rm oj.c
$ cvs remove oj.c
cvs remove: scheduling oj.c for removal
cvs remove: use ’cvs commit’ to remove this file permanently $ cvs add oj.c
U oj.c
cvs add: oj.c, version 1.1.1.1, resurrected
If you realize your mistake before you run the remove command you can use update to resurrect the file:
$ rm oj.c
$ cvs update oj.c
cvs update: warning: oj.c was lost U oj.c
When you remove a file it is removed only on the branch which you are working on (see Chapter 5 [Branching and merging], page 41). You can later merge the removals to another branch if you want (see Section 5.9 [Merging adds and removals], page 47).
7.3 Removing directories
In concept, removing directories is somewhat similar to removing files—you want the directory to not exist in your current working directories, but you also want to be able to retrieve old releases in which the directory existed.
The way that you remove a directory is to remove all the files in it. You don’t remove the directory itself; there is no way to do that. Instead you specify the ‘-P’ option to cvs update or cvs checkout, which will cause cvs to remove empty directories from working directories. (Note that cvs export always removes empty directories.) Probably the best way to do this is to always specify ‘-P’; if you want an empty directory then put a dummy file (for example ‘.keepme’) in it to prevent ‘-P’ from removing it.
Note that ‘-P’ is implied by the ‘-r’ or ‘-D’ options of checkout. This way, cvs will be able to correctly create the directory or not depending on whether the particular version you are checking out contains any files in that directory.
56 |
CVS—Concurrent Versions System v1.11.21 |
7.4 Moving and renaming files
Moving files to a di erent directory or renaming them is not di cult, but some of the ways in which this works may be non-obvious. (Moving or renaming a directory is even harder. See Section 7.5 [Moving directories], page 57.).
The examples below assume that the file old is renamed to new.
7.4.1 The Normal way to Rename
The normal way to move a file is to copy old to new, and then issue the normal cvs commands to remove old from the repository, and add new to it.
$ mv old new
$ cvs remove old $ cvs add new
$ cvs commit -m "Renamed old to new" old new
This is the simplest way to move a file, it is not error-prone, and it preserves the history of what was done. Note that to access the history of the file you must specify the old or the new name, depending on what portion of the history you are accessing. For example, cvs log old will give the log up until the time of the rename.
When new is committed its revision numbers will start again, usually at 1.1, so if that bothers you, use the ‘-r rev’ option to commit. For more information see Section 4.3 [Assigning revisions], page 33.
7.4.2 Moving the history file
This method is more dangerous, since it involves moving files inside the repository. Read this entire section before trying it out!
$ cd $CVSROOT/dir $ mv old,v new,v
Advantages:
•The log of changes is maintained intact.
•The revision numbers are not a ected.
Disadvantages:
•Old releases cannot easily be fetched from the repository. (The file will show up as new even in revisions from the time before it was renamed).
•There is no log information of when the file was renamed.
•Nasty things might happen if someone accesses the history file while you are moving it. Make sure no one else runs any of the cvs commands while you move it.
7.4.3 Copying the history file
This way also involves direct modifications to the repository. It is safe, but not without drawbacks.
#Copy the rcs file inside the repository $ cd $CVSROOT/dir
$ cp old,v new,v
#Remove the old file