{"id":48,"date":"2008-09-30T11:07:10","date_gmt":"2008-09-30T10:07:10","guid":{"rendered":"http:\/\/www.miscdebris.net\/blog\/2008\/09\/30\/use-mercurial-for-easy-local-revision-backup\/"},"modified":"2008-09-30T12:10:17","modified_gmt":"2008-09-30T11:10:17","slug":"use-mercurial-for-easy-local-revision-backup","status":"publish","type":"post","link":"http:\/\/www.miscdebris.net\/blog\/2008\/09\/30\/use-mercurial-for-easy-local-revision-backup\/","title":{"rendered":"Use Mercurial for easy local revision backup"},"content":{"rendered":"<p>I regularly make backups of all my data, it&#8217;s also synchronized on several computers and hard disks. But since I backup only once a week, I don&#8217;t really have several revisions from files available between the backups. This is espacially necessary if you work on some code of a small project, which is not revisioned via svn or cvs &#8211; and you don&#8217;t want to or have no access to svn. Also you don&#8217;t want to set up a local svn or cvs repository. You could use <a href=\"http:\/\/www.apple.com\/macosx\/features\/timemachine.html\" target=\"_blank\">Time Machine<\/a> on Mac OS X and there are some other tools available on Windows, like <a href=\"http:\/\/www.mogware.com\/FileHamster\/\" target=\"_blank\">FileHamster<\/a>. But FileHamster wasn&#8217;t always trouble free and by coincidence I found another solution which is rather appealing: <a href=\"http:\/\/www.selenic.com\/mercurial\/wiki\/\" target=\"_blank\">Mercurial<\/a>.<\/p>\n<p>The nice thing about Mercurial is, that it is a fast, distributed, lightweight Source Control Management system &#8211; you don&#8217;t need a server for it. The revisions are save to the local .hg folder. In this post I just explain some basics to get started (on Windows &#8211; but apart from the installation process, it&#8217;s the same for Mac OS X and Linux).<\/p>\n<p><!--more-->First download the binary distribution of Mercurial at the <a href=\"http:\/\/mercurial.berkwood.com\/\" target=\"_blank\">download page<\/a>. Download the latest installer and let the installer change the system PATH variable, so that hg.exe (chemical symbol for Mercurial) is found in all opened CLIs. There is also a GUI Mercurial client available (<a href=\"http:\/\/tortoisehg.sourceforge.net\/\" target=\"_blank\">TortoiseHg<\/a>), but since I already have TortoiseCSV and TortoiseSVN installed, I didn&#8217;t want to bloat my contect menu any further.<br \/>\nOpen a Windows CLI (Start-&gt;Run&#8230;, enter cmd.exe) and cd into the directory where your files are which need to be revisioned. You create now a repository with<\/p>\n<pre>hg init<\/pre>\n<p>A .hg directory will be created and the repository initialized. Now we add files we want to be in the revision with e.g.<\/p>\n<pre>hg add *.php<\/pre>\n<p>Adding a folder will add also the content of that folder. After that you need to commit the files to the repository with<\/p>\n<pre>hg commit -m \"Adding files\"<\/pre>\n<p>You can check which files were changed or need to be commited with<\/p>\n<pre>hg status<\/pre>\n<p>A log will be shown with<\/p>\n<pre>hg log<\/pre>\n<p>In order to ignore files you need to create a .hgignore text file in the same directory where the .hg directory is and add something like<\/p>\n<pre>syntax: glob\r\n.hgignore\r\n*.m4<\/pre>\n<p>If you didn&#8217;t commit your changes to a file you can revert to the revision in the repository with<\/p>\n<pre>hg revert file<\/pre>\n<p>In order to go back to a special revision of a file use the<\/p>\n<pre>hg backout<\/pre>\n<p>command (see the help (hg help backout) for the exact use).<\/p>\n<p>As said, these are only the basic features. For further information head to the\u00c2\u00a0<a href=\"http:\/\/www.selenic.com\/mercurial\/wiki\/index.cgi\/Tutorial\">tutorial <\/a>or the <a href=\"http:\/\/www.selenic.com\/mercurial\/wiki\/index.cgi\/QuickReferenceCardsAndCheatSheets\" target=\"_blank\">quick reference cards<\/a>. Extensive documentation about all features can be found in the freely available book <a href=\"http:\/\/hgbook.red-bean.com\/\">&#8220;Distributed revision control with Mercurial&#8221;<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I regularly make backups of all my data, it&#8217;s also synchronized on several computers and hard disks. But since I backup only once a week, I don&#8217;t really have several revisions from files available between the backups. This is espacially necessary if you work on some code of a small project, which is not revisioned &hellip; <a href=\"http:\/\/www.miscdebris.net\/blog\/2008\/09\/30\/use-mercurial-for-easy-local-revision-backup\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Use Mercurial for easy local revision backup<\/span> <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":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[6],"tags":[23],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-miscellaneous-debris","tag-backup"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6pnj-M","_links":{"self":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts\/48"}],"collection":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":9,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":50,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts\/48\/revisions\/50"}],"wp:attachment":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}