<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ted Naleid &#187; mercurial</title>
	<atom:link href="http://naleid.com/blog/category/mercurial/feed/" rel="self" type="application/rss+xml" />
	<link>http://naleid.com/blog</link>
	<description>Groovy, Grails and OS X tips and tricks</description>
	<lastBuildDate>Wed, 16 May 2012 00:54:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to use kdiff3 as a 3-way merge tool with mercurial, git, and Tower.app</title>
		<link>http://naleid.com/blog/2012/01/12/how-to-use-kdiff3-as-a-3-way-merge-tool-with-mercurial-git-and-tower-app/</link>
		<comments>http://naleid.com/blog/2012/01/12/how-to-use-kdiff3-as-a-3-way-merge-tool-with-mercurial-git-and-tower-app/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 06:29:08 +0000</pubDate>
		<dc:creator>tednaleid</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[shortcut]]></category>

		<guid isPermaLink="false">http://naleid.com/blog/?p=523</guid>
		<description><![CDATA[There are a few very nice looking, mac-like diff tools for OSX (Kaleidoscope and Changes come to mind), but none for doing &#8220;real&#8221; merges. By this, I mean real, 3-way merges with all of the information you need in front of you. There are no good-looking, &#8220;mac-like&#8221; merge tools, but if you swallow your pride [...]]]></description>
			<content:encoded><![CDATA[<p>There are a few very nice looking, mac-like diff tools for OSX (<a href="http://www.kaleidoscopeapp.com/" onclick="pageTracker._trackPageview('/outgoing/www.kaleidoscopeapp.com/?referer=');">Kaleidoscope</a> and <a href="http://connectedflow.com/changes/" onclick="pageTracker._trackPageview('/outgoing/connectedflow.com/changes/?referer=');">Changes</a> come to mind), but none for doing &#8220;real&#8221; merges.  By this, I mean real, <a href="http://en.wikipedia.org/wiki/3-way_merge#Three-way_merge" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/3-way_merge_Three-way_merge?referer=');">3-way merges</a> with all of the information you need in front of you.</p>
<p>There are no good-looking, &#8220;mac-like&#8221; merge tools, but if you swallow your pride there are a few different options for 3-way merges, including <a href="http://www.araxis.com/merge_mac/" onclick="pageTracker._trackPageview('/outgoing/www.araxis.com/merge_mac/?referer=');">Araxis Merge ($$$!)</a>, <a href="http://www.sourcegear.com/diffmerge/downloads.php" onclick="pageTracker._trackPageview('/outgoing/www.sourcegear.com/diffmerge/downloads.php?referer=');">DiffMerge</a>, <a href="http://www.deltopia.com/compare-merge-sync/macosx/" onclick="pageTracker._trackPageview('/outgoing/www.deltopia.com/compare-merge-sync/macosx/?referer=');">DeltaWalker</a>, and <a href="http://en.wikipedia.org/wiki/Apple_Developer_Tools#FileMerge" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Apple_Developer_Tools_FileMerge?referer=');">FileMerge</a> which comes free with XCode.</p>
<p>I&#8217;ve tried them all, and find them all confusing.  They all tend use a 3-pane display to do the merging with your file in the left pane, the file you&#8217;re merging in the right pane, and the messy half-merged file in the middle.</p>
<p>That&#8217;s not enough information.</p>
<p>A 3-way merge actually has four important sources of information:<span id="more-523"></span></p>
<ul>
<li><code>LOCAL</code> &#8211; your file with the changes you&#8217;ve made to it</li>
<li><code>REMOTE</code> &#8211; the file you&#8217;re merging in, possibly authored by someone else</li>
<li><code>BASE</code> &#8211; the common ancestor file that <code>LOCAL</code> and <code>REMOTE</code> came from</li>
<li><code>MERGE_RESULT</code> &#8211; the file resulting from the merge where you resolve conflicts</li>
</ul>
<p>You often need to see all four of these pieces of information to make intelligent choices.  Where you came from (<code>LOCAL</code>), where the other person&#8217;s changes came from (<code>REMOTE</code>), where you both started (<code>BASE</code>) and where you are now (<code>MERGE_RESULT</code>).</p>
<p>Most other 3-way merge tools either conflate or omit the <code>BASE</code> and that can make it harder to see what the right thing to do is.</p>
<p><a href="http://kdiff3.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/kdiff3.sourceforge.net/?referer=');">Kdiff3</a> is my merge tool of choice.  It&#8217;s not pretty; it&#8217;s cross-platform <a href="http://en.wikipedia.org/wiki/Qt_(framework)" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Qt_framework?referer=');">Qt</a> based so it has a very old-school linux GUI feel to it.  But like linux, it&#8217;s functional and can help you quickly be productive once you get over the learning curve.</p>
<p>If you&#8217;ve got 2 heads that you need to merge in your current repository:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/2_heads_need_to_merge.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/2_heads_need_to_merge.png" alt="" title="2_heads_need_to_merge" width="403" height="107" class="aligncenter size-full wp-image-526" /></a><br />
We made this modification to <code>file.txt</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">--git</span> a<span style="color: #000000; font-weight: bold;">/</span>file.txt b<span style="color: #000000; font-weight: bold;">/</span>file.txt
<span style="color: #660033;">---</span> a<span style="color: #000000; font-weight: bold;">/</span>file.txt
+++ b<span style="color: #000000; font-weight: bold;">/</span>file.txt
<span style="color: #000000; font-weight: bold;">@@</span> -<span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> +<span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">@@</span>
-BASE: common_ancestor
+LOCAL: <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> current working branch</pre></div></div>

<p>and they made this change to the same file and line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">--git</span> a<span style="color: #000000; font-weight: bold;">/</span>file.txt b<span style="color: #000000; font-weight: bold;">/</span>file.txt
<span style="color: #660033;">---</span> a<span style="color: #000000; font-weight: bold;">/</span>file.txt
+++ b<span style="color: #000000; font-weight: bold;">/</span>file.txt
<span style="color: #000000; font-weight: bold;">@@</span> -<span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> +<span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">@@</span>
-BASE: common_ancestor
+REMOTE: other branch we<span style="color: #ff0000;">'re merging in</span></pre></div></div>

<p>If you run your SCM&#8217;s merge command (here, in mercurial: <code>hg merge -r 2</code>), and have kdiff3 configured as your merge tool, you&#8217;ll get a pop-up window like this:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/kdiff3_merge_window_fixed.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/kdiff3_merge_window_fixed.png" alt="" title="kdiff3_merge_window_fixed" width="1241" height="512" class="alignleft size-full wp-image-555" /></a><br />
As you can see, it shows you all 4 pieces of information, <code>BASE</code>, <code>LOCAL</code>, and <code>REMOTE</code> on top, and the <code>MERGE_RESULT</code> file on the bottom.  It currently has a <code>Merge Conflict</code> that you need to fix.</p>
<p>You can move from one unresolved conflict to the next using the triple up and triple-down colored arrows in the middle of the tool bar.  When a conflict is highlighted, you can press any combination of the A, B, and C buttons in the toolbar.  Pressing one of those buttons will resolve the conflict with the code from pane A, B, or C on top.  So if the <code>LOCAL</code> file (your file) had the right changes in it, you&#8217;d press B.</p>
<p>It&#8217;s possible to press more than one button if code from multiple panes is valid.  You can also directly edit the file in the <code>MERGE_RESULT</code> pane to make manual changes if the correct merge is not the exact text in A/B/C.</p>
<p>Another option, if you want to take all of the changes from one file and discard any changes from the others, is to go to the &#8220;Merge&#8221; menu and pick one of &#8220;Choose A Everywhere&#8221;, &#8220;Choose B Everywhere&#8221;, or &#8220;Choose C Everywhere&#8221;.</p>
<p>Once you&#8217;ve resolved your file, simply save it (cmd-S) and quit out of kdiff3.  Your SCM should see the <code>MERGE_RESULT</code> no longer has any merge conflicts and will mark it as resolved, ready for you to commit it.  If there are other files with merge conflicts, you can repeat the process with those files.</p>
<h2>Installing kdiff3</h2>
<p>Installing kdiff3 is as easy as <a href="http://sourceforge.net/projects/kdiff3/files/kdiff3/" onclick="pageTracker._trackPageview('/outgoing/sourceforge.net/projects/kdiff3/files/kdiff3/?referer=');">downloading the latest version from sourceforge</a> and copying it to your <code>/Applications</code> directory.</p>
<p>The app is a simple wrapper around a Qt-based application.  It can be run from the command line at <code>/Applications/kdiff3.app/Contents/MacOS/kdiff3</code>.  You can make a symlink of that into your path, but I assume in the instructions below only that you&#8217;ve got kdiff3 in your <code>/Applications</code> folder.</p>
<h2>Mercurial Integration</h2>
<p>Mercurial command line integration is pretty easy.  Just open up your <code>~/.hgrc</code> file (or create one if you don&#8217;t have it already), and add this to it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>extdiff<span style="color: #7a0874; font-weight: bold;">&#93;</span>
cmd.kdiff3 = <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>kdiff3.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>kdiff3
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>merge-tools<span style="color: #7a0874; font-weight: bold;">&#93;</span>
kdiff3.args = <span style="color: #007800;">$base</span> <span style="color: #007800;">$local</span> <span style="color: #007800;">$other</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">$output</span></pre></div></div>

<p>That configures kdiff3 as your merge tool of choice, so it should pop up automatically when you hit a merge conflict.  You can also use it as a diff tool:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg kdiff3 <span style="color: #660033;">-r</span> revision_to_compare_to</pre></div></div>

<h2>Git Command-Line Integration</h2>
<p>To configure the git command line to use kdiff3 as a diff and merge tool, add this to your ~/.gitconfig:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>difftool <span style="color: #ff0000;">&quot;kdiff3&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
    path = <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>kdiff3.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>kdiff3
    trustExitCode = <span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>difftool<span style="color: #7a0874; font-weight: bold;">&#93;</span>
    prompt = <span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">diff</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
    tool = kdiff3
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mergetool <span style="color: #ff0000;">&quot;kdiff3&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
    path = <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>kdiff3.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>kdiff3
    trustExitCode = <span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mergetool<span style="color: #7a0874; font-weight: bold;">&#93;</span>
    keepBackup = <span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>merge<span style="color: #7a0874; font-weight: bold;">&#93;</span>
    tool = kdiff3</pre></div></div>

<p>Now you can use the external tool commands to look at diffs:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> difftool <span style="color: #7a0874; font-weight: bold;">&#91;</span>revision_sha<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>and fix unresolved merge conflicts:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> mergetool</pre></div></div>

<h2>Git Tower Integration</h2>
<p>I&#8217;m normally a pretty hard-core command line user, but I still sometimes find the places I get myself in git confusing enough that I&#8217;m willing to use a GUI to get myself out.  I think that <a href="http://www.git-tower.com/" onclick="pageTracker._trackPageview('/outgoing/www.git-tower.com/?referer=');">git-tower</a> is the best git GUI available right now. </p>
<p>It can show you diff files and lets you browse through history in it&#8217;s UI. It also lets you do a number of basic and mid-level commands (adding, committing, rebasing, squashing commits, cherry-picking, etc), but it doesn&#8217;t have a built-in diff or merge tool.  </p>
<p>It does come with the ability to integrate with a few different merge tools out of the box, but not kdiff3.  </p>
<p>After a little digging around, I found a generic <a href="http://www.git-tower.com/files/applicationHelp/pgs/Integration_DiffTools.html" onclick="pageTracker._trackPageview('/outgoing/www.git-tower.com/files/applicationHelp/pgs/Integration_DiffTools.html?referer=');">post showing how configure Tower with a plist file and a shim shell script</a>, but nothing specific to kdiff3.</p>
<p>I figured out how to get Tower and kdiff3 to play nice with each other, and have the instructions and files in a <a href="https://github.com/tednaleid/git-tower-kdiff3-shim" onclick="pageTracker._trackPageview('/outgoing/github.com/tednaleid/git-tower-kdiff3-shim?referer=');">GitHub repository</a>.  To get it working, just clone the repository to a temporary directory, and run the install.sh script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>github.com:tednaleid<span style="color: #000000; font-weight: bold;">/</span>git-tower-kdiff3-shim.git 
<span style="color: #7a0874; font-weight: bold;">cd</span> git-tower-kdiff3-shim
.<span style="color: #000000; font-weight: bold;">/</span>install.sh</pre></div></div>

<p>It simply copies the plist file and the shim script into the appropriate directories (and Tower is <i>very</i> picky about those locations).</p>
<p>Then you need to go into Tower&#8217;s Preferences->Git Config control panel, and choose kdiff3 as the diff and merge tool:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/tower_preferences.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/tower_preferences.png" alt="" title="tower_preferences" width="764" height="386" class="alignleft size-full wp-image-542" /></a><br />
For a quick rundown of how Tower works with kdiff3 as a merge tool, here&#8217;s an example where we&#8217;ve got one commit where we made changes to locally:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/my_master.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/my_master.png" alt="" title="my_master" width="1416" height="822" class="alignleft size-full wp-image-534" /></a><br />
And another commit on <code>origin/master</code> where someone else made changes to the same piece of code:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/their_master.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/their_master.png" alt="" title="their_master" width="1416" height="822" class="alignleft size-full wp-image-536" /></a><br />
We&#8217;ve pulled it down and now have 2 heads within our repository. To fix this, we need to merge and resolve the conflicts, hit the merge button and we&#8217;ll get an error message because there are conflicts that git can&#8217;t resolve automatically:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/tower-conflict.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/tower-conflict.png" alt="" title="tower-conflict" width="1416" height="822" class="alignleft size-full wp-image-540" /></a><br />
If you highlight a file with merge conflicts, and then hit the &#8220;Merge Tool&#8221; button, it will bring up kdiff3 and let us use it to resolve the issue:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/kdiff3-merge.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/kdiff3-merge.png" alt="" title="kdiff3-merge" width="1257" height="512" class="alignleft size-full wp-image-545" /></a><br />
Fix the merge conflicts in kdiff3 (ex: press &#8220;C&#8221; to change it to &#8220;Goodbye Cruel World&#8221;), save it, and quit out of kdiff3. Tower should see that the file has had it&#8217;s conflicts resolved and lets you commit the merge and carry on.</p>
<p>You can also use Kdiff3 as a regular diff tool if you don&#8217;t like looking at diff files.  Just choose a file that you&#8217;ve modified to diff:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/tower-diff.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/tower-diff.png" alt="" title="tower-diff" width="1416" height="822" class="alignleft size-full wp-image-547" /></a><br />
Press the &#8220;Diff Tool&#8221; button, and it&#8217;ll pop up in kdiff3:<br />
<a href="http://naleid.com/blog/wp-content/uploads/2012/01/tower-kdiff3.png"><img src="http://naleid.com/blog/wp-content/uploads/2012/01/tower-kdiff3.png" alt="" title="tower-kdiff3" width="1257" height="512" class="alignleft size-full wp-image-548" /></a><br />
Kdiff3 might be homely, but it&#8217;s easy to use once you understand how it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://naleid.com/blog/2012/01/12/how-to-use-kdiff3-as-a-3-way-merge-tool-with-mercurial-git-and-tower-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using a Unique Grails Working Directory for each Mercurial Branch</title>
		<link>http://naleid.com/blog/2010/05/07/using-a-unique-grails-working-directory-for-each-mercurial-branch/</link>
		<comments>http://naleid.com/blog/2010/05/07/using-a-unique-grails-working-directory-for-each-mercurial-branch/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:07:40 +0000</pubDate>
		<dc:creator>tednaleid</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[shortcut]]></category>

		<guid isPermaLink="false">http://naleid.com/blog/?p=184</guid>
		<description><![CDATA[At work, we&#8217;re using mercurial for our source control. As we&#8217;ve released code to production we&#8217;ve needed to branch our repository to support what&#8217;s in production as well as ongoing development. By default, grails uses ~/.grails as the working directory. If you&#8217;re doing branchy development, you can run into problems with this if you&#8217;ve got [...]]]></description>
			<content:encoded><![CDATA[<p>At work, we&#8217;re using <a href="http://mercurial.selenic.com/" onclick="pageTracker._trackPageview('/outgoing/mercurial.selenic.com/?referer=');">mercurial</a> for our source control.  As we&#8217;ve released code to production we&#8217;ve needed to branch our repository to support what&#8217;s in production as well as ongoing development.  </p>
<p>By default, grails uses <code>~/.grails</code> as the working directory.  If you&#8217;re doing branchy development, you can run into problems with this if you&#8217;ve got plugins installed in one branch that aren&#8217;t in the other.  Having a unique directory per branch prevents you from having to run <code>grails clean</code> all the time.</p>
<p>Here&#8217;s a quick shell script that changes the grails working directory to have the branch name as a suffix if your source is contained in a mercurial repository (ex: the default branch would be <code>~/.grails_default</code> and the 1.0 branch would be <code>~/.grails_1.0</code>).  If your application is not in a repo, it just uses the regular <code>~/.grails directory</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">HG_BRANCH</span>=<span style="color: #000000; font-weight: bold;">`</span>hg branch <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">GRAILS_SCRIPT</span>=<span style="color: #007800;">$GRAILS_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>grails
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$HG_BRANCH</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">GRAILS_WORK_DIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> ~<span style="color: #000000; font-weight: bold;">`/</span>.grails_<span style="color: #007800;">$HG_BRANCH</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** grails working directory: <span style="color: #007800;">$GRAILS_WORK_DIR</span>&quot;</span>
	<span style="color: #007800;">$GRAILS_SCRIPT</span> -Dgrails.work.dir=<span style="color: #007800;">$GRAILS_WORK_DIR</span> $<span style="color: #000000; font-weight: bold;">@</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** default grails working directory&quot;</span>
	<span style="color: #007800;">$GRAILS_SCRIPT</span> $<span style="color: #000000; font-weight: bold;">@</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Just save this script as &#8220;grails&#8221; and put it in your PATH before the $GRAILS_HOME/bin directory (also make sure that you&#8217;ve defined $GRAILS_HOME).  I have a ~/bin directory that&#8217;s the first thing in my PATH.</p>
<p>If you use the grails-debug command, you can repeat these steps for that, just change <code>GRAILS_SCRIPT</code> to <code>$GRAILS_HOME/bin/grails-debug</code>.</p>
<p>This same technique could easily be modified to be used for other source control systems such as git or subversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://naleid.com/blog/2010/05/07/using-a-unique-grails-working-directory-for-each-mercurial-branch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mercurial DVCS DevJam Presentation</title>
		<link>http://naleid.com/blog/2009/11/08/mercurial-dvcs-devjam-presentation/</link>
		<comments>http://naleid.com/blog/2009/11/08/mercurial-dvcs-devjam-presentation/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 02:43:20 +0000</pubDate>
		<dc:creator>tednaleid</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[presentation]]></category>

		<guid isPermaLink="false">http://naleid.com/blog/?p=106</guid>
		<description><![CDATA[This past week, I gave a presentation to the DevJam meeting on the advantages of using Mercurial, a DVCS (Distributed Version Control System) over tools like Subversion, Perforce, and ClearCase. I&#8217;ve been using a mercurial repository at bitbucket to host the build-test-data grails plugin, as well as a number of other things that I&#8217;ve done. [...]]]></description>
			<content:encoded><![CDATA[<p>This past week, I gave a presentation to the <a href="http://www.devjam.com/" onclick="pageTracker._trackPageview('/outgoing/www.devjam.com/?referer=');">DevJam</a> meeting on the advantages of using Mercurial, a DVCS (Distributed Version Control System) over tools like Subversion, Perforce, and ClearCase.<br />
<span id="more-106"></span><br />
I&#8217;ve been using a mercurial repository at bitbucket to host the build-test-data grails plugin, as well as a number of other things that I&#8217;ve done.  We&#8217;re also using it at work to hold our grails applications.  I find that the way Mercurial works fits better with my style of development over git, the other popular DVCS.</p>
<p>The turnout at the meeting was great, and a heated discussion followed the presentation (as it always does at that meeting).</p>
<p>I&#8217;ve checked the original keynote files along with a PDF version into <a href="http://bitbucket.org/tednaleid/dvcs-with-mercurial/src/" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/tednaleid/dvcs-with-mercurial/src/?referer=');">a mercurial repository</a>.</p>
<p>Here&#8217;s <a href="http://www.slideshare.net/tednaleid/mercurial-dvcs-presentation-to-devjam-1142009-2426116" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/tednaleid/mercurial-dvcs-presentation-to-devjam-1142009-2426116?referer=');">the presentation on SlideShare</a>:</p>
<div style="width:425px;text-align:left" id="__ss_2426116"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/tednaleid/mercurial-dvcs-presentation-to-devjam-1142009-2426116" title="Mercurial DVCS presentation to DevJam 11/4/2009" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/tednaleid/mercurial-dvcs-presentation-to-devjam-1142009-2426116?referer=');">Mercurial DVCS presentation to DevJam 11/4/2009</a><object style="margin:0px" width="600" height="500"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dvcspresentation-091104221655-phpapp01&#038;stripped_title=mercurial-dvcs-presentation-to-devjam-1142009-2426116" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dvcspresentation-091104221655-phpapp01&#038;stripped_title=mercurial-dvcs-presentation-to-devjam-1142009-2426116" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="500"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/?referer=');">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/tednaleid" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/tednaleid?referer=');">tednaleid</a>.</div>
</div>
<p><script type="text/javascript">var dzone_style = '1';</script><br />
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> </p>
]]></content:encoded>
			<wfw:commentRss>http://naleid.com/blog/2009/11/08/mercurial-dvcs-devjam-presentation/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>My Mercurial Setup (Plus Some Useful Shims and Jigs)</title>
		<link>http://naleid.com/blog/2008/11/25/my-mercurial-setup-plus-some-useful-shims-and-jigs/</link>
		<comments>http://naleid.com/blog/2008/11/25/my-mercurial-setup-plus-some-useful-shims-and-jigs/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 03:48:45 +0000</pubDate>
		<dc:creator>tednaleid</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[shortcut]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[jig]]></category>
		<category><![CDATA[shim]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://naleid.com/blog/?p=37</guid>
		<description><![CDATA[In his book, The Productive Programmer, Neal Ford talks about using shims or jigs to help productivity. Jigs and shims are quickly created little snippets of code that automate repetitive tasks or make them easy enough that they&#8217;re worth doing. They&#8217;re little tools that help make your job easier and let you avoid using brute [...]]]></description>
			<content:encoded><![CDATA[<p>In his book, <a href="http://productiveprogrammer.com/wiki/index.php/Main_Page" onclick="pageTracker._trackPageview('/outgoing/productiveprogrammer.com/wiki/index.php/Main_Page?referer=');">The Productive Programmer</a>, Neal Ford talks about using shims or jigs to help productivity.  Jigs and shims are quickly created little snippets of code that automate repetitive tasks or make them easy enough that they&#8217;re worth doing.  They&#8217;re little tools that help make your job easier and let you avoid using brute force to solve all of your problems.</p>
<p>My home directory has a bin folder in it that&#8217;s continually getting new jigs added to it, and my zshrc file is an ever-expanding list of quick shell functions.</p>
<p>Recently, I&#8217;ve been doing a lot more work with <a href="http://www.selenic.com/mercurial/wiki/" onclick="pageTracker._trackPageview('/outgoing/www.selenic.com/mercurial/wiki/?referer=');">Mercurial</a> as the team that I&#8217;m on switched from Subversion a couple of months ago on our Grails project.  The initial transition was a little difficult for some people, but I think just about everyone is pretty happy with the transition now that we&#8217;ve made it.  </p>
<p>Something that has helped everyone get comfortable with more complex Distributed Version Control System like Mercurial has been the distribution of shims and jigs amongst the team.  I thought these tips might be useful to others as well.<br />
<span id="more-37"></span></p>
<h2>Configuring Mercurial</h2>
<p>After installing mercurial (the easiest way is to just get the <a href="http://www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages" onclick="pageTracker._trackPageview('/outgoing/www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages?referer=');">appropriate binary package for your OS</a>), you&#8217;ll want to get it configured.</p>
<p>A good place to start is with someone else&#8217;s configuration file.  Here&#8217;s my my current ~/.hgrc configuration file (with the username replaced):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[extensions] 
fetch=
extdiff=
color=
hgext.graphlog=
hgshelve=~/Documents/workspace/hgshelve/hgshelve.py
rdiff=~/Documents/workspace/rdiff/rdiff.py
hgext.mq =
&nbsp;
[diff]
git = 1
&nbsp;
[ui]
username = YOUR NAME &lt;YOUR_NAME@YOUR_COMPANY.com&gt;
&nbsp;
[extdiff]
cmd.kdiff3 =
cmd.chdiff =
opts.chdiff = --wait
&nbsp;
[merge-tools]
kdiff3.args = $base $local $other -o $output</pre></div></div>

<p>In it, you&#8217;ll see a number of useful extensions, including:</p>
<ul>
<li><code>hg fetch</code> &#8211; automates the pull/update working copy/merge/commit merge steps</li>
<li><code>extdiff extension</code> &#8211; Mercurial allows you to set up external tools to do diffs and merges.  I&#8217;m using 2 different graphical merge tools for different purposes</li>
<ul>
<li><code>hg chdiff</code> &#8211; <a href="http://changesapp.com/" onclick="pageTracker._trackPageview('/outgoing/changesapp.com/?referer=');">Changes.app</a> for just comparing two files in a diff.  Changes is a beautiful shareware diff tool for the mac, it unfortunately doesn&#8217;t do a <a href="http://en.wikipedia.org/wiki/Merge_(revision_control)#Three-way_merge" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Merge_revision_control_Three-way_merge?referer=');">3-way merge</a>.</li>
<li><code>hg kdiff3</code> &#8211; For merging, (and some diff situations), I need the power of a 3-way merge tool and I&#8217;ve found kdiff3 to be the best one that I&#8217;ve used.  It&#8217;s an open source, free, cross platform 3-way merge tool.  Using a 3-way merge tool is imperative for getting your merges correct.</li>
</ul>
<li><code>color extension</code> &#8211; just colorizes some output including the status command</a></li>
<li><code>hg glog</code> &#8211; an ascii graphical log of the commit tree (enhanced &#8220;hg log&#8221;)</li>
<li><code>hg shelve</code> &#8211; simplified patch management that allows you to &#8220;shelve&#8221; changes without committing them locally, for instance if you want to do a fetch, I asked about this on <a href="http://stackoverflow.com/questions/125272/using-mercurial-whats-the-easiest-way-to-commit-and-push-a-single-file-while-le" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/125272/using-mercurial-whats-the-easiest-way-to-commit-and-push-a-single-file-while-le?referer=');">Stack Overflow</a></li>
<li><code>hg rdiff</code> &#8211; remote diff, allows you to compare a file checked into your local repo with a file in the remote repository, I also asked about this on <a href="http://stackoverflow.com/questions/156280/using-mercurial-is-there-an-easy-way-to-diff-my-working-copy-with-the-tip-file" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/156280/using-mercurial-is-there-an-easy-way-to-diff-my-working-copy-with-the-tip-file?referer=');">Stack Overflow</a></li>
<li><code>mq extension</code> &#8211; mercurial queues, a more advanced topic that I don&#8217;t think anyone else at my workplace uses, but there&#8217;s a lot of power in mqueue if you look into it.  The Mozilla guys have a really <a href="https://developer.mozilla.org/en/Mercurial_Queues" onclick="pageTracker._trackPageview('/outgoing/developer.mozilla.org/en/Mercurial_Queues?referer=');">nice introductory tutorial</a> to using this plugin.</li>
</ul>
<h2>Setting up KDiff3 so you can do 3-way merges</h2>
<p>The simplest way to get KDiff3 is to <a href="http://kdiff3.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/kdiff3.sourceforge.net/?referer=');">download the binary from the main website</a> (click on the download link and then choose the binary appropriate for your platform).</p>
<p>For the mac, you&#8217;ll just get a zip file with a KDiff3.app file in it that you should drag to your /Applications directory.  Then, you need to make sure that the actual executable in the application is in your path.  I just create a symlink in my path to the executable inside the application package:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>kdiff3.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>kdiff3 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>kdiff3</pre></div></div>

<p>You might not have /usr/local/bin in your path by default.  If you can execute <code>kdiff3 --help</code> on the command line, you&#8217;re ready to go.</p>
<h2>Setting up the &#8220;<a href='http://www.selenic.com/mercurial/wiki/index.cgi/ShelveExtension' onclick="pageTracker._trackPageview('/outgoing/www.selenic.com/mercurial/wiki/index.cgi/ShelveExtension?referer=');">shelve</a>&#8221; extension</h2>
<p>The easiest way to get the shelve extention set up is to simply clone the project that holds the python script to your local filesystem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg clone http:<span style="color: #000000; font-weight: bold;">//</span>freehg.org<span style="color: #000000; font-weight: bold;">/</span>u<span style="color: #000000; font-weight: bold;">/</span>tksoh<span style="color: #000000; font-weight: bold;">/</span>hgshelve<span style="color: #000000; font-weight: bold;">/</span> hgshelve</pre></div></div>

<p>Then just make sure that the path in your ~/.hgrc file points to the correct location of the hgshelve.py file in the cloned repository.</p>
<p>You can test that it&#8217;s working by just executing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg <span style="color: #7a0874; font-weight: bold;">help</span> shelve</pre></div></div>

<p>If you don&#8217;t get an error message, it&#8217;s set up right and you can start using it.</p>
<h2>Setting up the &#8220;<a href='http://www.selenic.com/mercurial/wiki/index.cgi/RdiffExtension' onclick="pageTracker._trackPageview('/outgoing/www.selenic.com/mercurial/wiki/index.cgi/RdiffExtension?referer=');">rdiff</a>&#8221; extension</h2>
<p>Setting up the rdiff extension is similar to the shelve extension above.  Just clone the repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg clone <span style="color: #660033;">-r</span> c3ac1c497bf0 http:<span style="color: #000000; font-weight: bold;">//</span>hg.kublai.com<span style="color: #000000; font-weight: bold;">/</span>mercurial<span style="color: #000000; font-weight: bold;">/</span>extensions<span style="color: #000000; font-weight: bold;">/</span>rdiff</pre></div></div>

<p><strong>We clone an older revision currently as the tip in that project uses some unsupported stuff that isn&#8217;t in mercurial 1.0.2, if you&#8217;ve got a newer version of mercurial, you might be able to get the tip of the rdiff extension and have it work.<br />
</strong></p>
<p>Then make sure that your ~/.hgrc is pointed to the right path for the rdiff.py file in the repo you just cloned.</p>
<p>It&#8217;s a little quirky in that it actually modifies the existing &#8220;hg diff&#8221; command by detecting if the first parameter is a remote URL. If it is then it will diff that file against your tip file in your local repo (not the working copy). This as the remote repo is first in the arguments, it&#8217;s the reverse of what I&#8217;d expect, but you can pass &#8220;&#8211;reverse&#8221; to the hg diff command to switch that around.</p>
<p>I could see these being potential enhancements to the extension, but for now, I can work around them with a bash/zsh shell function in my startup file. It does a temp checkin of my working copy (held by the mercurial transaction so it can be rolled back), executes the reverse diff, and then rolls the transaction back to return things back to the way they were:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hgrdiff<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    hg commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;temp commit for remote diff&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> 
    hg <span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">--reverse</span> http:<span style="color: #000000; font-weight: bold;">//</span>my_hardcoded_repo <span style="color: #007800;">$*</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>
    hg rollback      <span style="color: #666666; font-style: italic;"># revert the temporary commit</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>And then call it with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hgrdiff <span style="color: #000000; font-weight: bold;">&lt;</span>filename to <span style="color: #c20cb9; font-weight: bold;">diff</span> against remote repo tip<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<h2>Other Mercurial Jigs and Shims</h2>
<p>Here are some other jigs and shims that I&#8217;ve found useful.</p>
<h4>Jig to Get a List of Files With the Same Status</h4>
<p>One jig that I&#8217;ve gotten a ton of use out of, is a modification to the normal &#8220;hg status&#8221; command.  Normally, &#8220;hg status&#8221; returns a list of all files that are different in the working directory when compared to the tip if the repository.  In the output of status, each file is printed with a character in the first column that signifies the status of that file.  Ex:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> hg status
M build.xml
A src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Foobar.groovy
A src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Quux.groovy
? src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Bar.groovy
? src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Baz.groovy</pre></div></div>

<p>Some of the most common statuses are:</p>
<ul>
<li><code>?</code> &#8211; not tracked, unknown to the source control repository
<li>
<li><code>M</code> &#8211; modified, this file is different in the working copy than on the file system
<li><code>A</code> &#8211; added, source control is aware of this file, but it hasn&#8217;t yet been committed
<li><code>R</code> &#8211; removed, this file has been marked for deletion on the next commit
<li><code>!</code> &#8211; missing, this file is not present in the working copy but is in source control
</ul>
<p>Often, I&#8217;ll want to do something with all of the files in a particular status, but I can&#8217;t easily do that as they&#8217;re mixed in with the other file types.  Also, the status flag at the beginning of the line prevents me from piping the status into another command.</p>
<p>I&#8217;ve come up with this shell function to allow me to filter lists of files (it actually works for subversion too, so there are 2 aliases).  Just paste this into your bash/zsh startup file:</p>
<pre code="bash">
vcst() {
	# print out all of the files with a passed in status flag (M - modified, A - added, ? - unknown, etc) (default ?)
	# expects first parameter to be the version control command (likely svn or hg)
	STATUS='\?'
	if [ -n "$2" ]
	then
		STATUS=$2
	fi
	$1 status | egrep "^$STATUS" | awk '{print $2}'
}

alias svnst='vcst svn'
alias hgst='vcst hg'
</pre>
<p>Then you can use the &#8220;hgst&#8221; command to see all the files in a particular status, one per line.  By default, it shows files that aren&#8217;t tracked (&#8220;<code>?</code>&#8220;), but you can pass a parameter that specifies another flag type if it&#8217;s other than &#8220;<code>?</code>&#8220;.</p>
<p>To see the list of files that aren&#8217;t in source control, just use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> hgst
src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Bar.groovy
src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Baz.groovy</pre></div></div>

<p>If you want to delete all of the files that aren&#8217;t in source control, all you have to do is send the results of that command to rm:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">`</span>hgst<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;"># removes src/groovy/Bar.groovy and src/groovy/Baz.groovy</span></pre></div></div>

<p>If you want to edit all of the files that have been added in TextMate:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mate <span style="color: #000000; font-weight: bold;">`</span>hgst A<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;"># opens src/groovy/Foobar.groovy and src/groovy/Quux.groovy in TextMate</span></pre></div></div>

<p>If you want to do a diff and see only the files that have been modified using kdiff3:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg kdiff3 <span style="color: #000000; font-weight: bold;">`</span>hgst M<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;"># would show a diff of build.xml vs the working copy</span></pre></div></div>

<h4>Shim to See a List Incoming and Outgoing Files</h4>
<p>When I&#8217;m about to push changes out to a remote server, or pull changes down from that server, I often want to know what files will be affected by this action.  Surprisingly, there isn&#8217;t an easy built-in way to do this.</p>
<p>There is the <code>hg incoming -v</code> command, which will print out a log format of all of the different changesets.  But I don&#8217;t really care about all the changesets, I just want to know which files will be affected.  Here&#8217;s a sample run of incoming with 3 changesets:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> hg incoming <span style="color: #660033;">-v</span>
comparing with <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>ted.naleid<span style="color: #000000; font-weight: bold;">/</span>temp<span style="color: #000000; font-weight: bold;">/</span>foo
searching <span style="color: #000000; font-weight: bold;">for</span> changes
changeset:   <span style="color: #000000;">1</span>:5c5f71bda234
user:        Ted Naleid <span style="color: #000000; font-weight: bold;">&lt;</span>ted.naleid<span style="color: #000000; font-weight: bold;">@</span>carol.com<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">date</span>:        Tue Nov <span style="color: #000000;">25</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">30</span>:<span style="color: #000000;">51</span> <span style="color: #000000;">2008</span> <span style="color: #660033;">-0600</span>
files:       src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Foobar.groovy
description:
initial commit of foobar.groovy
&nbsp;
&nbsp;
changeset:   <span style="color: #000000;">2</span>:fe4a615747af
user:        Ted Naleid <span style="color: #000000; font-weight: bold;">&lt;</span>ted.naleid<span style="color: #000000; font-weight: bold;">@</span>carol.com<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">date</span>:        Tue Nov <span style="color: #000000;">25</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">31</span>:<span style="color: #000000;">36</span> <span style="color: #000000;">2008</span> <span style="color: #660033;">-0600</span>
files:       src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Bar.groovy src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Foobar.groovy
description:
committing <span style="color: #000000;">2</span> files
&nbsp;
&nbsp;
changeset:   <span style="color: #000000;">3</span>:21e3d26bc3eb
tag:         tip
user:        Ted Naleid <span style="color: #000000; font-weight: bold;">&lt;</span>ted.naleid<span style="color: #000000; font-weight: bold;">@</span>carol.com<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">date</span>:        Tue Nov <span style="color: #000000;">25</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">31</span>:<span style="color: #000000;">54</span> <span style="color: #000000;">2008</span> <span style="color: #660033;">-0600</span>
files:       build.xml src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Baz.groovy src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Foobar.groovy src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Quux.groovy
description:
3rd commit of files</pre></div></div>

<p>That&#8217;s not very useful as it&#8217;s hard to parse out the actual files in that list (and see only the unique list).</p>
<p>I use the following shim (just put in your bash/zsh rc file) to make this simple:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># look for lists of files in piped output, sort the unique set of them and print them one per line</span>
lf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">&quot;^files:&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{for (i=2; i&lt;=NF; i++) print $i}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> 
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ic</span>=<span style="color: #ff0000;">&quot;hg incoming -v | lf&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">og</span>=<span style="color: #ff0000;">&quot;hg outgoing -v | lf&quot;</span></pre></div></div>

<p>Once this is installed, you can simply use the <code>og</code> (outgoing) or <code>ic</code> (incoming) aliases to see what you&#8217;ll affect if you actually do a push or a pull.</p>
<p>Here&#8217;s the output using the incoming shim on same changeset above:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ic
build.xml
src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Bar.groovy
src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Baz.groovy
src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Foobar.groovy
src<span style="color: #000000; font-weight: bold;">/</span>groovy<span style="color: #000000; font-weight: bold;">/</span>Quux.groovy</pre></div></div>

<p>That makes it quick and easy to see the real things that you&#8217;ll affect by your actions.</p>
<h4>Enhancing Your Shell Prompt With Mercurial Info</h4>
<p>A couple of other commands that I have in my zshrc (they should also work in a bash startup file):</p>
<pre>
hgtarget() {
    hg_root=`hg root 2>&#038;1 | egrep -v "$abort:"`
   	if [ $hg_root ]; then
    	if [ -f $hg_root/.hg/hgrc ]; then
        	hg_target=`cat $hg_root/.hg/hgrc | egrep "^default =" | sed 's/\(^default = \(http:\/\/\)*\)\(.*@\)*//'`
        	echo "$hg_target"
        fi
    fi
}

hgbranch() {
	hg_root=`hg root 2>&#038;1 | egrep -v "$abort:"`
	if [ $hg_root ]; then
		hg_branch=`hg branch`
		echo "$hg_branch"
	fi
}
</pre>
<p>These commands will tell you the path to the default push/pull target for your repository (<code>hgtarget</code>) as well as the current branch that you&#8217;re working on (<code>hgbranch</code>) in your repo.</p>
<p>I&#8217;ve added these to my shell prompt so that when I&#8217;m in a mercurial repository I&#8217;m more informed of the context that I&#8217;m working in.  My prompt is a little complicated (lots more going on there besides this), but there are a number of <a href="http://www.hypexr.org/bash_tutorial.php#cmd_prompt" onclick="pageTracker._trackPageview('/outgoing/www.hypexr.org/bash_tutorial.php_cmd_prompt?referer=');">good tutorials</a> out there for modifying yours.  </p>
<p><script type="text/javascript">var dzone_style = '1';</script><br />
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> </p>
]]></content:encoded>
			<wfw:commentRss>http://naleid.com/blog/2008/11/25/my-mercurial-setup-plus-some-useful-shims-and-jigs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Distributed Source Control with Mercurial Presentation</title>
		<link>http://naleid.com/blog/2008/06/03/distributed-source-control-with-mercurial-presentation/</link>
		<comments>http://naleid.com/blog/2008/06/03/distributed-source-control-with-mercurial-presentation/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 03:10:28 +0000</pubDate>
		<dc:creator>tednaleid</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[dvcs mercurial grails svn]]></category>

		<guid isPermaLink="false">http://naleid.com/blog/?p=25</guid>
		<description><![CDATA[I gave a presentation at work today on Distributed Version Control Systems and Mercurial.  We're currently using Subversion, and I'm nudging my co-workers into getting interested in the benefits of distributed version control over a centralized system.]]></description>
			<content:encoded><![CDATA[<p>I gave a presentation at work today on Distributed Version Control Systems and Mercurial.  We&#8217;re currently using Subversion, and I&#8217;m nudging my co-workers into getting interested in the benefits of distributed version control over a centralized system.</p>
<p>The presentation starts with the pros and cons of distributed systems and gives a brief overview of the top 3 most popular DVCS systems:</p>
<ul>
<li><a href="http://git.or.cz/" onclick="pageTracker._trackPageview('/outgoing/git.or.cz/?referer=');">Git</a></li>
<li><a href="http://bazaar-vcs.org/" onclick="pageTracker._trackPageview('/outgoing/bazaar-vcs.org/?referer=');">Bazaar</a></li>
<li><a href="http://www.selenic.com/mercurial/wiki/" onclick="pageTracker._trackPageview('/outgoing/www.selenic.com/mercurial/wiki/?referer=');">Mercurial</a></li>
</ul>
<p>I go into the details of why I chose to use Mercurial and describe some common usage patterns for people used to using Subversion.</p>
<p>I then did a live-coding session where I created a quick grails application, added it to a new repository, cloned the repository and pushed changes back and forth to show how mercurial handles merging and history.</p>
<p>I also suggest how developers can <a href="http://naleid.com/blog/2008/05/01/using-mercurial-as-a-super-client-for-subversion/">use mercurial as a &#8220;super client&#8221;</a> to enable much of this power while still working on a team that uses subversion.<br />
<span id="more-25"></span><br />
Overall the presentation was well received, and many of the developers seemed excited about the potential in a DVCS like mercurial.  I know a number of them downloaded mercurial this afternoon and gave it a shot.  I also spoke with our build guy and one of our architects who both seem interested in switching over.</p>
<p>If you&#8217;re interested in installing mercurial, you can easily <a href="http://mercurial.berkwood.com/" onclick="pageTracker._trackPageview('/outgoing/mercurial.berkwood.com/?referer=');">download binaries</a>, or else you can go to the <a href="http://www.selenic.com/mercurial/wiki/" onclick="pageTracker._trackPageview('/outgoing/www.selenic.com/mercurial/wiki/?referer=');">main mercurial website</a> and compile it from source.</p>
<p>Here&#8217;s the presentation (without notes):</p>
<div style="width:425px;text-align:left" id="__ss_445714"><object style="margin:0px" width="600" height="525"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=dvcs-with-mercurialnonotes-1212548095115415-9"/><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=dvcs-with-mercurialnonotes-1212548095115415-9" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="525"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/?src=embed&amp;referer=');"><img src="http://static.slideshare.net/swf/logo_embd.png" style="border:0px none;margin-bottom:-5px" alt="SlideShare"/></a> | <a href="http://www.slideshare.net/tednaleid/dvcs-with-mercurial-no-notes?src=embed" title="View Dvcs With Mercurial (No Notes) on SlideShare" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/tednaleid/dvcs-with-mercurial-no-notes?src=embed&amp;referer=');">View</a> | <a href="http://www.slideshare.net/upload?src=embed" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/upload?src=embed&amp;referer=');">Upload your own</a></div>
</div>
<p>I&#8217;ve also uploaded a <a href="http://www.slideshare.net/tednaleid/distributed-version-control-dvcs-with-mercurial/" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/tednaleid/distributed-version-control-dvcs-with-mercurial/?referer=');">version of the presentation with full notes on slideshare</a>.  Adding the notes makes it too small to read in their flash app, so I suggest downloading the presentation if you want to see them.  The notes also include all of the detail in the live coding session (though you have to have grails 1.0.2 or better installed to get the same stuff I did).</p>
<p>I&#8217;d be interested to hear from others who have convinced their teams to switch from using a centralized repository to a distributed one like Mercurial.  </p>
]]></content:encoded>
			<wfw:commentRss>http://naleid.com/blog/2008/06/03/distributed-source-control-with-mercurial-presentation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

