Microsoft made a big move recently by supporting Mercurial on Codeplex. The company I was working for in 2009 was contemplating moving to a DVCS (Distributed Version Control System) and had we made the move, we would have gone to Mercurial. So I’ve been using Mercurial off and on for the last 8 months and have been pleased with the ease of use and the clean command set.
If you are just starting with Mercurial here are some basic commands that will get you going. For the sake of this article, I’m going to use Orchard as the example repository.
-Orchard source url: https://hg01.codeplex.com/orchard
-Clone repository: hg clone https://hg01.codeplex.com/orchard
-Clone repository (named working directory): hg clone https://hg01.codeplex.com/orchard my_dir
-Pull source from remote: hg pull -u
**Note: ‘-u’ is important since it updates your local working copy after pulling the latest
-Local commit: hg ci -m “some message”
**Note: Remember that you are committing to you local repository, you still need to ‘push’ to your remote repository.
-Push commits to remote: hg push
**Note: this command will likely request your credentials
-Check status of local files: hg status
-View the commit log: hg log
-View the most recent commit: hg tip
If you prefer to use visual tools then just type ‘hgtk’ at your command line and you will see all of the commands that will launch visual Mercurial tools. The following is an example for the visual log.
-View visual log of commits: hgtk log
If you have been using git or bazaar, then switching to Mercurial should be trivial.
What I’ve shown here is just the very beginning set of commands for Mercurial. If you want to dig deeper, then you’ll want to read the Hg Book.
A couple of weeks ago I was writing some code to initialize List<T> but my technique was very verbose and it seemed to be a distraction from what I was trying to do. Plus it seemed that every one else was writing about getting their func on.
So I looked back at some code that Nick Parker had written:
And tweaked it to initialize a list:
Now I can initialize a list like this:
Just for the record the Func initialization above could handle much more complex scenarios if needed. My usage is very simple.
Another variation on this is to create an extension method that does the same initialization like this:
And here is how you would use the extension method version:
Thanks to Nick Parker for some suggestions as I was working on this.
Something I would like to figure out is how to do this based on IEnumerable instead of IList. If you have ideas regarding implementing this on IEnumerable please add them as comments.
Also, if you want to see where I was using this, pull down the subversion source here: http://subversion.assembla.com/svn/solon-tools/trunk/Puzzles
I’ve almost learned Python several times in the recent past, but now I’m committing to learn it. Some of my learning resources are The Python Tutorial and Dive Into Python. What are other good online resources?
AUTHOR LAST MODIFIED DESCRIPTION
v-someone 2008-08-21 Initial Version
It’s official, we are at the end of 2008 and there are lots of good source control tools out there(some of the best are free).
You don’t need to keep putting change history comments in your source if you are using source control. If you add comments when you commit your code this will be handled for you.
Later Saturday night the Hawkeyes beat the Gophers 55-0, even better it was on the Gophers home turf in the Metrodome.
Saturday was a good day for football teams from Johnson County.
From my experience when people talk about IOC/DI they end up skipping basic concepts, but Jeff didn’t. It was really good because he went back to the very beginning and built a live code example along the way. And as he built the code base, he introduced all the core concepts.
I learned a lot and think I’ll introduce Unity into my current project. Structure Map has been on my list to learn for awhile, so I’ll probably use it to compare for usability and features.