<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2524678972955021559</id><updated>2011-12-03T19:40:00.774-08:00</updated><category term='C#'/><category term='PowerShell'/><category term='Backup'/><category term='Version Control'/><category term='TFS'/><category term='extension methods'/><title type='text'>Jay Bazuzi's coding blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jbazuzicode.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jbazuzicode.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jay Bazuzi</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2524678972955021559.post-7963843155643085730</id><published>2010-06-16T00:02:00.000-07:00</published><updated>2010-06-16T11:14:45.950-07:00</updated><title type='text'>Single-line blocks: A radical view</title><content type='html'>For a long time I've been a staunch advocate of using braces around single-line blocks in C-like languages:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// OK&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (foo)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 1;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Bad&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (foo)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 1;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
The obvious reason is to protect against this kind of bug:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// very Bad&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (foo)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Debug.WriteLine("returning 1"); // added later&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 1;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There's actually a bug in Visual Studio that we shipped because of this kind of mistake. If memory serves, it was in VS 2002. The repro:&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Start debugging.&lt;/li&gt;
&lt;li&gt;Open the watch window&lt;/li&gt;
&lt;li&gt;Make a Remote Desktop connection to the session running the debugger&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Result:&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The font in the watch window changes to the system font (big &amp;amp; ugly).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
The problem here was a bit of code in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DllMain&lt;/span&gt;&amp;nbsp;of a debugger DLL where a single-line block didn't have braces, and then another line was added later. Turns out&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DllMain&lt;/span&gt;&amp;nbsp;gets called when connecting in a RDP session. The Watch Window font gets deleted&amp;nbsp;prematurely. This was in the early days of Terminal Sevices / RDP, so it took us a little while to get cluefull (opposite of clueless!).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It would have helped if we auto-formatted our code, but we didn't like what the C++ auto-formatter did by default, so we didn't run it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Since then, I have argued that all single-line blocks must have braces, to prevent this kind of bug.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Later I started reading about Extreme Progamming, and their radical views on simplicity. I decided that simple, single-line blocks are a nice goal, because they mean your code is simple. So, I now have an exception to my rule. A single-line block can skip the braces if 1) it is on the same line as the if/for/whatever statement, and 2) the whole line is short. Also, I consider this state of affairs is particularly desirable.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
So:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Good&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (foo) return 1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if (bar) return 2;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else return 0;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2524678972955021559-7963843155643085730?l=jbazuzicode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbazuzicode.blogspot.com/feeds/7963843155643085730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2524678972955021559&amp;postID=7963843155643085730' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/7963843155643085730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/7963843155643085730'/><link rel='alternate' type='text/html' href='http://jbazuzicode.blogspot.com/2010/06/single-line-blocks-radical-view.html' title='Single-line blocks: A radical view'/><author><name>Jay Bazuzi</name><uri>http://www.blogger.com/profile/05292487295338684699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2524678972955021559.post-5434092993495180115</id><published>2009-01-06T11:39:00.000-08:00</published><updated>2009-01-06T12:39:55.728-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='extension methods'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>A way to manage extension methods in C#</title><content type='html'>I like C#'s extension methods, but I'm concerned about "polluting the namespace".  &lt;a id="w4y0" href="http://www.google.com/search?rlz=1C1GGLS_enUS291US305&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8&amp;amp;q=extension+methods+suck" title="I'm not the only one" style="color: rgb(85, 26, 139)"&gt;I'm not the only one&lt;/a&gt;.  I'm especially concerned about extensions to "&lt;span style="font-family: 'Courier New';"&gt;object&lt;/span&gt;", as they appear &lt;b&gt;everywhere&lt;/b&gt;. They can be useful, but wow that's a big impact.  How to make valuable, wide-reaching extension methods possible without affecting lots of code that doesn't need the extension?
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;I've come up with an approach that helps me be picky about which extension methods are available in which contexts.  That helps me manage how much pollution I am willing to accept.  It is also means that most of the extension methods available in a given context are the ones that are relevant to the code I'm trying to write in that context.&lt;/div&gt;
&lt;h2&gt;&lt;font size="4"&gt;Example:&lt;/font&gt;&lt;/h2&gt;
&lt;pre&gt;namespace MyProject.Extensions.TypeExtensions
{
    static class _
    {
        public static bool DerivesFrom(this Type type, Type baseType)
        {
            while (type != null)
            {
                if (type.BaseType == baseType)
                {
                    return true;
                }

                type = type.BaseType;
            }

            return false;
        }
    }
}
&lt;/pre&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;Which is normally used like this:&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
&lt;pre&gt;    using Extensions.TypeExtensions;

    var typesDerivedFromFoo = from type in typeof(foo).Assembly.GetTypes()
                              where type.DerivesFrom(typeof(Foo))
                              select type;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;span style="font-family: 'Courier New'"&gt;    &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;b&gt;&lt;font size="4"&gt;Consequences&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;* That this approach works best if &lt;b&gt;files are small&lt;/b&gt;, which means that my classes need to be small, too.  If all your code is in a few files, there's no point to my method.&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;* All my extension methods are in the &lt;span style="font-family: 'Courier New'"&gt;Extensions&lt;/span&gt; namespace.&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
* It's not friendly in &lt;b&gt;languages that don't have extension methods&lt;/b&gt;.  (You have to use the full name of the extension type):&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"&gt;&lt;span style="font-family: 'Courier New'"&gt;Extensions.TypeExtensions._.DerivesFrom(type, baseType)&lt;/span&gt;&lt;br&gt;
&lt;/blockquote&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
This isn't beautiful, but let's compare it to what you'd write if you didn't use extension methods at all:&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; "&gt;TypeExtensions.DerivesFrom(type, baseType)&lt;/span&gt;&lt;br&gt;
&lt;/blockquote&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;br&gt;
There is only an extra "_." and an extra "Extensions.", which isn't that much.&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;&lt;br&gt;
* My approach prevents you from using these methods as if they weren't extension methods, the way we did before:&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; "&gt;using Extensions.TypeExtensions;&lt;/span&gt;&lt;br&gt;
&lt;span style="font-family: 'Courier New'"&gt;_.&lt;/span&gt;&lt;span style="font-family: 'Courier New'"&gt;DerivesFrom&lt;/span&gt;&lt;span style="font-family: 'Courier New'"&gt;(type, baseType);&lt;/span&gt;&lt;br&gt;
&lt;/blockquote&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;
&lt;br&gt;
Because "&lt;span style="font-family: 'Courier New'"&gt;_.&lt;/span&gt;" is ambiguous as soon as you bring in more than one extension.&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;* While C# requires that extension methods be defined in a class, the language doesn't care what the name of the class is.  My approach reflects that, by giving the class a "nothing" name (and using the containing namespace as the visible name).&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;div style="margin-top: 0px; margin-bottom: 0px"&gt;* The word "Extensions" appears twice in the namespace name, which is repetitive, redundant, says something that was already said.  I'd rather call it "&lt;span style="font-family: 'Courier New'"&gt;Extensions.Type&lt;/span&gt;", but that means that the name of type I'm extending ("&lt;span style="font-family: 'Courier New'"&gt;Type&lt;/span&gt;") isn't available - I have to say "&lt;span style="font-family: 'Courier New'"&gt;System.Type&lt;/span&gt;".  Maybe that's a better choice.&lt;/div&gt;

&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2524678972955021559-5434092993495180115?l=jbazuzicode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbazuzicode.blogspot.com/feeds/5434092993495180115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2524678972955021559&amp;postID=5434092993495180115' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/5434092993495180115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/5434092993495180115'/><link rel='alternate' type='text/html' href='http://jbazuzicode.blogspot.com/2009/01/way-to-manage-extension-methods-in-c.html' title='A way to manage extension methods in C#'/><author><name>Jay Bazuzi</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2524678972955021559.post-7347867508010809348</id><published>2008-11-11T12:04:00.001-08:00</published><updated>2008-11-11T20:27:18.498-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Version Control'/><title type='text'>Version control that scales down: Mercurial</title><content type='html'>&lt;DIV&gt;Version control that scales down: Mercurial&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;When working on a small software project for myself, I still want version control, but I don't want the overhead of, say, TFS. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;I decided to give &lt;A id=deb1 title=Mercurial href="http://www.selenic.com/mercurial/"&gt;Mercurial&lt;/A&gt; a try, and it seems to scale down very well.&amp;nbsp; Here's what I have done: &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;A id=kcr: title="Install TortioseHG" href="http://www.selenic.com/mercurial/wiki/index.cgi/TortoiseHg"&gt;Install TortioseHG&lt;/A&gt; 
&lt;LI&gt;
&lt;DIV&gt;Open a PowerShell Prompt &lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;Go to the directory that contains my source &lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;hg init&lt;/FONT&gt; # create a new "repository" &lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;hg addremove&lt;/FONT&gt; # add all files in the current directory &lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;hg revert&lt;/FONT&gt; # avoid adding files you don't want &lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;hg commit&lt;/FONT&gt; &lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;A good idea is to create a .hgignore file to tell it what files you don't want to add, if there are some.&amp;nbsp; For a small C#/NUnit project, mine looks like this right now: &lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;syntax:glob&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;*.suo&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;*.user&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;bin\&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;obj\&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;TestResult.xml&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NUnit.VisualState.xml&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;Then, to add this file, do &lt;FONT face="Courier New"&gt;hg addremove&lt;/FONT&gt;, then &lt;FONT face="Courier New"&gt;hg commit&lt;/FONT&gt;. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;Then, you just edit your files as needed.&amp;nbsp; When you're ready to commit, you do &lt;FONT face="Courier New"&gt;hg addremove&lt;/FONT&gt;, &lt;FONT face="Courier New"&gt;hg commit&lt;/FONT&gt;. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;I don't have to worry about keeping my filesystem and my project in sync with my source control.&amp;nbsp; It just does it. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;In another directory I have some PowerShell scripts.&amp;nbsp; Since I already had Mercurial installed, it was easy: &lt;FONT face="Courier New"&gt;hg init, hg addremove, hg commit&lt;/FONT&gt;.&amp;nbsp; Tada, it's under version control.&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;Things I like about Mercurial: &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;No server setup &lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;No need to decide where on the server your files should live &lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;No need to "check out" a file before you can edit it - adding version control doesn't interrupt your existing workflow. &lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Works offline just as well as online &lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;Mercurial has a lot more power if you want to scale up, with&amp;nbsp;rich branching &amp;amp; merging.&amp;nbsp; You can create a branch for an experiment or a 1-off bug fix release, all offline.&amp;nbsp; That's cool, but right now that's not important for me: I really just want to track my changes. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;The main thing I wish for, and it's pretty minor, is PowerShell cmdlets.&amp;nbsp; They're really nice to work with.&amp;nbsp; I don't expect them to appear any time soon. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;People often look to version control software to provide backups of their source code.&amp;nbsp; I only have Mercurial on one machine right now, and standard guidance says I should put the small Mercurial server on another machine (my Windows Home Server seems like a good choice), and "push" my changes on to it regularly.&amp;nbsp; I'm not doing that, because my changes are backed up in other ways: &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV&gt;The directory that contains all my source code projects is in a Windows Live Mesh folder.&amp;nbsp; That means it's backed up, even the full history, unless I accidentally delete the whole thing.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;Every night my computer is backed up to my Windows Home Server.&amp;nbsp; Even if I delete by accident, I won't lose much.&lt;/LI&gt;&lt;/UL&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I'm not sure how well mesh &amp;amp; Mercurial will get along.&amp;nbsp; If I sit make edits on computer A, and Mesh syncs to computer B, I could commit from B, and that will get synced back to A.&amp;nbsp; That isn't what Mercurial is intended to do, but I can't think of a reason it wouldn't work.&amp;nbsp; The idea of being able to go computer hopping without having to first commit, push or pull, merge, commit each time seems attractive.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2524678972955021559-7347867508010809348?l=jbazuzicode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbazuzicode.blogspot.com/feeds/7347867508010809348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2524678972955021559&amp;postID=7347867508010809348' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/7347867508010809348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/7347867508010809348'/><link rel='alternate' type='text/html' href='http://jbazuzicode.blogspot.com/2008/11/version-control-that-scales-down.html' title='Version control that scales down: Mercurial'/><author><name>Jay Bazuzi</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2524678972955021559.post-4959763675371104405</id><published>2008-11-11T07:34:00.000-08:00</published><updated>2008-11-11T08:34:36.514-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Version Control'/><category scheme='http://www.blogger.com/atom/ns#' term='TFS'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='Backup'/><title type='text'>Backup up your pending changes (TFS)</title><content type='html'>More than once I have destroyed my data by accident. I've certainly lost more data this way than any other.

Version control is great for a lot of reasons; having a backup is just one of them. But if I have changes that aren't checked in, they are at risk.

When I was working with TFS for version control, I wrote this PowerShell script to back up all my changes to shelvesets. TFS has the ability to enumerate all workspaces, so it's easy: you just run it once and it will back them all up. The shelveset names begin with "ZZZ" to sort them to the end of the shelveset list.

It makes sense to run this as a nightly scheduled task.

The script is also interesting as an example of how to manipulate TFS from PowerShell, via the TFS APIs, instead of trying to parse textual output:
&lt;blockquote&gt;
&lt;pre&gt;[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")

$localWorkspaceInfos = [Microsoft.TeamFoundation.VersionControl.Client.Workstation]::Current.GetAllLocalWorkspaceInfo() | where { $_.Computer -eq $env:COMPUTERNAME }

"Found {0} workspaces to back up" -f $localWorkspaceInfos.Count | Write-Verbose&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Download:
&lt;a href="http://www.box.net/lite/606kqtufyx"&gt;&lt;img src="http://www.box.net/lite/image/606kqtufyx.png" border="0" /&gt;&lt;/a&gt;


&lt;p&gt;Warning: it has been a year+ since I last ran this script, and I don't have access to TFS these days to test it. I think it works, but YMMV.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2524678972955021559-4959763675371104405?l=jbazuzicode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbazuzicode.blogspot.com/feeds/4959763675371104405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2524678972955021559&amp;postID=4959763675371104405' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/4959763675371104405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2524678972955021559/posts/default/4959763675371104405'/><link rel='alternate' type='text/html' href='http://jbazuzicode.blogspot.com/2008/11/backup-up-your-pending-changes-tfs.html' title='Backup up your pending changes (TFS)'/><author><name>Jay Bazuzi</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
