<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>merill.net &#187; sharpsvn</title>
	<atom:link href="http://merill.net/tag/sharpsvn/feed/" rel="self" type="application/rss+xml" />
	<link>http://merill.net</link>
	<description>my utmost for His highest, my best for His glory</description>
	<lastBuildDate>Fri, 20 Apr 2012 21:31:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SharpSvn: A Primer</title>
		<link>http://merill.net/2010/03/sharpsvn-a-primer/</link>
		<comments>http://merill.net/2010/03/sharpsvn-a-primer/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 00:03:14 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[sharpsvn]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tortoisesvn]]></category>

		<guid isPermaLink="false">http://merill.net/2010/03/sharpsvn-a-primer/</guid>
		<description><![CDATA[The SharpSvn library basically gives you a .NET interface to all the operations that you would normally perform through a tool like TortoiseSVN. I found myself needing this exact library while writing a tool that changes files that have been checked out from SVN. The problem with manipulating files that are under SVN is that [...]]]></description>
			<content:encoded><![CDATA[<p>The SharpSvn library basically gives you a .NET interface to all the operations that you would normally perform through a tool like TortoiseSVN.</p>
<p>I found myself needing this exact library while writing a tool that changes files that have been checked out from SVN. </p>
<p>The problem with manipulating files that are under SVN is that you need to be careful about renaming files (and sometimes even deleting). If you don’t do it through the SVN api then you will end up with duplicates files/folders in SVN since SVN thinks that it’s a new file.</p>
<p>To solve this I finally got a chance to crack open the SharpSVN library which is used by my favourite AnkhSVN.</p>
<p>1. Download the latest library from <a href="http://sharpsvn.open.collab.net/">http://sharpsvn.open.collab.net/</a>. You have to pick between either 1.5 or 1.6. I went with 1.6 and didn’t run into any issues. I think this is based on the version of the SVN server that your connecting to.</p>
<p>2. In your Visual Studio project add a reference to the following assemblies.    <br />- SharpSvn.dll     <br />- SharpSvn.UI.dll (Only needed if you need the UI to prompt for login)</p>
<p>3. If like me your building on a 64 bit OS and you want your app to run on a 32 bit OS, make sure the project that references the SharpSvn.dll is set to Build for the x86 Platform. (Build –&gt; Configuration Manager – Solution Platform)</p>
<p>4. Write your code using the SvnClient object. Here are some samples from the SharpSvn Wiki and some that I wrote.</p>
<p><strong>CheckOut</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> CheckOut()
{
  <span class="kwrd">using</span> (SvnClient client = <span class="kwrd">new</span> SvnClient())
  {
     client.CheckOut(
       <span class="kwrd">new</span> Uri(<span class="str">&quot;http://svn.collab.net/repos/svn/trunk/contrib&quot;</span>),
       <span class="str">@&quot;c:\wc&quot;</span>);
  }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Add new files to the working copy</p>
<pre class="csharpcode"><span class="kwrd">using</span>(SvnClient client = <span class="kwrd">new</span> SvnClient())
{
  SvnAddArgs args = <span class="kwrd">new</span> SvnAddArgs();
  <span class="rem">// TODO: Set optional settings on args</span>

  client.Add(<span class="str">@&quot;C:\file\in\workingcopy&quot;</span>, args);
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>Check if a given path is a valid SVN working copy</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsWorkingCopy(<span class="kwrd">string</span> path)
{
    <span class="kwrd">using</span> (var client = GetSvnClient())
    {
        var uri = client.GetUriFromWorkingCopy(path);

        <span class="kwrd">return</span> uri != <span class="kwrd">null</span>;
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>Find out if a particular folder/file has been marked for deletion.</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsDeleted(<span class="kwrd">string</span> path)
{
    <span class="kwrd">if</span>(!IsWorkingCopy(path)) <span class="kwrd">return</span> <span class="kwrd">false</span>;

    <span class="kwrd">bool</span> isDeleted;
    <span class="kwrd">using</span> (var client = GetSvnClient())
    {
        Collection&lt;SvnStatusEventArgs&gt; args;
        client.GetStatus(path, <span class="kwrd">out</span> args);
        isDeleted = args.Count &gt; 0 &amp;&amp; args[0].LocalContentStatus == SvnStatus.Deleted;
    }
    <span class="kwrd">return</span> isDeleted;
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<div>&#160;</div>
<div>What’s even more awesome about the guys who wrote this library actively support it (even over twitter, thanks <a href="http://twitter.com/srijken">http://twitter.com/srijken</a>!).</div>
<div>&#160;</div>
<div>And that was even before I found out that they have a ready made .wxs file for integrating the .dlls into my WiX installer package. Awesome!</div>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2010/03/sharpsvn-a-primer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

