BazaarNG Tutorial.docx

上传人:b****8 文档编号:9378468 上传时间:2023-02-04 格式:DOCX 页数:12 大小:20.99KB
下载 相关 举报
BazaarNG Tutorial.docx_第1页
第1页 / 共12页
BazaarNG Tutorial.docx_第2页
第2页 / 共12页
BazaarNG Tutorial.docx_第3页
第3页 / 共12页
BazaarNG Tutorial.docx_第4页
第4页 / 共12页
BazaarNG Tutorial.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

BazaarNG Tutorial.docx

《BazaarNG Tutorial.docx》由会员分享,可在线阅读,更多相关《BazaarNG Tutorial.docx(12页珍藏版)》请在冰豆网上搜索。

BazaarNG Tutorial.docx

BazaarNGTutorial

Bazaar-NGTutorial

Currentforbzr-0.8,2006-04

Introduction

Ifyouarealreadyfamiliarwithdecentralizedrevisioncontrol,thenpleasefeelfreetoskipaheadto"IntroducingYourselftoBazaar-NG".If,ontheotherhand,youarefamiliarwithrevisioncontrolbutnotdecentralizedrevisioncontrol,thenpleasestartat"HowDRCSisdifferent."Otherwise,getsomecoffeeortea,getcomfortableandgetreadytocatchup.

ThePurposesofRevisionControl

Oddsarethatyouhaveworkedonsomesortoftextualdata--thesourcestoaprogram,websitesortheconfigfilesthatUnixsystemadministratorshavetodealwithin/etc.Thechancesarealsogoodthatyouhavemadesomesortofmistakethatyoudeeplyregretted.Perhapsyoudeletedtheconfigurationfileforyourmailserverorperhapsmauledthesourcecodeforapetproject.Whateverhappened,youhavejustdeletedimportantinformationthatyouwoulddesperatelyliketogetback.Ifthishaseverhappenedtoyou,thenyouareprobablyreadyforBazaar-NG.

Revisioncontrolsystems(whichI'llhenceforthcallRCS)suchasBazaar-NGgiveyoutheabilitytotrackchangesforadirectorybyturningitintosomethingslightlymorecomplicatedthanadirectorythatwecallabranch.Thebranchnotonlystoreshowthedirectorylooksrightnow,butalsohowitlookedatvariouspointsinthepast.Then,whenyoudosomethingyouwishyouhadn't,youcanrestorethedirectorytothewayitlookedatsomepointinthepast.

Revisioncontrolsystemsgiveuserstheabilitytosavechangestoabranchby"committingarevision".Therevisioncreatedisessentiallyasummaryofthechangesthatweremadesincethelasttimethetreewassaved.

Theserevisionshaveotherusesaswell.Forexample,onecancommentrevisionstorecordwhattherecentsetofchangesmeantbyprovidinganoptionallogmessage.Reallifelogmessagesincludethingslike"Fixedthewebtemplatetoclosethetable"and"Addedsftpsuppport.Fixes#595"

Wekeeptheselogssothatiflaterthereissomesortofproblemwithsftp,wecanfigureoutwhentheproblemprobablyhappened.

HowDRCSisDifferent

ManyRevisionControlSystems(RCS)arestoredonservers.IfonewantstoworkonthecodestoredwithinanRCS,thenoneneedstoconnecttotheserverand"checkout"thecode.Doingsogivesoneadirectoryinwhichapersoncanmakechangesandthencommit.TheRCSclientthenconnectstotheRCSserverandstoresthechanges.Thismethodisknownasthecentralizedmodel.

Thecentralizedmodelcanhavesomedrawbacks.AcentralizedRCSrequiresthatoneisabletoconnecttotheserverwheneveronewantstodoversioncontrolwork.Thiscanbeabitofaproblemifyourserveronsomeothermachineontheinternetandyouarenot.Or,worseyet,you''are''ontheinternetbuttheserverismissing!

DecentralizedRevisionControlSystems(whichI'llcallDRCSafterthispoint)dealwiththisproblembykeepingbranchesonthesamemachineastheclient.InBazaar-NG'scase,thebranchiskeptinthesameplaceasthecodethatisbeingversioncontrolled.Thisallowstheusertosavehischanges(commit)wheneverhewants--evenifheisoffline.Theuseronlyneedsinternetaccesswhenhewantstoaccessthechangesinsomeoneelse'sbranchthataresomewhereelse.

Acommonrequirementthatmanypeoplehaveistheneedtokeeptrackofthechangesforadirectorysuchasfileandsubdirectorychanges.Performingthistrackingbyhandisaawkwardprocessthatovertimebecomesunwieldy.Thatis,untiloneconsidersversioncontroltoolssuchasBazaar-NG.Thesetoolsautomatetheprocessofstoringdatabycreatingarevisionofthedirectorytreewhenevertheuserasks.

RevisioncontrolsoftwaresuchasBazaar-NGcandomuchmorethanjuststorageandperformingundo.Forexample,withBazaar-NGdevelopercantakethemodificationsinonebranchofsoftwareandapplythemtoanother,related,branch--evenifthosechangesexistinabranchownedbysomebodyelse.Thisallowsdeveloperstocooperatewithoutgivingwriteaccesstorepository.

Bazaar-NGremembersthe''ancestry''ofarevision:

thepreviousrevisionsthatitisbasedupon.Asinglerevisionmayhavemorethanonedirectdescendant,eachwithdifferentchanges,representingadivergenceintheevolutionofthetree.Bybranching,Bazaar-NGallowsmultiplepeopletocooperateontheevolutionofaproject,withoutallneedingtoworkinstrictlock-step.Branchingcanbeusefulevenforasingledeveloper.

IntroducingyourselftoBazaar-NG

Bazaar-NGinstallsasinglenewcommand,bzr.Everythingelseisasubcommandofthis.Youcangetsomehelpwithbzrhelp.Therewillbemoreinthefuture.

Onefunctionofaversioncontrolsystemistokeeptrackofwhochangedwhat.Inadecentralizedsystem,thatrequiresanidentifierforeachauthorthatisgloballyunique.Mostpeoplealreadyhaveoneofthese:

anemailaddress.Bzrissmartenoughtoautomaticallygenerateanemailaddressbylookingupyourusernameandhostname.Ifyoudon'tliketheguessthatBazaar-NGmakes,thenthreeoptionsexist:

1.Setanemailaddressviabzrwhoami.Thisisthesimplestway.Tosetaglobalidentity,use:

%bzrwhoami'YourName'

Ifyou'dliketouseadifferentaddressforaspecificbranch,enterthebranchfolderanduse:

%bzrwhoami--branch'YourName'

1.Settingtheemailaddressinthe~/.bazaar/bazaar.conf[1]byaddingthefollowinglines.Pleasenotethat[DEFAULT]iscasesensitive:

[DEFAULT]

email=YourName

Asabove,youcanoverridethissettingsonabranchbybranchbasisbycreatingabranchsectionin~/.bazaar/locations.confandaddingthefollowinglines:

[/the/directory/to/the/branch]

email=YourName

1.Overridingthetwopreviousoptionsbysettingtheglobalenvironmentvariable$BZREMAILor$EMAIL($BZREMAILwilltakeprecedence)toyourfullemailaddress.

[1]

(1,2)OnWindows,theusersconfigurationfilescanbefoundintheapplicationdatadirectory.Soinsteadof~/.bazaar/branch.conftheconfigurationfilecanbefoundas:

C:

\DocumentsandSettings\\ApplicationData\Bazaar\2.0\branch.conf.Thesameistrueforlocations.conf,ignore,andthepluginsdirectory.

Creatingabranch

Historyisbydefaultstoredinthe.bzrdirectoryofthebranch.Therewillbeafacilitytostoreitinaseparaterepository,whichmayberemote.Wecreateanewbranchbyrunningbzrinitinanexistingdirectory:

%mkdirtutorial

%cdtutorial

%ls-a

./../

%pwd

/home/mbp/work/bzr.test/tutorial

%

%bzrinit

%ls-aF

./../.bzr/

%

AsforCVS,therearethreeclassesoffile:

unknown,ignored,andversioned.Theaddcommandmakesafileversioned:

thatis,changestoitwillberecordedbythesystem:

%echo'helloworld'>hello.txt

%bzrstatus

unknown:

hello.txt

%bzrunknowns

hello.txt

%bzraddhello.txt

addedhello.txt

%bzrunknowns

Ifyouaddthewrongfile,simplyusebzrremovetomakeitunversionedagain.Thisdoesnotdeletetheworkingcopy.

Branchlocations

Allhistoryisstoredinabranch,whichisjustanon-diskdirectorycontainingcontrolfiles.Bydefaultthereisnoseparaterepositoryordatabaseasusedinsvnorsvk.Youcanchoosetocreatearepositoryifyouwantto(seethebzrinit-repocommand).Youmaywishtodothisifyouhaveverylargebranches,ormanybranchesofamoderatesizedproject.

You'llusuallyrefertobranchesonyourcomputer'sfilesystemjustbygivingthenameofthedirectorycontainingthebranch.bzralsosupportsaccessingbranchesoverhttp,forexample:

%bzrloghttp:

//bazaar-ng.org/bzr/bzr.dev/

Byinstallingbzrpluginsyoucanalsoaccessbranchesoverthesftporrsyncprotocols.

Reviewingchanges

Onceyouhavecompletedsomework,youwillwanttocommitittotheversionhistory.Itisgoodtocommitfairlyoften:

wheneveryougetanewfeatureworking,fixabug,orimprovesomecodeordocumentation.It'salsoagoodpracticetomakesurethatthecodecompilesandpassesitstestsuitebeforecommitting,tomakesurethateveryrevisionisaknown-goodstate.Youcanalsoreviewyourchanges,tomakesureyou'recommittingwhatyouintendto,andasachancetorethinkyourworkbeforeyoupermanentlyrecordit.

Twobzrcommandsareparticularlyusefulhere:

statusanddiff.

bzrstatus

Thestatuscommandtellsyouwhatchangeshavebeenmadetotheworkingdirectorysincethelastrevision:

%bzrstatus

modified:

foo

Bydefaultbzrstatushides"boring"filesthatareeitherunchangedorignored.Toseethemtoo,usethe--alloption.Thestatuscommandcanoptionallybegiventhenameofsomefilesordirectoriestocheck.

bzrdiff

Thediffcommandshowsthefulltextofchangestoallfilesasastandardunifieddiff.Thiscanbepipedthroughmanyprogramssuchas''patch'',''diffstat'',''filterdiff''and''colordiff'':

%bzrdiff

***addedfile'hello.txt'

---/dev/null

+++hello.txt

@@-1,0+1,1@@

+helloworld

Withthe''-r''option,thetreeiscomparedtoanearlierrevision,orthedifferencesbetweentwoversionsareshown:

%bzrdiff-r1000..#everythingsincer1000

%bzrdiff-r1000..1100#changesfrom1000to1100

The--diff-optionsoptioncausesbzrtoruntheexternaldiffprogram,passingoptions.Forexample:

%bzrdiff--diff-options--side-by-sidefoo

Someprojectspreferpatchestoshowaprefixatthestartofthepathforoldandnewfiles.The--prefixoptioncanbeusedtoprovidesuchaprefix.Asashortcut,bzrdiff-p1producesaformthatworkswiththecommandpatch-p1.

Committingchanges

Whentheworkingtreestateissatisfactory,itcanbecommittedtothebranch,creatinganewrevisionholdingasnapshotofthatstat

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1