Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Cederqvist P.Version management with CVS 1.11.21.pdf
Скачиваний:
4
Добавлен:
23.08.2013
Размер:
1.11 Mб
Скачать

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

Соседние файлы в предмете Электротехника