U E D R , A S I H C RSS

Pragmatic Version Control WithCVS/CommonCVS Commands

1. Common CVS Commands

이 장에서는 우리가 cvs를 이용해서 하는 작업의 90퍼센트를 차지하는 대부분의 명령어를 다룬다.
(이번장이 이 책에서 가장 페이지수가 많은 장이다. 대략 4~50 페이지 정도이다. 이정도까지만 보면 cvs 사용하는데 큰 무리는 없을 듯하다.)

1.1. Checking Things Out

~cpp 
root@eunviho:~/tmp2# cvs co sesame sesame2
cvs checkout: Updating sesame
U sesame/color.txt
U sesame/number.txt
cvs checkout: Updating sesame2
U sesame2/color.txt
U sesame2/number.txt
cvs server 에서 sesame sesame2 2개의 모듈이나 하위 모듈을 하나이 상의 동일한 이름의 지역 디렉토리로 가져옮

~cpp 
root@eunviho:~/tmp2# cvs co sesame2/sesame2
cvs checkout: Updating sesame2/sesame2
U sesame2/sesame2/color.txt
U sesame2/sesame2/number.txt
cvs checkout: Updating sesame2/sesame2/templates
U sesame2/sesame2/templates/test.test
저장소에 존재하는 하위 모듈의 디렉토리안에서 일부분만을 체크아웃한다.

-r : 특정한 개발판을 체크아웃. 버전번호 혹은 꼬리표로 지정.
CVS는 HEAD, BASE라는 2개의 꼬리표를 자동으로 제공한다.
HEAD : 저장소에서 가장 최신 버전. 대부분의 명령어의 기본이다.
BASE : 마지막으로 현재 디렉토리에 체크아웃된 개정판
-D : 날짜를 이용해서 체크아웃.

~cpp 
root@eunviho:~/tmp2# cvs log sesame
cvs log: Logging sesame

RCS file: /home/CVSHOME/sesame/color.txt,v
Working file: sesame/color.txt
head: 1.2
branch:
locks: strict
access list:
symbolic names:
        initial: 1.1.1.1
        sesame: 1.1.1
keyword substitution: kv
total revisions: 3;     selected revisions: 3
description:
----------------------------
revision 1.2
date: 2005-08-02 13:16:58 +0000;  author: sapius;  state: Exp;  lines: +4 -0
°í°´ÀÌ 4¤¡Áö »öÀ» ´õ ¿øÇÔ
----------------------------
revision 1.1
date: 2005-08-02 05:50:14 +0000;  author: sapius;  state: Exp;
branches:  1.1.1;
Initial revision
----------------------------
revision 1.1.1.1
date: 2005-08-02 05:50:14 +0000;  author: sapius;  state: Exp;  lines: +0 -0
 
=============================================================================
.
.
.
root@eunviho:~/tmp2# cvs co -r 1.1 sesame
cvs checkout: Updating sesame
U sesame/color.txt
U sesame/number.txt
파일의 내용을 확인하면 checkout 된 파일이 1.1버전의 것임을 확인할 수 있다.

cvs 가 인식하는 날짜의 형태
ISO8601 2003-06-04
20030604
2003-06-04 20:12
2003-06-04T20:12
2003-06-04 20:12Z
2003-06-05 20:12:00-0500
E-Mail format Mon Jun 9 17:12:56 CDT 2003
Mon, Jun 9 17:12:56 2003
Jun 9 17:12:56 2003
June 9, 2003
Relative 1 day ago
27 minutes ago
last monday
yesterday
third week ago

1.2. Keeping Up To Date

다수의 프로그래머들이 프로젝트를 진행하는 상황하에서는 내가 프로그램을 갱신하고 있는 동안 다른 프로그래머들도 프로그램의 갱신을 할 가능성이 대단히 높다. 만약 갱신주기가 길어진다면 프로그래머가 처리해야할 merge 작업이 상당할 것이다. 때문에 주기적으로 프로젝트를 checkout 하는 것이 중요하다.

cvs update -d files or directory : 현재 디렉토리에 존재하는 모든 파일 폴더를 저장소의 최신버전으로 체크아웃. -d 옵션은 추가된 디렉토리가 존재하는 경우에 cvs가 현재 폴더에 자동으로 폴더를 만들어서 체크아웃 시킨다.
~cpp 
root@eunviho:~/tmpdir/sesame# cvs update -d template
cvs update: Updating template
U template/file1.java
root@eunviho:~/tmpdir/sesame# cvs update
cvs update: Updating .
U number.txt
cvs update: Updating template
update 도중에는 변경된 사항에 대한 특이사항의 정보가 같이 출력된다.
다음은 그러한 예문이다.
~cpp 
StarterKit> cvs update
? SourceCode/tmpdoc.ilg
? SourceCode/tmpdoc.toc
cvs server: Updating .
RCS file: /home/CVSROOT/PP/doc/StarterKit/pragprog.sty,v
retrieving revision 1.16
retrieving revision 1.17
Merging differences between 1.16 and 1.17 into pragprog.sty
M pragprog.sty
cvs server: Updating SourceCode
A SourceCode/CommonCommands.tip
M SourceCode/HowTo.tip
A SourceCode/Releases.tip
cvs server: Updating SourceCode/images
cvs server: Updating UnitTest
P UnitTest/DesignIssues.tip
U UnitTest/InAProject.tip
P UnitTest/Introduction.tip
cvs server: Updating UnitTest/code
U UnitTest/code/Age.java
U UnitTest/code/TestMyStack.java
U UnitTest/code/testdata.txt
cvs server: Updating UnitTest/code/rev1
cvs server: Updating UnitTest/code/rev2
cvs server: Updating UnitTest/code/rev3
cvs server: Updating util
? : 작업공간에는 존재하나 CVS가 알지못하는 파일
A : 지역에서 추가되었으나 아직 저장소에 체크인 안됨
M : 지역에서 수정된 파일
U,P : 저장소에 존재하는 버전이 지역 공간의 버전보다 최신이어서 갱신됨
C : 파일의 변합중에 충돌을 일으킴


~cpp 
cvs 의 동작방식의 이해
cvs 는 단일 명령이 아니라 여러 하위 시스템의 집합체로 이해하는 것이 편하다.
예를 들어서

cvs -q -d /home/CVSHOME checkout -d temp
    -- ----------------          -------
    |          |                     |
quiet mode repository      checkout destination

위와 같이 동일한 옵션이지만 위치에 따라서 그 의미하는 바가 다른 결과가 나온다.

1.3. Adding Files and Directories

cvs add : 파일이나 디렉토리를 저장소에 추가한다.
~cpp 
root@eunviho:~/tmpdir/sesame# cvs add template2
Directory /home/CVSHOME/sesame/template2 added to the repository

root@eunviho:~/tmpdir/sesame# cd template2/

root@eunviho:~/tmpdir/sesame/template2# cvs add test.txt  
cvs add: scheduling file `test.txt' for addition
cvs add: use `cvs commit' to add this file permanently

root@eunviho:~/tmpdir/sesame/template2# cvs commit -m "new file added"
cvs commit: Examining .
/home/CVSHOME/sesame/template2/test.txt,v  <--  test.txt
initial revision: 1.1

1.3.1. CVS and binary files

CVS는 프로그램 소스 코드, XML 등 텍스트 파일을 위주로해서 설계되었다.
  • 바뀐 부분만을 저장하기 때문에 전체 리비전된 소스를 다 가지면서도 용량이 절약
  • 유닉스, 윈도우의 줄 구분문자를 구별한다.
  • 특정 키워드를 대체하는 방법으로 파일에 주석을 달아준다. (비추천)

하지만 바이너리의 경우에는 문제가 발생한다.
  • 바이너리를 대상으로는 미동작
  • 줄바꿈이 없는 바이너리에서 만약 윈도우식의 바이너리 부분을 유닉스 식으로 바꾼다면 바이너리가 깨질 것이다.
  • 바이너리 파일에 CVS 키워드가 들어있다면 이것이 치환되어서 문제가 발생하게 된다.

cvs add -kb File : 지정된 파일에 대해서는 개정판 마디 파일의 전체를 저장하고 기타 처리를 하지 않는다.

만약 바이너리 파일을 -kb옵션을 주지 않은 상태에서 add 시켰다면 이를 바꾸는 방법도 존재한다.

마땅한 마이너리가 없어서 책의 내용을 이용
~cpp 
work> cvs add DataFormat.doc #<-- forgot the -kb option
cvs add: scheduling file ‘DataFormat.doc’ for addition
cvs add: use ’cvs commit’ to add this file permanently

work> mv DataFormat.doc Temp.doc
work> cvs remove DataFormat.doc
cvs remove: removed ‘DataFormat.doc’

work> mv Temp.doc DataFormat.doc
work> cvs add -kb DataFormat.doc #<-- use the option
cvs add: scheduling file ‘DataFormat.doc’ for addition
cvs add: use ’cvs commit’ to add this file permanently

work> cvs commit -m "Add new data format document"

위와는 다르게 -kb설정을 하지 않은 상태에서 checkout을 이미 한 상태라면
다음과 같은 과정을 통해서 복구가 가능하다.
~cpp 
work> # reset the flag in the repository
work> cvs admin -kb DataFormat.doc
work> # then reset the flags in our workspace
work> cvs update -A DataFormat.doc
work> # copy a known good copy over this file
work> cp ?/docs/DataFormat.doc DataFormat.doc
work> # and save this back in the repository
work> cvs commit -m "Reset -kb flag"

note) 바이너리를 자주 사용한다면 cvswrappers 에 대해서 알아보자.
BOOK 책의 76페이지에 존재한다.

1.4. Ignoring Certain Files

개발을 하는 도중에는 여러개의 중간 단계의 파일들(.obj, .class 등등)이 생성된다. 이런 파일은 굳지 CVS 저장소에 보관하는 것이 아니라 로컬에 저장해 두고 사용자가 필요할 때마다 새로 생성시키는 것이 옳은 일이다. 다행히 cvs 는 이러한 일을 설정하는 것이 가능하다.
.cvsignore file
~cpp 
dummy.java
*.class
*.log
*.obj
를 로컬 작업공간에 저장해두면 저장된 .cvsignore 를 기반해서 cvs는 그런 파일을 무시하게된다.
이렇게 저장된 .cvsignore 를 저장소에 올려두면 그 저장소를 방문하는 모든 사용자들도 동일한 무시 설정하에서 작업하는 것이 가능하다.
~cpp 
root@eunviho:~/tmpdir/sesame#cvs add .cvsignore
root@eunviho:~/tmpdir/sesame#cvs commit -m"dummy write. ignore class, log, obj" .cvsignore

1.5. Renaming Files

cvs에서 파일, 디렉토리의 이름을 바꾸는 특별한 옵션은 없다.
방법은 단지 로컬 공간의 파일이름을 바꾸고 저장소내의 기존의 파일들을 삭제한뒤 로컬공간의 이름이 바뀐 파일들을 저장소에 추가하는 방법뿐이다.
~cpp 
root@eunviho:~/tmp/sesame# mv color.txt color_renamed.txt
root@eunviho:~/tmp/sesame# cvs remove color.txt
cvs remove: scheduling `color.txt' for removal
cvs remove: use `cvs commit' to remove this file permanently
root@eunviho:~/tmp/sesame# cvs add color_renamed.txt 
cvs add: scheduling file `color_renamed.txt' for addition
cvs add: use `cvs commit' to add this file permanently
root@eunviho:~/tmp/sesame# cvs commit -m "color.txt renamed"
cvs commit: Examining .
cvs commit: Examining template
cvs commit: Examining template2
/home/CVSHOME/sesame/color.txt,v  <--  color.txt
new revision: delete; previous revision: 1.2
/home/CVSHOME/sesame/color_renamed.txt,v  <--  color_renamed.txt
initial revision: 1.1
이렇게 관리를 하게되면 원래 존재했던 color.txt라는 파일에 존재하는 기존의 기록들이 삭제되어서 그 파일의 과거파일을 color_rename.txt의 로그로 이용하는 것이 불가하다. 기록이 따로 보관되기 때문이다.
~cpp 
root@eunviho:~/tmp/sesame# cvs status color.txt
===================================================================
File: no file color.txt         Status: Up-to-date

   Working revision:    No entry for color.txt
   Repository revision: 1.3     /home/CVSHOME/sesame/Attic/color.txt,v
위에서 보듯 color_renamed.txt라는 파일의 버전이 1.1인 것에 반해서 color.txt가 1.3버전임을 확인할 수 있다.

1.6. Renaming a Directory

1.7. Seeing What’s Changed

1.8. Handling Merge Conflicts

1.9. Committing Changes

1.10. Examining Change History

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:01
Processing time 0.0280 sec