Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, December 15

topgit Means Never Having to Wait for Reviews

I’ve been using git for a little while now at work. Some rather clever Googlers have rigged up a tool that syncs a local repository with Perforce, so I can do local development and version control with git and then check the final CL in to the depot.

Over the weekend I started using topgit (README), a git wrapper that takes most of the work out of managing dependent “topic branches.” The gist is that you mark branches as depending on one another. Then, when you modify a branch, you can use the tg update command to propagate those changes to any branches that depend on it.

I’ve been doing a lot of large changes and refactorings recently, so what topgit really means for me is never having to wait for code reviews to keep working.

The basic workflow goes like this:

“refactor” is the name of my new branch, “blogger” is the trunk
$ tg create refactor blogger
hack hack hack
mv mv mv
add add add
commit commit commit


now mail out the CL for review
$ gitwrapper mail -m reviewer

In a pure Perforce environment, I couldn’t continue working on this code at all until the review came back and I could submit. With vanilla git, I can of course git checkout -b new-branch and keep going, and this is fine most of the time.

Where it starts to get sticky is when my reviewer has comments. No big deal, though. I can just git checkout back to the refactor branch, make those changes, and commit them.

Of course, I now need to update my new-branch so that I’m working from the latest intermediate state. git merge refactor handles that fairly well (sometimes I get pedantic and use git rebase) and I’m back to coding the new feature.

topgit supports exactly this pattern of development by automating the “update the new-branch” step. If I created the new-branch branch with tg create, then I could run tg update to merge in the latest versions of all of new-branch’s dependencies.

To continue, we have:

git checkout refactor
tweak tweak tweak
git commit -am "fixes from review"
git checkout new-branch
tg update
code code code

“All” is a very operative word in that last sentence. With topgit, a branch can have several dependencies, forming a DAG, and it will recursively update each one of them. This means that I can have several independent changes, with each out for review in parallel, but continue development on a new change that relies on all of them.

topgit works by keeping a separate reference branch for each topgit-managed branch. When you run tg update, it merges the dependencies into this branch, then merges that into the normal branch. This gives the added benefit that you can easily git rebase against the reference branch to clean up your commit graph.

Saturday, July 5

Markov and Garkov


Jeff Atwood at Coding Horror wrote a good introductory post to Markov chains, with a link to Garkov, a Garfield comic generator that uses them.



I think that the humor in Garkov is probably the same as could be achieved by just putting random captions from other strips together, however. For something truly generated-awesome, see Atwood’s example Paul Graham essay:

You can feel the need to take advantage of increased cheapness, however. You're not all playing a zero-sum game. There's not some fixed number of startups; we fund startups we fund to work on matters of passing importance. But I'm uncomfortably aware that this is part of any illusions about the problem of overeating by stopping eating. I couldn't simply avoid the Internet had become, because the company is the new trend of worrying obsessively about what it meant for someone, usually an outsider, who deliberately stirred up fights in a startup than just start it. You know how the A List is selected. And even that is more work.

I tried running the last 100 Blogger known issues through the online Markov generator. I don’t think there’s quite enough diversity, though, as I recognize a lot of full sentences, but here are some random Blogger problems:


  • Some users are experiencing problems with the new version of Blogger in draft users are experiencing problems with FTP publishing that may affect image upload do not have "www" at the very bottom in the Blogger edit post form to upload one photo at a time or shrink photos larger.

  • Some users have been affected by this bug. If a blog or post, regardless of how many total comments the blog reviewed and the iGoogle gadget. Update, 1/28: This has been.

  • Some users report that they can be moderated. Comment feeds should now show the earliest comments. A temporary workaround is to click on the fix, one quick recommendation would be to clear your browser's cache and cookies and then go to.

  • Some users may be able to set your blog's language. Readers with Internet Explorer security settings set to a FeedBurner feed. The workaround is to exit Picasa.


Once you’ve had enough fun with Markov chains, move on to the Metropolis algorithm to generate samples based on a distribution that you can’t sample directly.