<?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>Tony&#039;s Blog &#187; mercurial</title>
	<atom:link href="http://stolennotebook.com/anthony/category/mercurial/feed/" rel="self" type="application/rss+xml" />
	<link>http://stolennotebook.com/anthony</link>
	<description>Just another Stolen Notebook weblog</description>
	<lastBuildDate>Tue, 07 Sep 2010 16:24:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>simple twitter mercurial hook</title>
		<link>http://stolennotebook.com/anthony/2009/03/30/simple-twitter-mercurial-hook/</link>
		<comments>http://stolennotebook.com/anthony/2009/03/30/simple-twitter-mercurial-hook/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 06:56:17 +0000</pubDate>
		<dc:creator>tonymagro</dc:creator>
				<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://www.stolennotebook.com/anthony/?p=33</guid>
		<description><![CDATA[UPDATE: This script uses basic auth and no longer works as of Aug 31, 2010. Please use the updated version with OAuth support This is a really simple mercurial 1.2 hook for posting incoming changesets to twitter. It requires python-twitter. File: hgtwitter.py ''' [extensions] hgext.hgtwitter= &#160; [hooks] incoming.notify = python:hgext.hgtwitter.hook &#160; [twitter] username = twitter_username [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<h3><span style="color: #ff0000;">UPDATE: This script uses basic auth and no longer works as of Aug 31, 2010. Please use</span> <a href="http://stolennotebook.com/anthony/2010/09/07/simple-twitter-oauth-mercurial-hook/">the updated version with OAuth support</a></h3>
<p>This is a really simple <a href="http://www.selenic.com/mercurial/wiki/">mercurial</a> 1.2 hook for posting incoming changesets to <a href="http://twitter.com">twitter</a>. It requires <a href="http://code.google.com/p/python-twitter/">python-twitter</a>.<br />
<code>File: hgtwitter.py</code></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;color: #111;"><span style="color: #483d8b;color: #666666;">''</span><span style="color: #483d8b;color: #666666;">'
[extensions]
hgext.hgtwitter=
&nbsp;
[hooks]
incoming.notify = python:hgext.hgtwitter.hook
&nbsp;
[twitter]
username = twitter_username
password = twitter_password
'</span><span style="color: #483d8b;color: #666666;">''</span>
<span style="color: #ff7700;font-weight:bold;color: #B83A24;">from</span> mercurial <span style="color: #ff7700;font-weight:bold;color: #B83A24;">import</span> cmdutil, templater
<span style="color: #ff7700;font-weight:bold;color: #B83A24;">import</span> twitter
&nbsp;
tweet_template = <span style="color: #483d8b;color: #666666;">''</span><span style="color: #483d8b;color: #666666;">'
|{root|basename}:{rev}|
{desc|strip}
'</span><span style="color: #483d8b;color: #666666;">''</span>.<span style="color: black;color: #517656">strip</span><span style="color: black;color: #729AE3;">&#40;</span><span style="color: black;color: #729AE3;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: #B83A24;">def</span> hook<span style="color: black;color: #729AE3;">&#40;</span>ui, repo, hooktype, node=<span style="color: #008000;color: #B83A24;">None</span>, source=<span style="color: #008000;color: #B83A24;">None</span>, <span style="color: #66cc66;color: #729AE3;">**</span>kwargs<span style="color: black;color: #729AE3;">&#41;</span>:
    ctx = repo<span style="color: black;color: #729AE3;">&#91;</span>node<span style="color: black;color: #729AE3;">&#93;</span>
    tuser = ui.<span style="color: black;color: #517656">config</span><span style="color: black;color: #729AE3;">&#40;</span><span style="color: #483d8b;color: #666666;">'twitter'</span>, <span style="color: #483d8b;color: #666666;">'username'</span><span style="color: black;color: #729AE3;">&#41;</span>
    tpass = ui.<span style="color: black;color: #517656">config</span><span style="color: black;color: #729AE3;">&#40;</span><span style="color: #483d8b;color: #666666;">'twitter'</span>, <span style="color: #483d8b;color: #666666;">'password'</span><span style="color: black;color: #729AE3;">&#41;</span>
&nbsp;
    t = cmdutil.<span style="color: black;color: #517656">changeset_templater</span><span style="color: black;color: #729AE3;">&#40;</span>ui=ui, repo=repo,
                                   patch=<span style="color: #008000;color: #B83A24;">False</span>, diffopts=<span style="color: #008000;color: #B83A24;">None</span>,
                                   mapfile=<span style="color: #008000;color: #B83A24;">None</span>, buffered=<span style="color: #008000;color: #B83A24;">False</span><span style="color: black;color: #729AE3;">&#41;</span>
    t.<span style="color: black;color: #517656">use_template</span><span style="color: black;color: #729AE3;">&#40;</span>templater.<span style="color: black;color: #517656">parsestring</span><span style="color: black;color: #729AE3;">&#40;</span>tweet_template,
                                        quoted=<span style="color: #008000;color: #B83A24;">False</span><span style="color: black;color: #729AE3;">&#41;</span><span style="color: black;color: #729AE3;">&#41;</span>
&nbsp;
    ui.<span style="color: black;color: #517656">pushbuffer</span><span style="color: black;color: #729AE3;">&#40;</span><span style="color: black;color: #729AE3;">&#41;</span>
    t.<span style="color: black;color: #517656">show</span><span style="color: black;color: #729AE3;">&#40;</span>ctx, changes=ctx.<span style="color: black;color: #517656">changeset</span><span style="color: black;color: #729AE3;">&#40;</span><span style="color: black;color: #729AE3;">&#41;</span>, root=repo.<span style="color: black;color: #517656">root</span><span style="color: black;color: #729AE3;">&#41;</span>
    tweet = ui.<span style="color: black;color: #517656">popbuffer</span><span style="color: black;color: #729AE3;">&#40;</span><span style="color: black;color: #729AE3;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;color: #B83A24;">if</span> <span style="color: #008000;color: #B83A24;">len</span><span style="color: black;color: #729AE3;">&#40;</span>tweet<span style="color: black;color: #729AE3;">&#41;</span> <span style="color: #66cc66;color: #729AE3;">&amp;</span>gt<span style="color: #66cc66;color: #729AE3;">;</span> <span style="color: #ff4500;color: #3F75D9;">140</span>:
        tweet = tweet<span style="color: black;color: #729AE3;">&#91;</span>:<span style="color: #ff4500;color: #3F75D9;">139</span><span style="color: black;color: #729AE3;">&#93;</span> + u<span style="color: #483d8b;color: #666666;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>2026&quot;</span>
&nbsp;
    api = twitter.<span style="color: black;color: #517656">Api</span><span style="color: black;color: #729AE3;">&#40;</span>username=tuser, password=tpass<span style="color: black;color: #729AE3;">&#41;</span>
    status = api.<span style="color: black;color: #517656">PostUpdate</span><span style="color: black;color: #729AE3;">&#40;</span>tweet<span style="color: black;color: #729AE3;">&#41;</span></pre></div></div>

<p>If you have problems with mercurial 1.1 and lower, try removing the diffopts argument from changeset_templater() so it looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;color: #111;">t = cmdutil.<span style="color: black;color: #517656">changeset_templater</span><span style="color: black;color: #729AE3;">&#40;</span>ui=ui, repo=repo,
                                   patch=<span style="color: #008000;color: #B83A24;">False</span>, mapfile=<span style="color: #008000;color: #B83A24;">None</span>,
                                   buffered=<span style="color: #008000;color: #B83A24;">False</span><span style="color: black;color: #729AE3;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://stolennotebook.com/anthony/2009/03/30/simple-twitter-mercurial-hook/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
