{"id":439,"date":"2009-02-18T23:17:20","date_gmt":"2009-02-18T22:17:20","guid":{"rendered":"http:\/\/www.dotmana.com\/index.php\/?p=439"},"modified":"2009-02-18T23:17:20","modified_gmt":"2009-02-18T22:17:20","slug":"svn-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.dotmana.com\/weblog\/2009\/02\/svn-cheat-sheet\/","title":{"rendered":"SVN Cheat Sheet"},"content":{"rendered":"<p>An exhaustive SVN cheat sheet found <a target=\"_blank\" href=\"http:\/\/www.xsteve.at\/prg\/vc_svn\/svn.txt\">here<\/a> :<\/p>\n<blockquote><p>* Create a repository<br \/>\n&#8211; use the database backend<br \/>\nsvnadmin create ~\/svn_repos\/Eccos<br \/>\n&#8211; use the filesystem backend<br \/>\nsvnadmin create &#8211;fs-type=fsfs PATH<\/p>\n<p>* Import a revision<br \/>\nsvn import -m &#8220;Initial import&#8221; Eccos file:\/\/\/home\/reichr\/svn_repos\/Eccos\/trunk<\/p>\n<p>* Check out a revision<br \/>\nsvn co file:\/\/\/home\/reichr\/svn_repos\/Eccos\/trunk Eccos<\/p>\n<p>* Dump a repository<br \/>\nsvnadmin dump \/home\/reichr\/svn_repos\/Eccos | gzip -9 > dump.gz<br \/>\nsvnadmin dump \/home\/reichr\/svn_repos\/Eccos | gzip -9 > `date &#8220;+Eccosdump%Y-%m-%d_%H:%M:%S.gz&#8221;`<\/p>\n<p>* Load contents of a dump into a repository<br \/>\ngunzip -c dump.gz | svnadmin load \/home\/reichr\/svn_repos\/e<\/p>\n<p>* Import from an existing directory, no need to check it out again<br \/>\nIt should work, but you could also check it out right into \/etc. Something<br \/>\nlike this:<\/p>\n<p>$ svnadmin create \/var\/svnrepos\/admin<br \/>\n$ svn mkdir -m &#8220;initial setup&#8221; file:\/\/\/var\/svnrepos\/admin\/trunk<br \/>\nc:> svn mkdir -m &#8220;initial setup&#8221; file:\/\/\/c:\/fhs\/svn_repos\/trunk<br \/>\n$ cd \/etc<br \/>\n$ svn co file:\/\/\/var\/svnrepos\/admin\/trunk .<br \/>\n$ svn add passwd group<br \/>\n$ svn commit -m &#8220;start loading it in&#8221;<\/p>\n<p>I tested the &#8216;svn co&#8217; into &#8216;.&#8217; just now. Works great.<\/p>\n<p>* svn propset<br \/>\nsvn propset svn:keywords &#8220;LastChangedDate LastChangedRevision Id Author&#8221; weather.txt<br \/>\nsvn propset svn:keywords &#8220;LastChangedDate LastChangedRevision Id&#8221; slides.tex<\/p>\n<p>* Before an update you could use the following to get the log messages of the changes:<br \/>\nsvn log -rBASE:HEAD<\/p>\n<p>* Upgrade to a new subversion version<br \/>\n$ mv repos repos.tmp<br \/>\n$ svnadmin create repos<br \/>\n$ svnadmin-old dump repos.tmp | svnadmin load repos<br \/>\n$ # copy over any hook scripts and stuff from repos.tmp to repos<\/p>\n<p>* Upgrade my repositories at work<br \/>\n$ mv Eccos Eccos-old<br \/>\n$ svnadmin create Eccos<br \/>\n$ gunzip -c dumps\/Eccosdump2003-11-11_10:08:54.gz | svnadmin load Eccos<\/p>\n<p>* Checkout from a repository over ssh<br \/>\nsvn co svn+ssh:\/\/felix\/home\/reichr\/svn_repos\/XSteveData\/trunk data<\/p>\n<p>* Change the path of the repository for a working copy<br \/>\nsvn switch &#8211;relocate file:\/\/\/original\/path\/to\/repos file:\/\/\/new\/path<\/p>\n<p>* Put system configuration in a subversion repository<br \/>\n&#8211; create the repository \/home\/reichr\/svn_repos\/WaldiConfig<br \/>\nsvnadmin create WaldiConfig<br \/>\n&#8211; Import an empty directory<br \/>\ncd to an empty directory<br \/>\nsvn import -m &#8220;Initial import&#8221; . file:\/\/\/home\/reichr\/svn_repos\/WaldiConfig\/trunk<br \/>\n&#8211; Check it out from Waldi (user reichr)<br \/>\nsvn co svn+ssh:\/\/felix\/home\/reichr\/svn_repos\/WaldiConfig\/trunk WaldiConfig<br \/>\n&#8211; Put files in the repository (as root)<br \/>\nmv \/etc\/fstab \/home\/reichr\/WaldiConfig\/etc<br \/>\nln -s \/home\/reichr\/WaldiConfig\/etc\/fstab \/etc\/fstab<\/p>\n<p>* Network a repository via svn+ssh:<br \/>\n&#8211; create the repository on the repository host:<br \/>\nsvnadmin create rp1  &#8212; this is located at \/home\/svtest\/rp1<br \/>\n&#8211; Import data to the repository:<br \/>\nsvn import -m&#8221;Initial import&#8221; svn+ssh:\/\/svtest@host\/rp1\/trunk<br \/>\n&#8211; Checkout the project:<br \/>\nsvn co svn+ssh:\/\/svtest@host\/home\/svtest\/rp1\/trunk p1<\/p>\n<p>* Warning:<br \/>\nPutting the repository on a network filesystem my be a bad idea,<br \/>\nbecause the repository may get corrupted!<br \/>\nIt is better to put it on a local filesystem.<\/p>\n<p>* Merge from a branch back to the trunk<br \/>\nSvnMerging<\/p>\n<p>* Generate a patch to undo some local changes and redo them later<br \/>\n> What usually happens to me is that I&#8217;ve changed N files in M different<br \/>\n> directories distributed all over the filesystem, and I want to check in<br \/>\n> N-1 of them.<\/p>\n<p>Yeah, I have to do this all the time.  But I can eye a potentially<br \/>\ncomplex command-line pretty well, so if I need to commit all but one<br \/>\nfile, I do this:<\/p>\n<p>% svn diff path\/to\/file_not_committing > \/tmp\/patch.txt<br \/>\n% svn revert path\/to\/file_not_committing<br \/>\n% svn ci -m &#8220;committing all the stuff i wanted to&#8221;<br \/>\n% patch -p0 < \/tmp\/patch.txt\n\nRevert is your friend.  Learn it, use it, looooooooooove it.\n\n* Revert to a previous version\nsvn co project\n<edit foo.c, adding bugs><br \/>\nsvn ci foo.c (commits to r348)<br \/>\n<realize terrible error><br \/>\nsvn merge -r348:347 foo.c<br \/>\nsvn ci foo.c (commits 349)<\/p>\n<p>note the ordering of the revision numbers in the merge command.  what this<br \/>\nreally says is &#8220;make a diff between revision 348 and 347, and apply it<br \/>\nimmediately to foo.c&#8221;<\/p>\n<p>if you are trying to revert a directory tree with moves or deletes in it, and<br \/>\nare getting arcane errors, try the &#8211;ignore-ancestry flag.<\/p>\n<p>* Edit the commit\/log messages after the commit<br \/>\nRead chapter 7, regarding unversioned properties attached to revisions.<br \/>\nYou want to change the svn:log property:<br \/>\n$ svn propedit -r N &#8211;revprop svn:log URL<\/p>\n<p>* Svn repository via apache2<br \/>\n&#8211; manage the htpasswd file:<br \/>\nhttp:\/\/search.cpan.org\/dist\/Apache-Htpasswd\/Htpasswd.pm<br \/>\n&#8211; a sample cgi script to alter users passwords via Apache::Htpasswd:<br \/>\nhttp:\/\/perlmonks.thepen.com\/178482.html<br \/>\n&#8211; A full featured utility to add\/change users via commandline or cgi:<br \/>\nhttp:\/\/stein.cshl.org\/~lstein\/user_manage\/<\/p>\n<p>* Use svn:mime-type for nicer www browsing of a repository<br \/>\n> When browsing your repository, if you click on a filename, you see the<br \/>\n> contents of the file (assuming it&#8217;s a text file) formatted as if with a<br \/>\n> <PRE> tag.  So, if the file happens to be an HTML file, you essentially see<br \/>\n> the source HTML code.  Which, in most cases, is perfectly correct.<br \/>\n><br \/>\n> However, there are times when it would be nice to see the _formatted_ HTML<br \/>\n> instead.  Is there a way to do this, other than the cumbersome Save Page As<br \/>\n> \/ Open File process within the browser?<\/p>\n<p>If you set the svn:mime-type property on that file to &#8216;text\/html&#8217; and<br \/>\ncommit, your browser should see subsequent revisions of that file as<br \/>\nformatted HTML.<\/p>\n<p>* Versionize symlinks, unix permissions and ownership<br \/>\nsvnpropset.pl, svnpropget.pl from Steve Wray <stevew@catalyst.net.nz><br \/>\n(search on the svn mailing list or in my mail-boxes)<\/p>\n<p>* track svn trunks\/branches with all history in arch<br \/>\n&#8211; svn-arch-mirror<br \/>\nCategory: svn-arch-mirror<br \/>\nArchive: eric@petta-tech.com&#8211;2004b-ordinary<\/p><\/blockquote>\n<blockquote>\n<pre>Location: http:\/\/des.petta-tech.bogomips.org\/~eric\/MusicPD\/eric@petta-tech.com--2004b-ordinary\/<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>An exhaustive SVN cheat sheet found here : * Create a repository &#8211; use the database backend svnadmin create ~\/svn_repos\/Eccos &#8211; use the filesystem backend svnadmin create &#8211;fs-type=fsfs PATH * Import a revision svn import -m &#8220;Initial import&#8221; Eccos file:\/\/\/home\/reichr\/svn_repos\/Eccos\/trunk &hellip; <a href=\"https:\/\/www.dotmana.com\/weblog\/2009\/02\/svn-cheat-sheet\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-439","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/comments?post=439"}],"version-history":[{"count":0,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/439\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/media?parent=439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/categories?post=439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/tags?post=439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}