220 likes | 396 Views
ARAra Seminar [ARA101] - Introduction to Subversion 2 -. 변규홍 combacsa@sparcs.kaist.ac.kr. Objective & Preliminary. Objective Subversion (SVN) 의 좀 더 많은 사용법 Seminar HW #2 Preliminary Introduction to Subversion 1. SVN Command : checkout (detail). 부분 checkout
E N D
ARAra Seminar [ARA101]- Introduction to Subversion 2 - 변규홍 combacsa@sparcs.kaist.ac.kr
Objective & Preliminary • Objective • Subversion (SVN) 의 좀 더 많은 사용법 • Seminar HW #2 • Preliminary • Introduction to Subversion 1
SVN Command : checkout (detail) • 부분 checkout • Subversion 저장소의 하위 디렉토리 하나만 받아올 수 있다 • 익명 checkout • 로그인하지 않고 받아올 수 있다 • 사용자들의 commit 은 막되 update 는 할 수 있도록 하는 형태 combacsa@swingfixer:~/checkout$ svn co svn://project.sparcs.org/PROJECT/svn/sandbox/SEMINAR seminar A seminar/arara101-02-subversion_2.pptx A seminar/arara101-04-python.pptx A seminar/arara101-03-trac.pptx A seminar/arara101-01-subversion_1.pptx Checked out revision 25. combacsa@swingfixer:~/checkout$ cd seminar combacsa@swingfixer:~/checkout/seminar$ ls -alh total 408K drwxr-xr-x 3 combacsacombacsa 248 2010-01-14 14:57 . drwxr-xr-x 6 combacsacombacsa 152 2010-01-14 14:57 .. -rwxr-xr-x 1 combacsacombacsa 149K 2010-01-14 14:57 arara101-01-subversion_1.pptx -rwxr-xr-x 1 combacsacombacsa 108K 2010-01-14 14:57 arara101-02-subversion_2.pptx -rwxr-xr-x 1 combacsacombacsa 72K 2010-01-14 14:57 arara101-03-trac.pptx -rwxr-xr-x 1 combacsacombacsa 73K 2010-01-14 14:57 arara101-04-python.pptx drwxr-xr-x 6 combacsacombacsa 208 2010-01-14 14:57 .svn
SVN Command : checkout (detail) • 익명 체크아웃 받은 뒤 commit을 시도하면? • 가정 : sandbox 리포지토리를 익명으로 받아온 뒤 sample.txt 를 수정했다고 치자. • 저장소 설정따라 차이가 있음 (project.SPARCS에서는 저러함) combacsa@swingfixer:~/checkout/sandbox$ svn diff Index: sample.txt =================================================================== --- sample.txt (revision 25) +++ sample.txt (working copy) @@ -1,2 +1,3 @@ hello world! +hahahahahaha Hello world! combacsa@swingfixer:~/checkout/sandbox$ svnci -m "modified sample.txt" svn: Commit failed (details follow): svn: Authorization failed combacsa@swingfixer:~/checkout/sandbox$
SVN Command : copy • 버전 관리 대상인 파일을 복사해서역시 버전 관리 대상인 새로운 파일을 만들기 • 예제 combacsa@swingfixer:~/checkout/sandbox$ cp sample.txt sample_cp.txt combacsa@swingfixer:~/checkout/sandbox$svnst ? sample_cp.txt combacsa@swingfixer:~/checkout/sandbox$svn cp sample.txt sample_go.txt A sample_go.txt combacsa@swingfixer:~/checkout/sandbox$svnst ? sample_cp.txt A + sample_go.txt combacsa@swingfixer:~/checkout/sandbox$
SVN Command : revert (after copy) • 백문이 불여일견! • Revert 를 해도 일단 copy 된 파일은 지워지지 않는다 combacsa@swingfixer:~/checkout/sandbox$svn cp sample.txt sample_go.txt A sample_go.txt combacsa@swingfixer:~/checkout/sandbox$svnst A + sample_go.txt combacsa@swingfixer:~/checkout/sandbox$ svn revert sample_go.txt Reverted 'sample_go.txt' combacsa@swingfixer:~/checkout/sandbox$ svnst ? sample_go.txt combacsa@swingfixer:~/checkout/sandbox$
SVN Command : move • 버전 관리 대상인 파일의 이름을 바꾸꺼나파일의 위치 (경로) 를 옮기고 싶을 때 • 그냥mv써서 옮기면? • 멀쩡한 파일이 사라지고모르는 파일이 생긴 꼴이 됨 • 버전 관리 역사가 사라짐 (다음 슬라이드!) combacsa@swingfixer:~/checkout/sandbox$ svnmv sample.txt sample_go.txt A sample_go.txt D sample.txt combacsa@swingfixer:~/checkout/sandbox$ svnst D sample.txt A + sample_go.txt combacsa@swingfixer:~/checkout/sandbox$ svn diff Index: sample.txt =================================================================== --- sample.txt (revision 25) +++ sample.txt (working copy) @@ -1,2 +0,0 @@ -hello world! -Hello world! Property changes on: sample_go.txt ___________________________________________________________________ Added: svn:mergeinfo
SVN Command : annotate (after move) • 앞 슬라이드의 연습을 commit 한 뒤 annotate 보자. • 버전 관리 이력이 따라온다. • 그냥 수동으로 mv하고 svn remove 하고 svn add 했으면 따라오지 않을 텐데, 따라왔다는 것을 주목! combacsa@swingfixer:~/checkout/sandbox$ svnci -m "moved sample_go.txt" combacsa@project.sparcs.org's password: Deleting sample.txt Adding sample_go.txt Committed revision 26. combacsa@swingfixer:~/checkout/sandbox$ svn annotate sample_go.txt combacsa@project.sparcs.org's password: 1 combacsa hello world! 2 combacsa Hello world! combacsa@swingfixer:~/checkout/sandbox$
SVN Command : revert (detail) • 파일을 삭제해버린 경우 revert 로 복구할 수 있다 • Recursive 옵션을 걸어보자. combacsa@swingfixer:~/checkout/sandbox$ rm sample.txt combacsa@swingfixer:~/checkout/sandbox$ rm SEMINAR/* combacsa@swingfixer:~/checkout/sandbox$ svnst ! sample.txt ! SEMINAR/arara101-02-subversion_2.pptx ! SEMINAR/arara101-04-python.pptx ! SEMINAR/arara101-03-trac.pptx ! SEMINAR/arara101-01-subversion_1.pptx combacsa@swingfixer:~/checkout/sandbox$ svn revert -R . Reverted 'sample.txt' Reverted 'SEMINAR/arara101-02-subversion_2.pptx' Reverted 'SEMINAR/arara101-04-python.pptx' Reverted 'SEMINAR/arara101-03-trac.pptx' Reverted 'SEMINAR/arara101-01-subversion_1.pptx' combacsa@swingfixer:~/checkout/sandbox$
SVN Command : revert 가 안 되는 경우 • 디렉토리를 통째로 날려버렸을 때 (.svn폴더가 없어!) • Revert 를 위해 필요한 정보는 .svn폴더 속에 들어있다 • 따라서 이런 경우에는 해당 디레토리만update 받아야 한다 combacsa@swingfixer:~/checkout/sandbox$ rm -rf SEMINAR combacsa@swingfixer:~/checkout/sandbox$ svnst ! SEMINAR combacsa@swingfixer:~/checkout/sandbox$ svn revert SEMINAR Failed to revert 'SEMINAR' -- try updating instead. combacsa@swingfixer:~/checkout/sandbox$ svn up combacsa@project.sparcs.org's password: A SEMINAR combacsa@project.sparcs.org's password: A SEMINAR/arara101-02-subversion_2.pptx A SEMINAR/arara101-04-python.pptx A SEMINAR/arara101-03-trac.pptx A SEMINAR/arara101-01-subversion_1.pptx Updated to revision 30. combacsa@swingfixer:~/checkout/sandbox$
SVN Command : delete • 버전 관리되고 있던 파일을 삭제해버리기 • 단순히 rm으로 지우면 st에 ! 라고 뜰 뿐이니까아예 subversion 에게 “얜 없애버려” 라고 말하는 것. • --keep-local 옵션이 있음 • Repository 에서는 파일을 지워버리되,working copy 에 그 파일을 남겨두는 것. • Keep-local 옵션을 안 주면 working copy 에서도 바로 지워버림. combacsa@swingfixer:~/checkout/sandbox$ svn delete sample.txt D sample.txt combacsa@swingfixer:~/checkout/sandbox$ svnst D sample.txt combacsa@swingfixer:~/checkout/sandbox$ svnci -m "sample.txt is now removed." combacsa@project.sparcs.org's password: Deleting sample.txt Committed revision 32. combacsa@swingfixer:~/checkout/sandbox$
SVN Command : log (detail) • 최근에 일어난 3개의 변화만 보고 싶을 때 • -l 옵션으로, 표시되는 entry 의 개수를 3개로 맞춘 것! combacsa@swingfixer:~/checkout/sandbox$ svn log -l 3 combacsa@project.sparcs.org's password: ------------------------------------------------------------------------ r27 | combacsa | 2010-01-14 15:18:12 +0900 (Thu, 14 Jan 2010) | 1 line sample.txt is back. sample_go.txt is away. ------------------------------------------------------------------------ r26 | combacsa | 2010-01-14 15:15:13 +0900 (Thu, 14 Jan 2010) | 1 line moved sample_go.txt ------------------------------------------------------------------------ r25 | combacsa | 2010-01-12 22:35:17 +0900 (Tue, 12 Jan 2010) | 1 line seminar file names are changed... ------------------------------------------------------------------------ combacsa@swingfixer:~/checkout/sandbox$
SVN Command : diff (detail) • sample.txt 원래 내용 • sample.txt 고친 내용 To explain how svn diff work, I will modified sample.txt a lot. Well, it takes time ... gee. These days my English brain circuit is damaged, so I don't speak English fluently. Damn it. Whatever ... phew! I want money. To explain how svn diff work, I will modified sample.txt a lot. Becasue my English is not so fluent, it takes time ... gee. These days my English brain circuit is damaged, Damn it. But still I am writing something in English! Whatever ... phew! I want money. • 이렇게 고친 뒤에, svn diff 명령어를 사용해 보자.combacsa@swingfixer:~/checkout/sandbox$ svndiff
SVN Command : diff (detail) Index: sample.txt ======================= --- sample.txt (revision 28) +++ sample.txt (working copy) @@ -1,8 +1,9 @@ To explain how svn diff work, I will modified sample.txt a lot. -Well, it takes time ... gee. +Becasue my English is not +it takes time ... gee. These days my English brain -so I don't speak English Damn it. +But still I am writing Whatever ... phew! I want money. --- sample.txt (revision 28) To explain how svn diff work, I will modified sample.txt a lot. Well, it takes time ... gee. These days my English brain so I don't speak English Damn it. Whatever ... phew! I want money. +++ sample.txt (working copy) To explain how svn diff work, I will modified sample.txt a lot. Becasuemy English is not it takes time ... gee. These days my English brain Damn it. But still I am writing Whatever ... phew! I want money. • @@-1, 8 +1, 9 @@ 의 의미 • Revision 28 에서는 1번째 줄 – 8번째 줄 • Working copy 에서는 1번째 줄 – 9번째 줄!
SVN Command : diff (detail) • 특정 revision 과 현재의 차이를 알고 싶을 때 combacsa@swingfixer:~/checkout/sandbox$ svn diff -r 1 sample.txt combacsa@project.sparcs.org's password: combacsa@project.sparcs.org's password: Index: sample.txt =================================================================== --- sample.txt (revision 1) +++ sample.txt (working copy) @@ -1 +1,9 @@ -hello world! +To explain how svn diff work, +I will modified sample.txt a lot. +Becasue my English is not so fluent, +it takes time ... gee. +These days my English brain circuit is damaged, +Damn it. +But still I am writing something in English! +Whatever ... phew! +I want money. Property changes on: sample.txt ___________________________________________________________________ Added: svn:mergeinfo
Concept : Conflict • 발생 조건 (svn식) • 같은 파일을 서로 다른 두 사람이 편집하였을 때 • 한 사람이 commit 하고 • 다른 한 사람이 commit 을 하려 하고 실패한 뒤 • 그 실패한 사람이 update 를 하려고 할 때 발생 • 해결 방법 • svn resolve 를 이용하기 • 닥치고 내가 작업하던 것을 고수한다 • 닥치고 니가 작업하던 것을 받아들인다 • svn resolved 를 이용하기 • 다음 슬라이드
Concept : Conflict (쉬운거) • 상황 예제 combacsa@swingfixer:~/checkout/sandbox_2$ svn diff Index: sample.txt ==================================== --- sample.txt (revision 29) +++ sample.txt (working copy) @@ -1,8 +1,5 @@ To explain how svn diff work, I will modified sample.txt a lot. -Becasue my English is not so fluent, -it takes time ... gee. -These days my English brain circuit is damaged, Damn it. But still I am writing something in English! Whatever ... phew! combacsa@swingfixer:~/checkout/sandbox_2$ svnci -m "sample.txt updated." combacsa@project.sparcs.org's password: Sending sample.txt Transmitting file data .svn: Commit failed (details follow): svn: File '/sample.txt' is out of date combacsa@swingfixer:~/checkout/sandbox_2$ combacsa@swingfixer:~/checkout/sandbox$ svn diff Index: sample.txt ================================== --- sample.txt (revision 29) +++ sample.txt (working copy) @@ -2,8 +2,5 @@ I will modified sample.txt a lot. Becasue my English is not so fluent, it takes time ... gee. -These days my English brain circuit is damaged, -Damn it. -But still I am writing something in English! Whatever ... phew! I want money. combacsa@swingfixer:~/checkout/sandbox$ svnci -m "sample.txt updated." combacsa@project.sparcs.org's password: Sending sample.txt Transmitting file data .w Committed revision 30. combacsa@swingfixer:~/checkout/sandbox$
SVN Command : resolved • 상황 예제 combacsa@swingfixer:~/checkout/sandbox_2$ svn up combacsa@project.sparcs.org's password: Conflict discovered in 'sample.txt'. Select: (p) postpone, (df) diff-full, (e) edit, (h) help for more options: p C sample.txt Updated to revision 33. combacsa@swingfixer:~/checkout/sandbox_2$ svn diff Index: sample.txt =================================================================== --- sample.txt (revision 33) +++ sample.txt (working copy) @@ -1,6 +1,12 @@ To explain how svn diff work, I will modified sample.txt a lot. +<<<<<<< .mine +These days, my English brain circuit is damaged, +Damn it. +But still I am writing something in English! +======= Becasue my English is not so fluent, it takes time ... gee. +>>>>>>> .r33 Whatever ... phew! I want money.
SVN Command : resolved (2) • 문제를 해결하기 위해 적당히 고친 뒤. combacsa@swingfixer:~/checkout/sandbox_2$ svnci -m "merged." svn: Commit failed (details follow): svn: Aborting commit: '/ReiserFS/checkout/sandbox_2/sample.txt' remains in conflict combacsa@swingfixer:~/checkout/sandbox_2$ svn resolved sample.txt Resolved conflicted state of 'sample.txt' combacsa@swingfixer:~/checkout/sandbox_2$ svnci -m "merged." combacsa@project.sparcs.org's password: Sending sample.txt Transmitting file data . Committed revision 34. combacsa@swingfixer:~/checkout/sandbox_2$
SVN Command : update (detail) • 특정 리비전으로 돌아가기 combacsa@swingfixer:~/checkout/sandbox_2$ ls anna418 bigeye elaborate mikkangnevergiveup nonsense58 sample.txt SEMINAR sodasai combacsa@swingfixer:~/checkout/sandbox_2$ svn up -r 3 combacsa@project.sparcs.org's password: UU sample.txt D nevergiveup D sodasai D bigeye D nonsense58 D anna418 D SEMINAR D elaborate D mikkang/hello D mikkang/nonsense58.txt D mikkang/bigeye D mikkang/anna418 D mikkang/nevergiveup.txt D mikkang/elaborate U mikkang/mikkang.txt Updated to revision 3. combacsa@swingfixer:~/checkout/sandbox_2$ ls mikkang sample.txt combacsa@swingfixer:~/checkout/sandbox_2$
Concept : Trunk, Branch, Tag • 필요성 • 모두 다 같이 실시간으로 자신의 변경 사항을 저장소에 올림 • 그러다보니 새로운 Revision 에서 갑자기 버그가 생길지도모름 • 예 : 새로운 기능을 추가하기 위해 두 사람이 동시에 작업하느라충분한 검사 없이 기능 추가를 단행했는데, 현재 가동되고 있는 아라에 실수로 반영해버리면 …? • 따라서, 서비스에 사용되는 소스 코드와 개발에 사용되는 소스 코드를 분리하는 것이 좋음 • 또다른 필요성 • Release 를 할 때마다 그 상황을 분리해두기 • Revision 만으로 하는 것도 좋지만,이렇게 분리해서 따로 따로 버그 해결을 하는 것도 좋음. • 세미나 3에서 제대로 다뤄보자.
Summary • Concepts • 부분 checkout • 익명checkout • Conflict • 다음 시간에 • Branch, Trunk, Tags • Merge • SVN Ignore • Diff & Patch • SVN Commands • checkout (detail) • copy • move • annotate (detail) • revert (detail) • delete (detail) • log (detail) • diff (detail) • resolved