<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en"
   >
  <title type="text">Code Kills</title>
  <subtitle type="text"></subtitle>

  <updated>2012-01-22T21:05:58Z</updated>
  <generator uri="http://blogofile.com/">Blogofile</generator>

  <link rel="alternate" type="text/html" href="http://blog.codekills.net" />
  <id>http://blog.codekills.net/feed/atom/</id>
  <link rel="self" type="application/atom+xml" href="http://blog.codekills.net/feed/atom/" />
  <entry>
    <author>
      <name></name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Nested Repository Handling in git and Mercurial</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2011/07/14/nested-repository-handling-in-git-and-mercurial" />
    <id>http://blog.codekills.net/2011/07/14/nested-repository-handling-in-git-and-mercurial</id>
    <updated>2011-07-14T04:31:09Z</updated>
    <published>2011-07-14T04:31:09Z</published>
    <category scheme="http://blog.codekills.net" term="Version control" />
    <summary type="html">Nested Repository Handling in git and Mercurial</summary>
    <content type="html" xml:base="http://blog.codekills.net/2011/07/14/nested-repository-handling-in-git-and-mercurial">&lt;div class=&#34;document&#34;&gt;
&lt;p&gt;git and Mercurial both have extensions for nesting particular versions of
external repositories (git has &lt;a class=&#34;reference external&#34; href=&#34;http://kernel.org/pub/software/scm/git/docs/git-submodule.html&#34;&gt;submodules&lt;/a&gt;, Mercurial
has &lt;a class=&#34;reference external&#34; href=&#34;http://mercurial.selenic.com/wiki/Subrepository&#34;&gt;subrepos&lt;/a&gt;), and I&#39;ve
found it interesting (and telling?) to compare the implementations.&lt;/p&gt;
&lt;p&gt;To nest the repository &lt;tt class=&#34;docutils literal&#34;&gt;nested&lt;/tt&gt; at &lt;tt class=&#34;docutils literal&#34;&gt;.subrepos/nested&lt;/tt&gt; in Mercurial, the
line &lt;tt class=&#34;docutils literal&#34;&gt;.subrepos/nested = nested&lt;/tt&gt; is added to the file &lt;tt class=&#34;docutils literal&#34;&gt;.hgsub&lt;/tt&gt; and the line
&lt;tt class=&#34;docutils literal&#34;&gt;[hash] .subrepos/nested&lt;/tt&gt; (where &lt;tt class=&#34;docutils literal&#34;&gt;[hash]&lt;/tt&gt; is the current revision&#39;s hash)
is added to the file &lt;tt class=&#34;docutils literal&#34;&gt;.hgsubstate&lt;/tt&gt;. As the version of &lt;tt class=&#34;docutils literal&#34;&gt;nested&lt;/tt&gt; changes, the
&lt;tt class=&#34;docutils literal&#34;&gt;.hgsubstate&lt;/tt&gt; file is updated and committed like any other file.&lt;/p&gt;
&lt;p&gt;In contrast, to nest &lt;tt class=&#34;docutils literal&#34;&gt;nested&lt;/tt&gt; at &lt;tt class=&#34;docutils literal&#34;&gt;.modules/nested&lt;/tt&gt; in git, the lines:&lt;/p&gt;
&lt;pre class=&#34;literal-block&#34;&gt;
[submodule &amp;quot;.modules/nested&amp;quot;]
    path = .modules/nested
    url = nested
&lt;/pre&gt;
&lt;p&gt;are added to &lt;tt class=&#34;docutils literal&#34;&gt;.gitmodules&lt;/tt&gt;, and an entry is added to &lt;a class=&#34;reference external&#34; href=&#34;http://book.git-scm.com/1_the_git_object_model.html#tree-object&#34;&gt;the tree&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;literal-block&#34;&gt;
160000 commit [hash]        .modules/nested
&lt;/pre&gt;
&lt;p&gt;I found this interesting because it re-enforces my feelings towards both
systems: I appreciate the simplicity and accessibility of Mercurial&#39;s
implementation, and I appreciate the intellectual stimulation I got from
learning about git&#39;s implementation.&lt;/p&gt;
&lt;p&gt;But I also believe that git&#39;s implementation is inferior in every practical
way.&lt;/p&gt;
&lt;p&gt;Because Mercurial&#39;s subrepo state is stored in plain text files which are
committed into the repository, any tool which is used to view/edit/exchange
a repository will trivially be able to handle subrepos. For example, changes to
subrepos can be trivially exchanged with standard &lt;tt class=&#34;docutils literal&#34;&gt;diff&lt;/tt&gt;/&lt;tt class=&#34;docutils literal&#34;&gt;patch&lt;/tt&gt; tools:&lt;/p&gt;
&lt;pre class=&#34;literal-block&#34;&gt;
$ hg diff -c bump_nested
diff --git a/.hgsubstate b/.hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
&amp;#64;&amp;#64; -1,1 +1,1 &amp;#64;&amp;#64;
-[... old hash ...] .subrepos/nested
+[... new hash ...] .subrepos/nested
&lt;/pre&gt;
&lt;p&gt;Versions pinned in subrepos can be easily changed with a text editor (for
example, to resolve merge conflicts), and tools which interact with Mercurial
repositories (for example, &lt;tt class=&#34;docutils literal&#34;&gt;hgweb&lt;/tt&gt;) will function correctly, even if they are
ignorant of subrepos.&lt;/p&gt;
&lt;p&gt;Contrast this with git&#39;s submodules, where submodule versions are “hidden” in
the tree, and &lt;em&gt;every&lt;/em&gt; tool must be aware of their existence. For example, it is
impossible to use standard &lt;tt class=&#34;docutils literal&#34;&gt;diff&lt;/tt&gt; and &lt;tt class=&#34;docutils literal&#34;&gt;patch&lt;/tt&gt; tools:&lt;/p&gt;
&lt;pre class=&#34;literal-block&#34;&gt;
$ git show bump_nested
...
diff --git a/.modules/nested b/.modules/nested
index f44396c..1fd6830 160000
--- a/.modules/nested
+++ b/.modules/nested
&amp;#64;&amp;#64; -1 +1 &amp;#64;&amp;#64;
-Subproject commit [... old hash ...]
+Subproject commit [... new hash ...]
&lt;/pre&gt;
&lt;p&gt;Instead, &lt;tt class=&#34;docutils literal&#34;&gt;git am&lt;/tt&gt; must be used. Any tool that interacts with a
submodule-enabled repository must be aware of submodues, otherwise &lt;a class=&#34;reference external&#34; href=&#34;http://www.google.ca/search?q=%22fatal%3A+bad+object%22+%2Bsubmodules&#34;&gt;it will
crash with “fatal: bad object”&lt;/a&gt; (ie,
because it likely assumes that any hash in the tree references a blob in the
repository, which is &lt;em&gt;not&lt;/em&gt; true in the case of a &lt;tt class=&#34;docutils literal&#34;&gt;commit&lt;/tt&gt; entry) and
submodule-specific commands must be learned and used to resolve submodule merge
conflicts &lt;a class=&#34;footnote-reference&#34; href=&#34;#id2&#34; id=&#34;id1&#34;&gt;[0]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All of these complications could be acceptable if they allowed git&#39;s submodules
to be somehow “better” than if a simpler scheme, like Mercurial&#39;s
&lt;tt class=&#34;docutils literal&#34;&gt;.hgsubstate&lt;/tt&gt; was used… But, as far as I can tell, this implementation
affords &lt;em&gt;no&lt;/em&gt; practical benefit.&lt;/p&gt;
&lt;table class=&#34;docutils footnote&#34; frame=&#34;void&#34; id=&#34;id2&#34; rules=&#34;none&#34;&gt;
&lt;colgroup&gt;&lt;col class=&#34;label&#34; /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign=&#34;top&#34;&gt;
&lt;tr&gt;&lt;td class=&#34;label&#34;&gt;&lt;a class=&#34;fn-backref&#34; href=&#34;#id1&#34;&gt;[0]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;p class=&#34;first&#34;&gt;hint: after a submodule merge conflict, &lt;tt class=&#34;docutils literal&#34;&gt;git submodule status&lt;/tt&gt; will show
all the revisions you might care about:&lt;/p&gt;
&lt;pre class=&#34;literal-block&#34;&gt;
$ git submodule status
-595c7a8dd110ab3f0f305bb0f3d6356ca5d62d99 nested
-cacb40625cc891b33c9c935442c0180e8ba5ab15 nested
-5e71d23bc5d24d18e026bcf12773f3fade1ac6b9 nested
&lt;/pre&gt;
&lt;p class=&#34;last&#34;&gt;And you&#39;ll need to remember that the first line is the common ancestor, the
second line “our” version, the third line is “their” version. To resolve
the conflict, the standard &lt;tt class=&#34;docutils literal&#34;&gt;git checkout &lt;span class=&#34;pre&#34;&gt;--{ours,theirs}&lt;/span&gt;&lt;/tt&gt; appears to do
nothing — you need to copy the hash of the desired revision, &lt;tt class=&#34;docutils literal&#34;&gt;cd nested;
git checkout $hash; cd ..&lt;/tt&gt;, then commit as normal.&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Poll results: how often do programmers interact with their version control system?</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2011/01/05/poll-results--how-often-do-programmers-interact-with-their-version-control-system-" />
    <id>http://blog.codekills.net/2011/01/05/poll-results--how-often-do-programmers-interact-with-their-version-control-system-</id>
    <updated>2011-01-06T01:12:00Z</updated>
    <published>2011-01-06T01:12:00Z</published>
    <category scheme="http://blog.codekills.net" term="Version control" />
    <summary type="html">Poll results: how often do programmers interact with their version control system?</summary>
    <content type="html" xml:base="http://blog.codekills.net/2011/01/05/poll-results--how-often-do-programmers-interact-with-their-version-control-system-">

&lt;p&gt;Out of curiosity, I polled Twitter, asking how often they interact with their version control systems. These are the responses I got, along with (my guess at) the version control system they use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;5 - 10 times a day. (?)&lt;/li&gt;
&lt;li&gt;Lots of ‘working directory diff’, then a bit less for ‘commit’ and a lot less for ‘push’. (dvcs)&lt;/li&gt;
&lt;li&gt;Not nearly as much as I should. (git)&lt;/li&gt;
&lt;li&gt;Every few hours lately I wake up from some code daydreaming and do a diff to see how much has gone on, then &#34;hg record&#34; a few times. (hg)&lt;/li&gt;
&lt;li&gt;When I have something that represents a &#34;single&#34; change; could be anywhere from two minutes/one line to afternoon/minor new module. Diff and revert are also minor but nontrivial contributors to VCS interaction while coding. Those happen approximately randomly. (git, cvs)&lt;/li&gt;
&lt;li&gt;When I want to switch contexts (different branch or project), or when things are reasonably functional and I want to break things. In practice, about 2-8 times per full work session. (git)&lt;/li&gt;
&lt;li&gt;Trying to do it much, much more. (?)&lt;/li&gt;
&lt;li&gt;Depends on the team and VCS. Ideally, if I&#39;m using a DVCS and coding heavily, probably hourly... But right now at work, since I&#39;m dealing with a centralized P4 and a kludgy dev toolset, probably once a day. (dvcs, p4)&lt;/li&gt;
&lt;li&gt;Often: I branch like a madman, commit when I am satisfied, and push/merge when i am complete. (git)&lt;/li&gt;
&lt;li&gt;Every 10-15 minutes, typically. (git)&lt;/li&gt;
&lt;li&gt;Usually one to three times a day. Should be more, but I don&#39;t do enough TDD these days, so commits are larger. (?)&lt;/li&gt;
&lt;li&gt;I commit approximately hourly and diff/stat about as often. Revert once a day. (hg)&lt;/li&gt;
&lt;li&gt;Very frequently. (hg)&lt;/li&gt;
&lt;li&gt;Usually once a day, when I&#39;m done with my tasks and all tests pass. But I&#39;m the only one touching the code so I never have to update or merge. (?)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And my answer would be &#34;every 15-30 minutes&#34;.&lt;/p&gt;
&lt;p&gt;Anyway, that&#39;s all. Thanks to everyone who replied; I found the results interesting.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">DVCSs and Changeset Numbering</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2010/01/29/dvcss-and-changeset-numbering" />
    <id>http://blog.codekills.net/2010/01/29/dvcss-and-changeset-numbering</id>
    <updated>2010-01-29T22:30:00Z</updated>
    <published>2010-01-29T22:30:00Z</published>
    <category scheme="http://blog.codekills.net" term="Version control" />
    <summary type="html">DVCSs and Changeset Numbering</summary>
    <content type="html" xml:base="http://blog.codekills.net/2010/01/29/dvcss-and-changeset-numbering">

&lt;p&gt;One of my big beefs with DVCSs is their version numbers.&lt;/p&gt;
&lt;p&gt;For example, take two changesets I committed today: 6899 and 02a9. Which one is more recent? How many changesets separate them? Without access to a repository, there&#39;s no way to tell… But that sort of information can be useful to have.&lt;/p&gt;
&lt;p&gt;Two of the three DVCSs I have experience with, &lt;code&gt;bzr&lt;/code&gt; and &lt;code&gt;hg&lt;/code&gt;, both take steps towards solving this problem.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;bzr&lt;/code&gt; tries &#34;really hard&#34; to give everything a sequential ID, and uses those IDs in the UI (as far as I can tell) all the time (it does use unique hashes under the hood, but they aren&#39;t shown very much):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ bzr log
------------------------------------------------------------
revno: 3
message:
  A merge
    ------------------------------------------------------------
    revno: 1.1.1
    message:
      A conflicting change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;hg&lt;/code&gt; assigns local aliases for each changeset, and displays those aliases along with hashes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ hg log -r 4:6
changeset:   4:658109dca65b
description:
A merge

changeset:   5:bd8053bf02f1
description:
A conflicting change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And, of course, &lt;code&gt;git&lt;/code&gt; doesn&#39;t stand for this sort of frivolity and shows pure, unadulterated, hashes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git log
commit aa55884d693c92da6dc96eb7a45c9ecd774fefc2

    A merge

commit 8e47937468071ae29d385b76ff925d231c65b97b

    A conflicting change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I&#39;d like to see this taken a step further, though: I&#39;d like the changeset hashes themselves to encode some basic information about where they live in the repository.&lt;/p&gt;
&lt;p&gt;For example, one way to do this could be using the first two bytes of the hash to store the distance from the root*, and the next two bytes to store a &#34;repository id&#34;, which is generated once, when a repository is first cloned or initialized.&lt;/p&gt;
&lt;p&gt;So, for example, one of these changeset hashes might look like this: &lt;tt&gt;&lt;strong&gt;0afc&lt;/strong&gt;53bf02f1&lt;/tt&gt;, and committing again to the same repository would produce &lt;tt&gt;&lt;strong&gt;0bfc&lt;/strong&gt;109dca65&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Of course, this scheme doesn&#39;t guarantee anything - it&#39;s entirely possible to generate two completely different changesets with the exact same four-byte prefix… But in the general case, this sort of scheme could make it significantly easier to figure out how arbitrary changesets relate to one another.&lt;/p&gt;
&lt;p&gt;&lt;small&gt;*: &lt;a href=&#34;http://twitter.com/dgou&#34;&gt;Doug Philips&lt;/a&gt; suggested this - thanks.&lt;/small&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Using git for Backup is Asking for Pain</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2009/12/08/using-git-for-backup-is-asking-for-pain" />
    <id>http://blog.codekills.net/2009/12/08/using-git-for-backup-is-asking-for-pain</id>
    <updated>2009-12-08T18:10:00Z</updated>
    <published>2009-12-08T18:10:00Z</published>
    <category scheme="http://blog.codekills.net" term="Version control" />
    <summary type="html">Using git for Backup is Asking for Pain</summary>
    <content type="html" xml:base="http://blog.codekills.net/2009/12/08/using-git-for-backup-is-asking-for-pain">

&lt;p&gt;git isn&#39;t a backup system.&lt;/p&gt;
&lt;p&gt;Neither is Mercurial, Bazaar, Subversion or even (&lt;em&gt;even&lt;/em&gt;) CVS &lt;del&gt;CSV&lt;/del&gt;.&lt;/p&gt;
&lt;p&gt;Version control systems, with the possible exception of SourceSafe, are great at keeping track of code. Why is that? Because they were &lt;strong&gt;designed to keep track of code&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately, though, the features of a good VCS are &lt;strong&gt;entirely different&lt;/strong&gt; – and often &lt;strong&gt;exactly the opposite&lt;/strong&gt; – of the features which make a good backup system.&lt;/p&gt;
&lt;p&gt;Take, for example, &lt;strong&gt;file ownership&lt;/strong&gt;. A good VCS will, very rightly, &lt;strong&gt;ignore file ownership&lt;/strong&gt;: when I check out someone else&#39;s code, I should be the owner of those file - not whatever &lt;code&gt;uid&lt;/code&gt; originally created them. A good backup system, on the other hand, will do &lt;strong&gt;everything in its power to preserve file ownership&lt;/strong&gt;: when I restore from my backups, I want &lt;code&gt;/etc/shaddow&lt;/code&gt; to be owned by &lt;code&gt;root&lt;/code&gt; and &lt;code&gt;/home/wolever/&lt;/code&gt; to be owned by &lt;code&gt;wolever&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;And ownership is just one example - permissions†, creation and modification times, empty directories‡, hardlinks, xattrs, resource forks, … the list of details that a backup system must keep track of goes on and on.&lt;/p&gt;
&lt;p&gt;In fact, there are so many things a backup system can get wrong, there is a project called &lt;a href=&#34;http://www.n8gray.org/code/backup-bouncer/&#34;&gt;Backup Bouncer&lt;/a&gt;, designed specifically to verify that backup scripts correctly copy all the various bits of metadata tracked by the filesystem.&lt;/p&gt;
&lt;p&gt;So, please: if you value your bytes, use a real backup system, not git.&lt;/p&gt;
&lt;p&gt;†: Most VCSs only track the &#39;x&#39; bit - for backup purposes, all bits, including suid bits, must be tracked.&lt;br /&gt;
‡: fun fact - Mercurial and git don&#39;t track empty directories, but Bazaar does.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Why I Don&#39;t Like git</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2008/08/27/why-i-don't-like-git" />
    <id>http://blog.codekills.net/2008/08/27/why-i-don't-like-git</id>
    <updated>2008-08-27T13:59:00Z</updated>
    <published>2008-08-27T13:59:00Z</published>
    <category scheme="http://blog.codekills.net" term="Version control" />
    <summary type="html">Why I Don&#39;t Like git</summary>
    <content type="html" xml:base="http://blog.codekills.net/2008/08/27/why-i-don't-like-git">

&lt;p&gt;I&#39;ve got some code checked out with git-svn, and I&#39;d like to do two things: pull in new revisions and push up my local revisions.  Pretty simple, brainless, thing, right?  But we&#39;re dealing with git, so of course not &lt;img src=&#34;/templates/default/img/emoticons/smile.png&#34; alt=&#34;:-)&#34; style=&#34;display: inline; vertical-align: bottom;&#34; class=&#34;emoticon&#34; /&gt;
&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;strong&gt;# Fortunately I&#39;m smart enough to remember that when you
# want to push changes to SVN, you&#39;ve obviously got to use: &lt;/strong&gt;
$ &lt;strong&gt;git-svn dcommit&lt;/strong&gt;
...
$
&lt;strong&gt;# Hurra! It worked! (at least I think...)
# Now for the next feat, pulling in more revisions...&lt;/strong&gt;
$ &lt;strong&gt;git svn&lt;/strong&gt;
...
  fetch            Download new revisions from SVN
...
&lt;strong&gt;# Phew! That looks like exactly what I need... Maybe it&#39;s not so tricky after all!&lt;/strong&gt;
$ git svn fetch
        A       basie/a3c/admin.py
r13 = 45f5309121a77f33f8bd87009671727c0e2dc4a5 (zuze)
&lt;strong&gt;# Sweet! Now I can take a look at what has been changed&lt;/strong&gt;
$ &lt;strong&gt;cat basie/a3c/admin.py&lt;/strong&gt;
cat: basie/a3c/admin.py: No such file or directory
&lt;strong&gt;# Hu? I thought I just fetched it...
# Crap, right! I&#39;m NOT supposed to use fetch, I&#39;m supposed to use &#39;rebase&#39;
# (not, of course, that I understand why &#34;pulling in new revisions from SVN
#  is equivilent to a mung-your-history-rebase... But that&#39;s ok, I guess)&lt;/strong&gt;
$ &lt;strong&gt;git svn rebase&lt;/strong&gt;
...
$ &lt;strong&gt;cat basie/a3c/admin.py&lt;/strong&gt;
cat: basie/a3c/admin.py: No such file or directory
&lt;strong&gt;# Blast.  That didn&#39;t work either.
# Right, that&#39;s because &#39;fetch&#39; updates the git repository but not the
# working tree... Alright, let&#39;s try an update&lt;/strong&gt;
$ &lt;strong&gt;git up&lt;/strong&gt;
git: &#39;up&#39; is not a git-command. See &#39;git --help&#39;.
&lt;strong&gt;# Crap, right, git is too cool to have &#39;update&#39;... I think I need reset&lt;/strong&gt;
$ &lt;strong&gt;git reset&lt;/strong&gt;
docs/cmdline.wiki: needs update
&lt;strong&gt;# hhmm... Why is it telling me that the files I edited need update?
# And how on earth do I update them?
# I give up &lt;img src=&#34;/templates/default/img/emoticons/sad.png&#34; alt=&#34;:-(&#34; style=&#34;display: inline; vertical-align: bottom;&#34; class=&#34;emoticon&#34; /&gt; Can someone smarter than I am tell me what to do?&lt;/strong&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I guess I&#39;ll go back to Bazaar... It may be slow as molasses on a cold day, but at least it is simple enough that mere mortals can use it without resorting to Google.&lt;/p&gt;
</content>
  </entry>
</feed>

