emacs.d/clones/lisp/stevelosh.com/blog/2009/05/what-i-hate-about-mercurial/index.html
2022-10-07 15:47:14 +02:00

208 lines
No EOL
11 KiB
HTML

<!DOCTYPE html>
<html lang='en'><head><meta charset='utf-8' /><meta name='pinterest' content='nopin' /><link href='../../../../static/css/style.css' rel='stylesheet' type='text/css' /><link href='../../../../static/css/print.css' rel='stylesheet' type='text/css' media='print' /><title>What I Hate About Mercurial / Steve Losh</title></head><body><header><a id='logo' href='https://stevelosh.com/'>Steve Losh</a><nav><a href='../../../index.html'>Blog</a> - <a href='https://stevelosh.com/projects/'>Projects</a> - <a href='https://stevelosh.com/photography/'>Photography</a> - <a href='https://stevelosh.com/links/'>Links</a> - <a href='https://stevelosh.com/rss.xml'>Feed</a></nav></header><hr class='main-separator' /><main id='page-blog-entry'><article><h1><a href='../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html'>What I Hate About Mercurial</a></h1><p class='date'>Posted on May 29th, 2009.</p><p>This entry was inspired by <a href="http://jacobian.org/writing/hate-python/">Jacob Kaplan-Moss</a>, who was inspired by
<a href="http://ivory.idyll.org/blog/mar-07/five-things-I-hate-about-python">Titus</a>, who was inspired by <a href="http://use.perl.org/~brian_d_foy/journal/32556?from=rss">brian d foy</a>. The premise is that you
can't really claim to know much about a piece of software until you can name a
few things you hate about it.</p>
<p>Jacob and Titus talked about Python, and so have a bunch of other people, so I
figured I'd write about something a bit different:
<a href="http://selenic.com/mercurial">Mercurial</a>.</p>
<p>I love Mercurial to death, but there <em>are</em> a few things about it that annoy
me. Here they are, in no particular order.</p>
<ol class="table-of-contents"><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s1-configuration-through-a-textfile">Configuration Through a Textfile</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s2-hg-rm-is-a-confusing-mess">&quot;hg rm&quot; is a Confusing Mess</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s3-addremove-can-track-renames-but-won-t-unless-you-ask-it-really-nicely">Addremove Can Track Renames But Won't Unless You Ask It Really Nicely</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s4-why-the-hell-does-status-not-show-renames">Why the Hell Does Status Not Show Renames?</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s5-get-git-out-of-my-mercurial">Get Git Out of My Mercurial</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s6-bitbucket-could-be-prettier">BitBucket Could Be Prettier</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s7-mercurial-s-site-could-be-much-prettier">Mercurial's Site Could Be Much Prettier</a></li><li><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s8-but-hey-at-least-it-s-not-git">But Hey, at Least It's Not Git!</a></li></ol>
<h2 id="s1-configuration-through-a-textfile"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s1-configuration-through-a-textfile">Configuration Through a Textfile</a></h2>
<p>This is one of the things that <a href="http://git-scm.com/">git</a> people seem to like
to <a href="http://jointheconversation.org/2008/11/24/on-mercurial.html">bring up</a>:
&quot;It doesn't have a command to set your username and email and such? Lame.&quot;</p>
<p>I personally don't mind editing a text file — <code>vim ~/.hgrc</code> really isn't that
hard to type and the format is simple enough that you get the hang of it in
about ten seconds. It forces you to know <em>where</em> the config file is, which is
nice when the magic &quot;Oh man, I could put my config files under <em>version
control</em>!&quot; moment strikes.</p>
<p>That said, this is on the list because I'd like to see a command to edit some
of the common options just so people will <em>stop complaining</em> about something
so trivial.</p>
<h2 id="s2-hg-rm-is-a-confusing-mess"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s2-hg-rm-is-a-confusing-mess">&quot;hg rm&quot; is a Confusing Mess</a></h2>
<p>Here's part of the help for the <code>hg rm</code> command:</p>
<blockquote>
<p>This only removes files from the current branch, not from the entire
project history. -A can be used to remove only files that have already
been deleted, -f can be used to force deletion, and -Af can be used
to remove files from the next revision without deleting them.</p>
</blockquote>
<p>What the hell? If <code>-A</code> won't remove files that are still present, and <code>-f</code>
forces the files to be deleted, why the fuck does combining them mean <em>the
exact opposite of both</em>?</p>
<p>I had to look up the syntax every single time I wanted to use this command,
until I added this alias to my <code>~/.hgrc</code>:</p>
<pre><code>[alias]
untrack = rm -Af</code></pre>
<p>Now I can use <code>hg untrack whatever.py</code> to stop tracking a file.</p>
<h2 id="s3-addremove-can-track-renames-but-won-t-unless-you-ask-it-really-nicely"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s3-addremove-can-track-renames-but-won-t-unless-you-ask-it-really-nicely">Addremove Can Track Renames But Won't Unless You Ask It Really Nicely</a></h2>
<p>It took me a while to realize this, but Mercurial can actually record file
renames — not just separate adds and removes — when using <code>hg addremove</code>.
Here's what happens when you move a file and then use <code>hg addremove</code> normally
to have Mercurial track the changes.</p>
<pre><code>sjl at ecgtheow in ~/Desktop/test on default
$ ls
total 16
-rw-r--r-- 1 sjl 14B May 29 20:12 a
-rw-r--r-- 1 sjl 12B May 29 20:12 b
sjl at ecgtheow in ~/Desktop/test on default
$ mv b c
sjl at ecgtheow in ~/Desktop/test on default!
$ hg addremove
removing b
adding c
sjl at ecgtheow in ~/Desktop/test on default!
$ hg diff
diff --git a/b b/b
deleted file mode 100644
--- a/b
+++ /dev/null
@@ -1,1 +0,0 @@
-To you too!
diff --git a/c b/c
new file mode 100644
--- /dev/null
+++ b/c
@@ -0,0 +1,1 @@
+To you too!
sjl at ecgtheow in ~/Desktop/test on default!
$ hg commit -m 'Normal addremove.'
sjl at ecgtheow in ~/Desktop/test on default
$ </code></pre>
<p>Now watch what happens when we tell Mercurial to detect renames when using <code>hg
addremove</code>:</p>
<pre><code>sjl at ecgtheow in ~/Desktop/test on default
$ ls
total 16
-rw-r--r-- 1 sjl 14B May 29 20:12 a
-rw-r--r-- 1 sjl 12B May 29 20:12 c
sjl at ecgtheow in ~/Desktop/test on default
$ mv c b
sjl at ecgtheow in ~/Desktop/test on default!
$ hg addremove --similarity 100
adding b
removing c
recording removal of c as rename to b (100% similar)
sjl at ecgtheow in ~/Desktop/test on default!
$ hg diff
diff --git a/c b/b
rename from c
rename to b
sjl at ecgtheow in ~/Desktop/test on default!
$ hg commit -m 'This time with rename detection.'
sjl at ecgtheow in ~/Desktop/test on default
$ </code></pre>
<p>This time it notices the rename, and records it. The diff is far, far easier
to read, and if a branch is merged in where someone else changed that file,
the changes will follow it over.</p>
<p>The <code>--similarity</code> option is a percentage. I have an entry in my <code>~/.hgrc</code>
file to default that to 100, which means that renames will only be
automatically detected if the files are <em>identical</em>. It's safer, but might not
always catch everything.</p>
<p>I wish I had known this earlier or that Mercurial defaulted to 100% to catch
the obvious renames.</p>
<p>And yes, I realize I could use <code>hg rename</code> to rename it and it <em>would</em> get
recorded, but usually I'm moving files by some other method and using <code>hg
addremove</code> to clean up later.</p>
<p>Now, while we're on the topic...</p>
<h2 id="s4-why-the-hell-does-status-not-show-renames"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s4-why-the-hell-does-status-not-show-renames">Why the Hell Does Status Not Show Renames?</a></h2>
<p>Assuming they're recorded, I wish <code>hg status</code> would show that a file has been
renamed. Here's what we get instead:</p>
<pre><code>sjl at ecgtheow in ~/Desktop/test on default
$ hg rename b c
sjl at ecgtheow in ~/Desktop/test on default!
$ hg stat
A c
R b
sjl at ecgtheow in ~/Desktop/test on default!
$ hg diff
diff --git a/b b/c
rename from b
rename to c</code></pre>
<p>No, <code>hg status</code>, it clearly <em>wasn't</em> an add and a remove, according to <code>hg
diff</code>. Why doesn't <code>hg status</code> have a separate character for &quot;renamed&quot; files
so we can tell them apart?</p>
<h2 id="s5-get-git-out-of-my-mercurial"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s5-get-git-out-of-my-mercurial">Get Git Out of My Mercurial</a></h2>
<p>I <em>hate</em> that half of Mercurial's commands need a <code>--git</code> option to be really
useful. Is there any reason not to make this the default format and have a
<code>--useless</code> option for backwards compatibility?</p>
<p>I always add it to the defaults in my <code>~/.hgrc</code> but it makes me feel kind of
dirty when I do. It adds a bunch of unnecessary lines to the config file and
confuses new people.</p>
<h2 id="s6-bitbucket-could-be-prettier"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s6-bitbucket-could-be-prettier">BitBucket Could Be Prettier</a></h2>
<p>Don't get me wrong, <a href="http://bitbucket.org/">BitBucket</a> is an awesome site, but
compared to <a href="http://github.com/">GitHub</a> it looks a bit dull and unappealing.</p>
<p>It's definitely more usable (how the hell do I view a graph of all
branches/merges of a given repository on GitHub?) but there's something about
GitHub's design that just makes it pop.</p>
<h2 id="s7-mercurial-s-site-could-be-much-prettier"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s7-mercurial-s-site-could-be-much-prettier">Mercurial's Site Could Be Much Prettier</a></h2>
<p>Mercurial's site is ugly. Very ugly. It seems strange to me that the ugly
version control system (git) has a fairly good-looking site while the much
more elegant Mercurial has something that looks so boring and dated.</p>
<p>I know, <a href="http://mercurial-scm.org/">mercurial-scm.org</a> aims to fix this. Thank
you from the bottom of my heart but please, hurry. The wiki is hurting my
eyes.</p>
<h2 id="s8-but-hey-at-least-it-s-not-git"><a href="../../../entry/2009/5/29/what-i-hate-about-mercurial/index.html#s8-but-hey-at-least-it-s-not-git">But Hey, at Least It's Not Git!</a></h2>
<p>All of those things annoy me, but they're small problems compared to the
revulsion I get when I try to use git every so often.</p>
<p>Maybe that would be a good topic for another entry. At the very least it'll
probably get me a ton of pageviews and comments saying: &quot;Git's changed, man!
It's not like it used to be, it's totally intuitive now! You just gotta learn
how it stores the data!&quot;</p>
<p>I learned, and I'll still take Mercurial despite the small annoyances.</p>
</article></main><hr class='main-separator' /><footer><nav><a href='https://github.com/sjl/'>GitHub</a><a href='https://twitter.com/stevelosh/'>Twitter</a><a href='https://instagram.com/thirtytwobirds/'>Instagram</a><a href='https://hg.stevelosh.com/.plan/'>.plan</a></nav></footer></body></html>