linux svn
refrencefrom:http://www.yolinux.com/TUTORIALS/Subversion.html#COMMAND
SubversionIntroduction:
Subversionisasoftwaresourcecode"ChangeManagement"(CM)systemforcollaborativedevelopment.Itmaintainsahistoryoffileanddirectoryversions.Thefilesanddirectoriesarecheckedoutoftherepositoryandintoyourlocalprojectworkarea.Thiscalledyour"workingdirectory".Changesaremadetofilesinyour"workingdirectory".Afterchangesaremadetothecreatethenextworkingversion,thefilesarecheckedintotheSubversionCMrepository.
SubversionCommands:
Subversioncommandsummarycheatsheet:
CommandDescription
--------------------------------------------------------------
svn--helpListSubversioncommands
svnhelpcommand
Also:?orhHelpongiven"command"
svnaddfilename
svnadddirectory
AddafileordirectorytoSubversionCMcontrol.
Mustalsoperform:svncifilename(orsvncommit)touploadthefileordirectory.Filewillnotbeavailableintherepositoryuntila"commit"isperformed.Ifaddingadirectory,thedirectoryandallofitscontentsrecursivelyareadded.i.e.:
svncidirectory
svncommitdirectory
svncommit.
svnblamefilename
svnblame-rRevisionNumberfilename
Also:praise,annotate,annShowfilecontentswithrevisionsannotatedwithauthorinformation.
svncatfilenameListcontentsoffileunderSubversioncontrol.
svncheckouthttp://node-name/repos/svn/trunk/parentPath/path
Thiscreates:
path/file1
path/file2
...
svncheckouthttp://node-name/repos/svn/trunk/parentPath.
Thiscreates:
path/file1
path/file2
...
Notethedifferencea"."makes.
svncheckoutfile:///repos/svn/trunk/path/
svnco-r497http://node-name/repos/svn/trunk/pathfile-name
Also:svncohttps://...,svn://...,andsvn+ssh://
MS/Windows:svncofile:///c:/repository/project/trunk
Checkouteveryfilefromthepathandsubdirectoriesspecifiedbelow.Creates"working"copyoffilesanddirectories.
Checkoutarepository.
Useoption"-r"tospecifyaspecificrevisionotherthanthelatest.
TheURL"svn://"communicateswithanSVNserver(port3690)
TheURL"http://"comunicateswiththeApacheserverandmodulemod_dav_svn(port80)[morecommonserver]
svncleanupCleanupsubversionfilesresultingfromescapedprocessesandcrashed.
svncommitfilename
svncommit--message"Messagegoeshere."filename
svncommit-m"Messagegoeshere."filename
svncifilename1filename2filename3
svnci.Check-in(commit)local"working"file,filesordirectoryandcontents(recursively)intoSubversionrepository.Atomic,i.e.allcommittedornone,noincompletecheck-in.
svncopysourcedestination_clone
Also:svncp...Copyfileordirectorytree.OnecancopyfromonelocalworkingcopytoanotherortorepositoryserverURL's.ThesourcesanddestinationscanbeworkingcopiesorURLs.
svncopyhttp://host/repos/project/trunkhttp://host/repos/project/tags/TagName-1.4.5-m"TagRelease1.4.5"Tagarelease.Takesasnapshotoftherepositoryandassignsaname.Thiscanbeperformedatanydirectorybranch.
svncopy.http://host/repos/project/tags/TagName-1.4.5-m"TagRelease1.4.5"Tagarelease.Takesasnapshotofyourlocalworkingcopyandassignsaname.Thiscanbeperformedatanydirectorybranch.
svndeletefilename
svndeletedirectory
Also:del,removeorrm
svnrmhttp://host/repos/project/trunk/file-or-directoryDeletefilefromrepository.TheUNIXcommandrmfile-name.Mustperforma"commit"toupdatetherepositoryandlocalworkingdirectorywiththechanges.i.e.:
svncommit.
svndifffilename
svndifilenameShowfilediffsbetweenSVNrepositoryandyourfilechangesusingGNUfilediffformat.UseGUIdifftoolsasshownbelow.
svndiff-rrev1:rev2filenameShowfilediffsbetweenspecifiedversions.
Example:svndiff-r456:459subfn.cpp
UsingGUIdifftool:svndiff-r457:459--diff-cmdkdiff3file-name
svndifffilename>patch-fileGeneratepatchfileusedbythepatchcommand.
svnexportdirectoryExportdirectorytreetoyourfilesystembutitwillnotbea"workingdirectory"underSVNcontrol.
svnexport-rRev-Numberhttp://node-name/pathExportdirectorytreeofspecifiedversionandcreatelocaldirectorytreeandfilesnotunderSVNcontrol.
svnimportlocal-directoryhttp://node/repos/svn/trunk/directoryAdddirectory(andfilesinitrecursively)topathinrepositoryspecified.
svninfofilenameDisplayinformationaboutfileordirectory.(Datemodified,author,revision,pathinrepository.)
CannotspecifyaURL.
svnlistdirectory
svnlistfile-nameListfileordirectoryoffilesinrepository.Usedtobrowserepositorybeforecheckout.Ifcurrentdirectoryisgiven(svnlist./),thenSubversionwilllisttherepositoryURLofthecurrentdirectory.
svnlist-rRevisionNumberdirectoryListdirectoryoffilesinrepositoryinspecifiedrevision.
svnlockfilename-m"commentastowhyitslockedorbywhom"
(Commentisnotrequiredbutisoftenuseful)Lockfiletograntexclusiveaccesstooneandforbidallothers.Acommitwillunlockthefile(unlessthe"--no-unlock"optionisused).Alockcanberemovedwiththecommands:svnunlockfilename,svnlookandthesvnadmincomands(i.e.List:svnadminlslocksandremove:svnadminrmlocksfilename).
svnlogfilename
svnlog.
svnloghttp://URL/path/file
svnlog-v.
svnlog-rRevisionNumberhttp://URL/path/fileShowtheSubversionlogmessagesforasetofrevision(s)and/orfile(s)and/oralldirectorycontentsinrepository.
Listverbose.Includeslistofallfilesinchange
Showsthefilechangesassociatedwithrevisionnumber.
svnmergehttp://url/path/branch1http://url/path/branch2working-local-dir
svnmergefile1@revJfile2@revK
svnmerge-r414:411http://url/pathworking-dir
svnmerge-r413:HEADfile-nameMergedirectorychangesintoyourcurrentworkingdirectoryormergeafileinSubversionintothefileinyourworkingdirectory.Iftargetisnotspecified,theidenticalbasenameorcurrentdirectoryisassumed.Usedtoincorporatechangescheckedinwhicharenotaccountedforinyourfileortomergebranches.
ExampleusingGUImergetool:
svndiff-r459:454--diff-cmdkdiff3--extensions'-m'file-name
Next,tellsubversionthattheconflictshavebeenresolved:
svnresolvefile-name
Finally,check-infile:svncifile-name
orabortchanges:svnrevertfile-name
svnmerge--dry-run-r414:413http://url/pathTestmerge.NochangesaremadetoyourlocalworkingcopybutshowsSubversionfeedbackasifmergewasperformed.
svnmerge-r414:413http://url/path
svnmerge-r414:413.Undochangescommittedinrevision414.
svnmkdirdirectory
svnmkdirhttp://URL/directoryCreateanewdirectoryunderversioncontrol.
svnmovedirectory1directory2
svnmvdirectory1directory2
svnmvfile-old-namefile-new-nameRenameormoveafileordirectory.Moves/renamesfile/directoryinrepositoryandinlocalworkarea.
Mustperformsvncifile-new-nameafterthemoveforchangestototakeplaceinrepository.
svnrevertfilenameUndochangesinlocalworkfiles.Throwawaylocalchanges.
svnresolvedfilenameRunthiscommandafterresolvingmergeconflicts.Next"commit"yourchanges.
svnstatus
svnstatus-u
svnstatus-u.
svnstatus-uq.Showstatusoffilechangesincurrentdirectoryandrecursivelyindirectoriesbelow.
Showoutofdatefileinfo:svnstatus--show-updates
(equivalent:svnstatus-u)
-u:Determinesstatusbycomparingyourlocalrepositorywiththeserverrepository.Withoutthisoption,thestatusshownwillonlybethechangesyouhavemadeinyourlocalrepository.
-q:Quiet.Donotprint"?:File/directorynotunderversioncontrol"or"!:File/directorymissing"extraneousinformation.
Firstcollumn:
*A:Filetobeadded
*C:Conflictingchanges
*D:Filetobedeleted
*G:Filetobemergedwithupdatesfromserver
*M:Filehasbeenmodified
*R:Filetobereplaced
*G:Filetobemerged
*X:Resourceisexternaltorepository(svn:externals)
*?:File/directorynotunderversioncontrol
*!:File/directorymissing
*~:Versioneditemobstructedbysomeitemofadifferentkind.
Secondcollumn:Modificationofproperties
*''nomodifications.Workingcopyisuptodate.
*'C'Conflicted
*'M'Modified
*'*'Localfiledifferentthanrepository.Anewerrevisionexistsontheserver.Updatewillresultinmergeorpossibleconflict.
Thirdcollumn:Locks
o''notlocked
o'L'locked
o'S'switchedtoabranch
svnswitchhttp://server/new-branch
svnswitch--relocatehttp://server/old-pathhttp://server/new-pathSwitchyourlocalworkingcopytomirroranewrepositorybranchinsteadofmaintrunkorpreviousbranch.Alsoallowsyoutopointyourrepositorytoanewpathontheserveriftheserverpathchangessinceyouperformedacheck-out.
svnupdate
svnupdatefilename
svnupdate-r458filename
svnupdate--ignore-externals./MigrateallupdatesfromSubversionrepositorytoyourlocalcopy(recusivelyforallfilesinthecurrentdirectoryandallbelowit).Iftherehavebeenupdatestothesvnrepositorysinceyoudownloadedthefiles,subversionwillgiveyoutheopportunitytomerge.Statusoffileswillusethecodingasstatedabovefor"status".Filesmarkedwitha"C"(conflict)shouldbemergedofreverted.Ifmergedthenonecanperforma"resolve"andthena"check-in".
Ifafilenameisspecified,onlythatfileisupdated.
Canalsosyncronizetoaspecifiedrevisiongivenby-r.
Use--ignore-externalstoavoidtheslowprocessingofexternalstoapotentiallyslowdistantinternetserver.
WhereRevisionNumberis:
*HEAD:Thelatestrevisionintherepository.
*BASE:The"pristine"revisionofaniteminaworkingcopy.Matchescheckedoutversionbeforeanymodifications.
*COMMITTED:Thelastrevisioninwhichanitemchangedbefore(orat)BASE.
*PREV:Therevisionjustbeforethelastrevisioninwhichanitemchanged.(Technically,COMMITTED-1.)
ExampleSession:
(Assumesthattherepositoryhasalreadybeencreated.ForSubversionrepositorycreationandSubversionserverconfiguration,seethe(YoLinuxSubversionandTractutorial)
*Checkout:svncheckouthttp://svnserver/repos/svn/trunk/Project1
*Gotosourcecodedirectory:cdProject1/src
*Editfiles:
ovifile1.cpp
ovifile2.cpp
*Verifyandtest:make
Wearereadytocheck-inthefilesintotheSubversionrepository.
*Checkrepositoryandreportonnewrevisionsandchangesothershavecheckedin:svnstatus-u.
*Aftermanylonghoursordaysofeditingandwork,getupdatesothershavemade:svnupdate
Ufile.h
Cfile1.cpp
Gfile2.cpp
?a.out
Youwillsee:
oU:Filewasupdatedwithanewerversionchecked-insinceyourcheckout.
oG:Automaticallymergedwithnoconflicts.
oC:Notmergedduetoconflicts.Youmadechangestothesamesectionofcodeastheupdatemadebysomeoneelsesinceyourcheckout.
*Foreach"conflicted"filetherewillbethreenewlocalfilesgeneratedby"update":
ofile1.cpp.mine(File-postediting)
ofile1.cpp.rold(BASE-preediting)
ofile1.cpp.rnew(HEAD-Updatedfilefromrepository)
Thefilefile1.cppstillexistsbutwithsvnconflictmarkerstringsaddedinthefile.
Atthispoint,acheck-inwillfailuntilthemergeisresolved.
*Mergeoptions:
oEditthefilefile1.cpp
Textmarkersareplacedinthefiletoshowtheconflictsbetweenthe"HEAD"and"mine"versions.
OR
otkdiff-conflictfile1.cpp
OR
oUseaGUImergetool:kdiff3file1.cpp.minefile1.cpp.rnew-ofile1.cpp
OR
oThrowoutyourchanges/abort:svnrevertfile1.cpp
Noresolveorcheck-innecessaryiffileisreverted.
*Verifyandtest,again:make
*NotifySubversionthatconflictshavebeenresolved:svnresolvedfile1.cpp
Note:Thisalsoremovesthetemporaryfiles".mine"and".r###".
*Check-intoSubversionrepository:svnci-m"Addcommentshere"file1.cpp
SubversionPegrevisions:
PegrevisionsareusedsoSubversioncanfindapreviousversionofaresource(fileordirectory)ifits'locationwasdifferentthanitisnow.PegrevisionsarethatextrahintSubversionneedstoclearupambiguity.
$svncommand-rOPERATIVE-REVitem@PEG-REV
ThedefaultpegrevisionisBASEforworkingcopyitemsandHEADforrepositoryURLs.Whennooperativerevisionisprovided,itdefaultstobeingthesamerevisionasthepegrevision.
ThePEG-REVisspecifiediftheresource(file/directory)inquestionusetoappearinadirectorywhichisnolongerinthesameplaceornolongerexists.The"peg-revision"mustbespecifiedsosubversioncanlookatthedirectoryinthatrevisionsoitcanfindtheresource.
Ifapegrevisionisspecifiedwithoutanoperativerevision,thentheoperativerevisionisassumedtobethesameasthepegrevision.
Formoresee:http://svnbook.red-bean.com/en/1.5/svn.advanced.pegrevs.html
SubversionProperties:
FilesunderrevisioncontrolcanincludeSubversionkeywordswhichpropertiescanbesetwiththe"propset"command.KeywordsaresubstitutedwiththeSubversionpropertiesandwillnotappearinthefileuntilacommitisperformed.OtherpropertiesareusedtomodifythebehaviorofSubversion.
ThefollowingpropertiescanbesetonentitiesstoredinSubversion:
PropertyDescription
svn:ignoreAnewlineseparatedlistoffilepatternstoignore.Listoffiles/directoriestobeignoredbysvnstatus
svn:keywordsValidRCSstylekeywordsare:
*HeadURL-TheURLfortheheadversionoftheobject.
Also:$URL$
*LastChangedBy-Thelastpersontomodifythefile.
Also:$Author$
*LastChangedDate-Thedate/timetheobjectwaslastmodified.
Willappearas:$LastChangedDate:2005-07-2222:02:37-0700(Fri,22Jul2005)$
Also:$Date$
*LastChangedRevision-Describesthelastknownrevision.
Willappearas:$LastChangedRevision:XXX$where"XXX"istherevisionnumber.
Also:$Rev$,Revision
*$Id$-Acompressedsummaryoftheprevious4keywords.
ExampleRCSstylecommentExampleOutput
/*$URL$
$Rev$
$Author$
$Date$
$Id$
*/
/*$URL:http://server/svn/path/file.cpp$
$Rev:2$
$Author:Greg$
$Date:2006-10-1214:31:84-0400(Thu,12Oct2006)$
$Id:file.cpp32006-10-1218:31:84ZGreg$
*/
svn:executableEnsurefileattributeisexecutable.Possiblevalues:ON,OFF
Example:svnpropsetsvn:executableONapp.exe
svn:eol-styleOneof'native','LF','CR','CRLF'.Specifyandmaintainspecifiedlineendingfortextfile.
*LF:Unix,Linux,standardsbasedOS,proprietarylegacysystems,etc.
*CRLF:DOSandMicrosoftOSs
*CR:Responseinputscripts,etc
Example:find./-name"*.h"-execsvnpropsetsvn:eol-styleLF{}\;
svn:mime-typeThemimetypeofthefile:
*text/html
*text/css
*text/plain
*image/jpeg
*...
Seefile/etc/mime.typesforalistofmimetypes.
Examples:
*svnpropsetsvn:mime-typetext/plainfile.cpp
*svnpropsetsvn:mime-typetext/htmlfile.html
WebpagesrenderedfromsubversionwilldisplayasHTMLsourceratherthanasawebpageunlessthismimetypeisapplied.
svn:needs-lockPreventsconflictsforfileswhichcannotbecontextuallymerged.i.e.photos,binaries,objectlibraries.
svn:externalsListoffilesordirectoriespointedto.Locaterepositorywheredirectoryspecifiedshouldberetrieved.Thedirectivepropsetisnotrequired:
svnpropeditsvn:externalslocal-target-dir
local-target-dirhttp://server/svn/dir-remote
local-target-dir/subdir-r###http://server/svn/dir-remote2
svnupdate
svncommit
svnpropgetsvn:externals./
Thepropertyappliestothedirectory.Subversioncannotlistorwebbrowsesvn:externals.Check-out("co"),"export"and"log"canbeperformed.
Mustsetenvironmentvariable"EDITOR","SVN_EDITOR","VISUAL"orsettheSubversionconfigurationfile(~/.subversion/config)attributeeditor-cmd.i.e.:exportEDITOR=vi
Note:Subversion1.6introducesfileexternalsinadditiontodirectoryexternals.Thefileshowevermustresideinthesamerepository.Also,thefilemustpointtoalocationwhichexistsinyourlocalworkingdirectory.
[PotentialPitfall]:Applysvnexternalstodirectoriesandnotfiles.(version1.4)
[PotentialPitfall]:Ifgeneratingatag(branch),oneshouldassigntherevisionnumbertotheexternallinktotrulysnapshottherepositoryforthattag.Thisrevisionnumbershouldbespecifiedinthetaggedbranchversionofthesvnexternal.
[PotentialPitfall]:Therevisionnumbersshownbysvninfowillreflecttheversionnumbersoftherepositoryinwhichthefilesarestored.Ifthefilesareimportedviaansvnexternaldirectory,therevisionnumberswillreflectthatoftheexternalrepositorywhichtheexternalpointstoandthusfromwherethefileswereimported.
CommandDescription
svnpropdelPropertyNamefile-name
svnpropdel--revprop-rRevisionNamehttp://url/path
Also:pdel,pdRemovepropertynamefromfilesordirectories.
Removepropertiesonfileinrepository.
svnpropeditPropertyNamefile-name
svnpropedit--revprop-rRevisionNamehttp://url/path
Also:pedit,peEditpropertynameoffilesordirectories.
Editpropertiesonfileinrepository.
svnpropgetPropertyNamefile-name
svnpropget--revprop-rRevisionNamehttp://url/path
Also:pget,pgPrintvalueofpropertynameoffilesordirectories.
Printpropertiesonfileinrepository.
svnproplistfile-name
svnproplist*
svnproplist--revprop-rRevisionNamehttp://url/path
Also:plist,plListpropertiesoffile,filesordirectory.
svnpropsetPROPNAMEPropertyValuefile-name
svnpropsetPROPNAME--revprop-rRevisionNamePropertyValuehttp://url/path
svnpropsetsvn:mime-typetext/htmlfile-name.dat
Also:pset,psSetpropertiesoffileordirectory.
Setmimetypeforafileintherepository.Mustperformacommittouploadchangestotherepository.
Setfilepropertiessothat"^M"'sareremoveduponcheck-in:
svnpropsetsvn:eol-styleLFfile-name.txt
SeeYoLinuxSubversionserverconfigurationtutorial:Noctrl-M.
SubversionandGraphicaldiffsforLinux:
Threetypesoffiledifferencesarecoveredinthissection:
1.Showfiledifferencesmadesincecheckoutwasmade.Thisshowsthechangesyouhavemade.Itisusefulltoperformthisbeforeanupdate.
2.ShowfiledifferencesbetweentwofilesversionsstoredinSubversion.
3.Showdifferences/conflicts,chooseandmerge.UseourbashscriptsvndiffwrapperwhichintegratesintoSubversion'sfilecheck-inprocess.
1)Filedifferencessincecheckout:
Thefollowingscriptswillallowyoutoviewthechangesyouhavemadesincecheckout.Usethescriptbeforerunning"svnupdate"asanupdatewillalterthefilewithdiffchevron(>>>>)markers.Afterperforminga"svnupdate",usetkdiff,gtkdifforkdiff3asdescribedbelowinsteadofthescripts:
Usethefollowingbashshellscripttousethegraphicaldifftool"mgdiff"withSubversion.
svndiff:
viewsource
print?
01#!/bin/bash
02#svndiff1.0
03#usage:svndifffile
04
05if[[!-d.svn]]
06then
07echoERROR:YouarenotworkinginanSVNdirectory.
08exit1
09fi
10
11rev="--revisionHEAD"
12
13if[[!-n$1]]
14then
15echo"Usage:svndiff[option]file"
16echo"Options:"
17echo"-hDiffwithlatestinrepository(HEAD)-Default"
18echo"-bDiffwithwhatyouhadcheckedout(BASE)"
19echo"-cDiffwithCOMMITTED,theversionbeforeBASE"
20echo"-pDiffwithPREV,theversionbeforeCOMMITTED"
21echo"-rrevnumDiffwithspecifiedrevision(specifyinteger)"
22exit1
23fi
24
25whilegetopts":r:hbcp"Option
26do
27case$Optionin
28h)rev="--revisionHEAD";;
29b)rev="--revisionBASE";;
30c)rev="--revisionCOMMITTED";;
31p)rev="--revisionPREV";;
32r)rev="--revision$OPTARG";;
33*)echo"Incorrectoptionspecified.Use-hor-bor-r#";;
34esac
35done
36shift$(($OPTIND-1))
37
38#Definegraphicaldifftool
39#
40
41#ThegeometryoptionusedbyMotif,TclandXbasedprograms
42geometry="-geometry1280x800+0+0"
43
44#ThefollowingisforMotifdiff
45#-w:ignorewhitespace
46dif="mgdiff-args-w"
47
48file=$1
49prev=${file}_PREV
50
51#Trapbashcommandsignals
52#SIGINT2
53#SIGQUIT3
54#SIGTERM15
55trap"rm-f$prev"2315
56svncat$rev$file>$prev2>/dev/null
57$dif$geometry$prev$file
58
59sleep1
60rm-f$prev
Comparesyourcurrentlocalcopywiththelatestintherepository(Default"-h").
OR
Usethefollowingbashshellscripttousethegraphicaldifftool"gvimdiff:"withSubversion:
svndiff:
viewsource
print?
01#!/bin/bash
02#usage:svndifffile
03
04if[[!-d.svn]]
05then
06echoERROR:YouarenotworkinginanSVNdirectory.
07exit1
08fi
09
10#Definegraphicaldifftool
11#
12
13dif="gvimdiff\"+colomorning\"-R"
14
15file=$1
16prev=PREV_${file}
17
18#Trapbashcommandsignals
19#SIGINT2
20#SIGQUIT3
21#SIGTERM15
22trap"rm-f$prev"2315
23svncat$file>$prev2>/dev/null
24$dif$prev$file
25
26#Sleepfornon-blockingappslikegvimdiff.
27#Allowgvimdifftoreadfilebeforeitisdeleted.
28sleep2
29rm-f$prev
Compareyourcurrentlocalcopywiththeoriginalcopyyoucheckedout.
2)Filedifferencesbetweentworevisions:
ThisconfigurationsupportstheuseofGUIdifftoolswithSubversionbyusingthecommand:svndiff-r457:459--diff-cmd
Somedifftoolsaresupportedwithnativesvn.i.e.:svndiff-r457:459--diff-cmdkdiff3file-namewhileothersrequireawrapperscripttoarrangetheargumentscorrectly.
Subversionconfigurationsanddefaultsarespecifiedinthefile:$HOME/.subversion/config
..
...
[helpers]
editor-cmd=gedit
diff-cmd=/opt/bin/diffScript
diff3-cmd=/opt/bin/diff3Script
...
..
ThisconfigurationconfiguresSubversiontoexecutethescript/opt/bin/diffScripttolaunchyourowndifftoolwiththecommand:svndiff-rOld:NewURL.
File:/opt/bin/diffScript
viewsource
print?
01#!/bin/bash
02
03LeftLabel=$3
04RightLabel=$5
05LeftFile=$6
06RightFile=$7
07
08#gtkdiff$LeftFile$RightFile
09tkdiff$LeftFile$RightFile-L"$LeftLabel"-L"$RightLabel"&
10
11#waitforcommandtofinish
12wait
Note:Todebugwhatispassedasacommandlineargumenttothedifftool,setthediff-cmdto"echo":
..
...
[helpers]
diff-cmd=echo
...
..
Thisconfigurationechostothescreenthecommandlineargumentsbeingpassedtothedifftoolwhenthefollowingcommandisexecuted:svndiff.....
i.e.-u-Ld0/f01.cpp(revision1)-Ld0/f01.cpp(workingcopy)d0/.svn/text-base/f01.cpp.svn-based0/.svn/empty-file
3)Conflicts,filedifferencesandmerge:
*tkdiff:Subversionconflictresolutionmerge:tkdiff-conflictfile1.cpp
Selectfromtkdifftoolbar:"Merge"+"ShowMergeWindow"toopenthirdresultswindow.
*kdiff3diffandmerge:svndiff-r457:459--diff-cmdkdiff3--extensions'-m'file-name
*svndiffwrapper:BashscripttoaddoptionstoMerge|Ignore|Accept|Revertetcasaresultofacheck-in.Thisscriptdoesitall!!
Editfile:$HOME/.subversion/config
...
[helpers]
diff-cmd=svndiffwrapper
diff3-cmd=svndiffwrapper
...
Useourbashscriptsvndiffwrappertoperformthisintegratedtask.Bydefault,useskdiff3fordifftool.Canalsospecifyyourownchoiceofdifftool.
Placethescriptin/opt/bin/forglobaluseor$HOME/bin/forprivateuseraccessandsetpermissionssothatscriptexecutionisallowed:chmodugo+x/opt/bin/svndiffwrapper
Listofgraphicaldiffandmergetools:
*tkdiff:[download]ComeswithtkcvsSubversionGUIfront-end.
ExamplesofSubversiondiffswithtkdiff:(See:tkdiff--help)
otkdiffold-URL@revAnew-URL@revB
otkdiff-r457-r459file-name
Note:Usecommand"svnlogfile-name"toviewvalidrevisionnumbersforthefile.Referencinginvalidrevisionnumbersasinputtotkdiffwillnotwork.
*gtkdiff:Hasdiff3andmergefeatures.WrittenwithGTK+.Aftergtkdiff-0.8.0,GNOMEdesktoprequired.
*diffUse:Diff/mergeGUItool.Goodlinematchingfeatures.SupportsUnicode.
*kdiff3:Graphicaldirectoryandfilediff,mergeandedit.KDE3/Qtbased.Supportsdraganddrop.ComeswithS.u.S.E.distro.(Crossplatform)MS/Windowsdownloadavailable.Averygooddirectoryandfilediffandmergetool.
oDifference:kdiff3file1file2
oDifference:kdiff3file1file2file3
oDifferenceoftwofiles:kdiff3directory1/filedirectory2
oDifference:kdiff3directory1directory2
oMerge:kdiff3directory1directory2-odest-directory
oMerge:kdiff3file1file2-m
oMerge:kdiff3file1file2-ooutput-file
oDiffwithSVN:svndiff-r457:459--diff-cmdkdiff3file-name
*Kompare:Shipswith(RHEL4/FC3)KDESDK.[manual]
*mgdiff:[download]Motif-basedgraphicalfiledifferencebrowserandmerge.ComeswithS.u.S.E.distro.
*Meld:Compare,editandmerge.
*fldiff:Graphicalfileanddirectorydiff.(Crossplatform)
*xxdiff:Compare2or3filesandmerge.Alsocomparesdirectories.
*gvimandgvimdiff
SubversionGUIinterfacesforLinux:
*TkSVN/TkCVS:Tcl/TkbasedGUI.AverygoodUnix/LinuxandMS/WindowsGUIfront-endtoSubversion.Simpletoinstall(requirestk).SupportsGUIdiff/merge,branching,tagging,editing,check-in/check-out,...
Installationto/usr/local/binandlib(Addtoyourpath.):(requiresRPM:tkversion8.4+)
otarxzftkcvs_8_0_3.tar.gz
ocdtkcvs_8_0_3
o./doinstall.tcl-nox/opt
Configuration:(See:~/.tkcvs)
Setdefaulteditoranddifftool:
...
setcvscfg(editor)"xterm-evim"
setcvscfg(tkdiff)"tkdiff"
Alsoseedefaultconfigfile:/opt/lib/tkcvs/tkcvs_def.tcl
Setsdefaulteditorsforvariousfiletypes.Seteditorto"gedit"forrookies.
IfyouwanttorunTkSVN/TkCVSonMS/Windows,downloadTkforMS/Windows.ItcanalsoberunfromtheCygwinenvironmentusingTkprovidedintheCygwinshell.
*Tigris.org:RapidSVN:DependentonwxWidgetscrossplatformC++GUIAPI.
DownloadRPMsfromDagWieers:
orapidsvn-0.7.2-1.2.el4.rf.i386.rpm
owxGTK-2.4.2-5.2.el4.rf.i386.rpm
*pysvn:Pythonsubversionfront-end.(crossplatform)[download]
*eSVN:qtbasedGUI.Mediocre.
*KdeSvn:KDEfront-end.
*Subcommander:SubversionGUIclientwithvisualdiffandmergetoolwithsupportfordifferenttextencodings
*Subview:GTKbasedsubversion(1.3+)client.
*JSVN:JavaSVNclient
*SyncroSVNClient-Commercialproduct.Editor,difftoolandSVNclientinoneintegratedtool.
WebClients:
*Kamikaze-qscm:Webbasedfront-endsimilartoMozillaBonsai.
*WebClientforSVN:ImplementedinJSPforTomcat4
*ViewSVN:PHP4
*EasySVN:PERLcgi
Plug-ins:
*NaughtySVN:GNOMENautilusfilebrowserSVNplug-in.
*Ksvn:SubversionclientpluginfortheKDEKonquerorbrowser.
*Eclipseplug-ins:
oTigris.org:subclipse
Alsosee:C/C++developmentenvironmentandEclipse
oSubversive
SubversionSecurityTips:
OneshouldbeawareofapossibleSubversionclientsecurityhole.TheSubversionclientauthenticationwillcacheyourloginandpasswordinyourhomedirectoryinnon-encryptedcleartext.Itwillhavefilesystemsecuritysootherscannotreadthefilehowever,itstillisvisiblebyrootorbyarootuserofthefileserverifoneisusedforhomedirectories.
Herearethreesolutionstoreducethispotentialsecurityvulnerability:
1.Don'tallowSubversiontocachethepassword:svncommit-Ffile.txt--no-auth-cache
Thiswillrequestausernameandpasswordbutwillnotstoreit.
2.SettheSubversionconfigurationfileonservertonotcache:
[auth]
store-auth-creds=no
3.Deletecachedfileswhenyoulogout.Reducesriskbutdoesnoteliminateit.Thisusesthebashshelllogoutscripttoperformaclean-upoftheauthenticationfiles.
File:~/.bash_logout
viewsource
print?
1rm~/.subversion/auth/svn.simple/*
Subversionutilitycommandsandscripts:
CommandDescription
svnversionlocal-pathThissvnadmincommandwillproduceacompactversionnumberforaworkingcopy.Listsrangeofversions,adds"S"ifswitched,"M"modified.
svnchangesinceShowsthechangestothesubversionrepositorysincethelocalcopywaslastupdated.
svnlastlogDisplaysthelastlogmessagethatpertainstothecurrentworkingcopy.Simplifiedsvnlastchange.
svnlastchangeDisplaysthelastlogmessageandaunifieddiffofthechangesmadeinthelastcommit.
svn-cleanRemovesallthefilesanddirectoriesthatarenotinSubversion.
ListofKDEscripts(Seescriptswhichstartwith"svn")
ReportGeneration:
Oftenonewillhavetogenerateareportorsourcelist.Thefollowingawkscriptandcommandwillgenerateasimplesourceversiondescriptionreport:
File:svd_report.awk
viewsource
print?
1BEGIN{RS="";
2FS="\n";
3printf("%-75s%5s%-45s\n","Path","Rev","LastChangeDate");}
4/^Path:/{n1=split($1,path,":");
5n2=split($6,revision,":");
6n3=split($11,changeDate,":");
7printf("%-75s%5s%-45s\n",path[2],revision[2],changeDate[2]);}
Commandtogeneratethereport:svninfo-R*|awk-fsvd_report.awk
TheSubversion"info"commandwillgenerateadumpofinformationaboutallofthefilesunderSubversioncontrolrecursively(-R)throughallsubdirectories.TheAWKscriptwillparsetheoutputandgenerateasimplereport.TheAWKscriptviewstheSubversionoutputasanAWKrecordseperatedbyblanklinewherethecontentofeachlineisdeliminatedbythe":"(colon).
FormoreinformationonAWKscripts,seetheawkmanpage
SubversionBestPractices:
*ALWAYScompileandtestbeforecheckinginsourcecode.Subversionrevisionsshouldcorrespondtorevisionswhichcompile.
*Alwaysaddcheck-incomments.Nothingismoreobnoxiousthatlookingatablanklogorinformationhistory.
*MonstrousbinaryfileslikeCDorDVDISOimagesarebettersuitedforstorageonafilesystemratherthaninSubversion.Subversionwillnotbeabletoshowdifferencesbetwenversionandwillbeslowerthanarawfilesystem.
*Don'tcopy,renameandmovedirectoriesandfileswithsystemshellcommands.UseSubversioncommandsto"rm","mv",and"add"directoriesandfilesandthencommitchangeswhendone.WorkwithinSubversion.
*Commitchangesasasinglelogicalchangesetforonepurpose.Thusallcodechangesforasinglebugfixorenhancementshouldbechecked-intogether.Thisallowsonetobetterfollowthehistorylogofchanges.
oCheck-incodeatthedirectorylevelandallchangedfiles,recursivelyinthedirectoryandsubdirectorieswillbecheckedintogether.
svnci-m"Check-incommentgoeshere"./
oCheck-infilestogetherbyspecifyingthemexplicitly:
svnci-m"Check-incommentgoeshere"file.cppfile2.cpp...
*TieBugtrackingandSubversionCMtogether:
oUsecommentswhenchecking-infilesintoSubversion.AddbugtrackingnumberstothecommentssoSubversionwillreferenceTracbugs.
oIfusingTrac,addtraccommentssothatlinksaregeneratedtotheSubversionrepositorybyplacingtheSubversionrevisionnumberinsquarebraces(i.e.[1140])inaTraccomment.Inthisway,TracwillhaveadirectURLlinktoSubversion.
*IfusingTracintegratedwithSubversion,refertotheTracticketintheSubversioncheck-incommentusinga"#"infrontoftheTracticketnumber(eg.#65)ThisgeneratesahyperlinkwhentheSubversionlogsareviewedinTrac.
*TakingcodefromaSubversionrepositoryforuploadtoanother:Use"svnexport"andNOT"svnco"ifyouwantfilesforuploadintoanotherCMrepository.Acheckout(svnco)willcreateSubversionmanagementdirectories(.svn/)inthelocalworkingcopy.YouwillnotwanttouploadthesedirectoriesintoaCMsystemastheyareonlyfortheuser'slocalworkingdirectoryonly.An"export"willnotcreatethesedirectories.
*The"tags"branchesareNOTtobeusedasworkingbranchesbutaresnapshotsofanexistingbranch.The"tags"areforhistoricalreferencesuchasarelease,welltestedversionorprogressmilestone.
*Documentationandrelatedartifactsshouldnotbeunderthesourcetreebutparalleltoit.ThisisolatesthesourcetreesothatemailnotificationtriggerssenttodevelopersuponsourcechangeswillonlygooutonsourcechangesorregressionbuildandtestsystemslikeCabiewillonlyrebuildandtestonsourcechangesratherthanonunrelateddocumentationchanges.
Links:
*YoLinuxTutorial:SubversionServerandTracServerInstallationandConfiguration
*YoLinuxTutorial:CabieBuildSystem-InstallationandConfiguration
*svnbook.red-bean.com:OpenSourcedversionofO'ReilyBook
oSubversion1.1-singlepage
oSubversion1.1-multi-page
*Referencecard[pdf]
*Subversionary:Subversionadvocacywebsite.
*IntegratingJDeveloperandSubversion
Books:
VersionControlwithSubversion
byC.MichaelPilato
ISBN#0596004486,O'ReillyPress
Amazon.com
PracticalSubversion(Expert'sVoiceinOpenSource)
GarrettRooney
ISBN#1590592905,Apress
Amazon.com
SubversionVersionControl:UsingtheSubversionVersionControlSysteminDevelopmentProjects
WilliamNagel
ISBN#0131855182,PrenticeHallPTR
相关推荐
pub_svnserve.conf的 pub_authz.conf的配置文件有非法字符的原因引起,需要查找pub_authz.conf提的非法内容比如多余的空格删除或直接将pub_authz.conf