17 Managing Source Files CVS Concurrent Versions System

  • Slides: 43
Download presentation
제 17강 : Managing Source Files CVS (Concurrent Versions System) 1

제 17강 : Managing Source Files CVS (Concurrent Versions System) 1

Typical Source Codes src dir 1 sys. h inode. h vm. h file. h

Typical Source Codes src dir 1 sys. h inode. h vm. h file. h cdev. h bdev. h init. h flt. h obj. h text. h. . dir 2 user. h read. h type. h mount. h abs. h dir 3 dir 4 . . . driver. c stream. c intrp. c signal. c file. c write. c nfs. c super. c ftp. c telet. c. . hd. c strategy. c sleep. c win. c fill. c 2

Typical Source Codes src dir 1 dir 2 dir 3 dir 4 . .

Typical Source Codes src dir 1 dir 2 dir 3 dir 4 . . . file. c sys. h inode. h vm. h file. h cdev. h bdev. h init. h flt. h obj. h text. h. . user. h read. h type. h mount. h abs. h Bob flash memory John driver. c stream. c hd. c file, c Testing file. c intrp. c signal. cfile, c strategy. c file. c write. c sleep. c. Tom file. c nfs. c super. cfile. c win. c mpeg 3 file. c ftp. c telnet. c fill. c Peter. . file. c booting 3

Typical Source Codes src dir 1 dir 2 dir 3 dir 4 . .

Typical Source Codes src dir 1 dir 2 dir 3 dir 4 . . . Bob flash memory sys. h inode. h vm. h file. h cdev. h bdev. h init. h flt. h obj. h text. h. . user. h read. h type. h mount. h abs. h driver. c stream. c intrp. c signal. c file. c write. c nfs. c super. c ftp. c telnet. c. . hd. c John Testing strategy. c sleep. c Tom win. cmpeg 3 fill. c Peter booting 4

Everybody makes copy of files # of people 8000 files P men P*8000 files

Everybody makes copy of files # of people 8000 files P men P*8000 files 5

Many Releases 95 8000 files P*8000 P men 98 8000 files P men P*8000

Many Releases 95 8000 files P*8000 P men 98 8000 files P men P*8000 6

Many people, Many Releases # of revisions 95 8000 files P*8000 P men 98

Many people, Many Releases # of revisions 95 8000 files P*8000 P men 98 8000 files P men P*8000 00 8000 files P men P*8000 P*R*8000 7

Number of Files to Manage Revision (Replacement) word 1. 1 word 1. 2 (**

Number of Files to Manage Revision (Replacement) word 1. 1 word 1. 2 (** 1 st version is called “Baseline”) word French word Russian word 1. 3 Branch or Variation (Alternative – eg: for different Hardware’s, uses) 8

Many people, releases, branches 95 8000 files P men P*8000 98 8000 files P

Many people, releases, branches 95 8000 files P men P*8000 98 8000 files P men P*8000 00 8000 files P men P*8000 P*R*B*8000 100*10*10*8000 80, 000 files! # of branches 9

Typical System • Situation: – m persons, p files – concurrent/independent work • Access

Typical System • Situation: – m persons, p files – concurrent/independent work • Access Control: any file? • Concurrent Update: file? • History/undo: anyone update two work on same 10 who/file/action/date/

Terminology • Repository Directory Original Files Access Control History – Place where master source

Terminology • Repository Directory Original Files Access Control History – Place where master source is stored • Check-out CVS System Repository Directory Master Source – Take a copy of file(s) from master source • Commit (Check-in) Check out Check in – local change master source Private Directory • Revision – Each change to a file • Project Check in Private Directory A’s Working Copy B’s Working Copy Edit File(s) – Collection of files (tree name) 11

Original Files 12

Original Files 12

Original Files Repository A. c CVS Files stored in repository become “master source” CVS

Original Files Repository A. c CVS Files stored in repository become “master source” CVS attaches extra info such as : access control info history version info …. 13

Original Files Remove original files now. Afterwards, you can not simply “vi”. Always check

Original Files Remove original files now. Afterwards, you can not simply “vi”. Always check out first, Then you can do vi Repository A. c Check-out A. c Bob Access Control modify v i CVS 14

Repository Bob A. c vi < old > modify A. c CVS Commit(Check-in) A.

Repository Bob A. c vi < old > modify A. c CVS Commit(Check-in) A. c < new > System updates master copy records history version # 15

Repository modify A. c CVS Commit (Check-in) A. c Later Print history undo …

Repository modify A. c CVS Commit (Check-in) A. c Later Print history undo … 16

CVS Command Original Files Repository (1) Import (Make master copy in repository) (2) Checkout

CVS Command Original Files Repository (1) Import (Make master copy in repository) (2) Checkout Bob A. c vi A. c modify CVS (3) Commit (Checkin) (4) History. . . Bob A. c vi 17

CVS Lab Exercise man cvs Make repository directory Create master source (import) Checkout Modify

CVS Lab Exercise man cvs Make repository directory Create master source (import) Checkout Modify Commit (checkin) 18

$HOME Original source files are under …. /src cvs_ex src Source Original Example cd

$HOME Original source files are under …. /src cvs_ex src Source Original Example cd $HOME/cvs_ex ls src/ /*all source files are under src*/ 19

original source files home cvs_ex src my_dir 1 my_dir 2 Original Source 20

original source files home cvs_ex src my_dir 1 my_dir 2 Original Source 20

$HOME Create repository directory for future master source ** Make repository directory Make master

$HOME Create repository directory for future master source ** Make repository directory Make master source (import) Checkout Modify Commit (checkin ) cvs_ex src master Original Source Example cd $HOME/cvs_ex ls src /*all source files are under src*/ cvs -d `pwd`/master init /* make repository dir */ export CVSROOT=`pwd`/master /* register CVS repository in env. variable*/ ls $HOME/cvs_ex /*now you see the new directory master*/ 21

creating repository directory home cvs_ex src my_dir 1 my_dir 2 master Original Source 22

creating repository directory home cvs_ex src my_dir 1 my_dir 2 master Original Source 22

$HOME Create master source under repository directory Make repository directory ** Make master source

$HOME Create master source under repository directory Make repository directory ** Make master source (import) Checkout Modify Commit (checkin ) cvs_ex src Original Source master s 2 Master Source System knows where the master file directory is. cd to src. Example cd $HOME/cvs_ex/src cvs import –m “s 1” /* cd to original source file directory */ /* copy original src master */ s 2 s 3 v 1_1 message project vendor (sub-tree) version cd to master directory – new directory s 2 created here ls -l s 2/ see files with comma …? no write permission 23

creating master source files home cvs_ex src Original Source my_dir 1 my_dir 2 master

creating master source files home cvs_ex src Original Source my_dir 1 my_dir 2 master s 2 CVSROOT Master Source 24

after creating master source home cvs_ex src Original Source my_dir 1 my_dir 2 master

after creating master source home cvs_ex src Original Source my_dir 1 my_dir 2 master s 2 Master Source CVSROOT 25

files created for bookkeeping 26

files created for bookkeeping 26

home Check-out from master source to working directory cvs_ex src Make repository directory Make

home Check-out from master source to working directory cvs_ex src Make repository directory Make master source (import) ** Checkout (copy all files) Modify Commit (checkin ) my_dir 1 my_dir 2 s 2 My Source master s 2 Master Source Example cd $HOME/cvs_ex/my_dir 1 /* time to do coding here */ cvs checkout s 2 ls cd s 2 ls -l /* copy files: give project name=s 2*/ System knows where the master file directory is. cd to my dir. Checkout. Run vi in my dir. 27

checkout home cvs_ex src my_dir 1 my_dir 2 s 2 My source master s

checkout home cvs_ex src my_dir 1 my_dir 2 s 2 My source master s 2 CVSROOT Master Source 28

home Modify file Commit cvs_ex src Make repository directory Make master source (import) **

home Modify file Commit cvs_ex src Make repository directory Make master source (import) ** Checkout (copy all files) Modify Commit (checkin ) my_dir 1 my_dir 2 s 2 My Source master s 2 Master Source Example cd $HOME/cvs_ex/my_dir 1 /* time to do coding here */ cd s 2 vi test 1. c cvs commit test 1. c /* modify file*/ /* Commit. Give any message-to log*/ cvs log test 1. c /*see history*/ 29

Multiple Developers -- Status -- • Up to date me = master – My

Multiple Developers -- Status -- • Up to date me = master – My file = master copy in the repository (latest version) me master • Locally Modified – I edited, not committed my changes to master copy yet • Needs Patch me – he committed newer version to master copy – (my copy is not modified yet) – What is his modification? me • Needs Merge he master – I made modification, – he also committed newer version to master copy 30

Multiple Developers src scenario: need patch • developer “me” master – cvs checkout s

Multiple Developers src scenario: need patch • developer “me” master – cvs checkout s 2 at dir 1 • developer “he” dir 2 me he – cvs checkout s 2 at dir 2 – vi this. c; – cvs commit –m “add two” this. c • “his” change is not reflected in dir 1 yet • developer “me” cvs update this. c (2) me (1) master he 31

Multiple Developers scenario: need merge • developer “he” – vi this. c; /* add

Multiple Developers scenario: need merge • developer “he” – vi this. c; /* add printf(“two”); */ – cvs commit –m “add two” this. c • developer “me” – vi this. c; /* add printf(“one”); */ – cvs commit –m “add one” this. c – cvs status this. c “status: Needs Merge …” – cvs update this. c “Merging differences …” (2) me (1) master he 32

manual merge • cvs update this. c me Merging differences … warning: conflicts during

manual merge • cvs update this. c me Merging differences … warning: conflicts during merge in this. c: void test() { <<<< this. c printf(“one”); developer-1’s code ======= printf(“two”); developer-2’s code >>>> } master • Fix them manually. Delete {>>>, <<<, = = =} • cvs commit this. c 33

add/remove files • to add files – create new files in working directory –

add/remove files • to add files – create new files in working directory – cvs add filename cvs commit filename • to remove files – remove files from working directory (rm …) – cvs remove filename cvs commit filename 34

Managing Branches (** 1 st version is called “Baseline”) Revision (Replacement) word 1. 1

Managing Branches (** 1 st version is called “Baseline”) Revision (Replacement) word 1. 1 word 1. 2 D 1 D 2 English French D 3 Russian word 1. 3 Branch or Variation (Alternative – eg: for different Hardware’s, uses) 35

 • • Branches cd dir 1 cvs tag release-1 tag all files gives

• • Branches cd dir 1 cvs tag release-1 tag all files gives symbolic name to files cvs checkout -r release-1 s 2 now this release-1 is our new base. copy from this release. NOT from newest version all subsequent commits go to release-1 master release-1 36

Branches • To create new branch from this version cvs rtag -b -r release-1

Branches • To create new branch from this version cvs rtag -b -r release-1 -patches project_name another new branch • To get a working copy cvs checkout -r release-1 -patches project_name master release-1 new branch create new branch from this version 37

merge (branch & main tree) • First release the patched version – cd –

merge (branch & main tree) • First release the patched version – cd – cvs release -d project_name • To merge release-1 & release-1 -patches – cvs checkout -j release-1 -patches project_name • To commit all files changed by merge of release-1 patch into source tree – cvs commit -m “merged” 38

Versions • MRF (Modification Request Form) • Change control authority–approves DB • Change tracking

Versions • MRF (Modification Request Form) • Change control authority–approves DB • Change tracking authority CASE – CVS administrator IDE – Check out, modify, Unit test, other tests – lint, coverage, review … DB 39

CVS command arguments • init • import files • checkout directory • commit •

CVS command arguments • init • import files • checkout directory • commit • update create repository directory plain source --> repository cvs repository --> my working dir --> repository memorize modification, versioning repository --> my working dir modified files only or specified version only 40

misc • SCCS • RCS • CVS AT&T, Bell Lab (Source Code Control System)

misc • SCCS • RCS • CVS AT&T, Bell Lab (Source Code Control System) lock/unlock open source code single host client/server environment network, multi-user (do CVS after telnet) copy/merge If conflict: CVS requests hand-editing to resolve conflict Notify service : via email if file(s) are modified by others. 41

Bonsai (ctags continued) • Basically, a tree control • Web-based tool for watching the

Bonsai (ctags continued) • Basically, a tree control • Web-based tool for watching the up-to-the-minute goings-on in CVS (Concurrent Versions System) repository • Allows queries on the contents of a CVS archive – get a list of checkins – see what checkins have been made • by a given person, • given CVS branch, • in a particular time period 42

(Cont’d) • Also includes tools for : – looking at checkin logs (and comments)

(Cont’d) • Also includes tools for : – looking at checkin logs (and comments) – doing diffs between various versions of a file – finding out what person is responsible for changing a particular line of code(“cvsblame”) 43