Changeset eb70bed28959…
by Benjamin Pollack
Changes to one file · Browse files at eb70bed28959 Diff from another changeset...
|
@@ -0,0 +1,63 @@ + # Copyright (C) 2009 by Benjamin Pollack <benjamin@bitquabit.com>
+#
+# This extension allows you to automatically upload the contents of
+# "hg diff" to the paste.lisp.org pastebin, attaching it to the
+# channel of your choice.
+#
+# To enable the "lisppaste" extension, put these lines in your ~/.hgrc:
+# [extensions]
+# lisppaste= /path/to/lisppaste.py
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+'''allows automatic upload of repository diff to lisppaste
+
+This extension allows you to upload the contents of the "hg diff" command
+directly to the lisppaste paste bin, located at paste.lisp.org. The
+lisppaste paste bin provides direct integration with many IRC channels
+on Freenode, making it very easy for you to quickly submit your pending
+commit for review by your peers.
+'''
+
+import xmlrpclib
+from mercurial import commands, cmdutil, patch, ui, util
+from mercurial.i18n import _
+
+def paste(ui, repo, nick, channel, title, **opts):
+ nick = nick or ui.config('lisppaste', 'nick')
+ channel = channel or ui.config('lisppaste', 'channel')
+ if not nick or not channel or not title:
+ raise util.Abort('must specify nick, channel, and title')
+ rev = opts.get('rev')
+ node1, node2 = cmdutil.revpair(repo, rev)
+ m = cmdutil.match(repo, None, opts)
+ diffs = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
+ udiff = '\n'.join(diffs)
+ if not udiff:
+ ui.status('no changes found; nothing uploaded\n')
+ return
+ server = xmlrpclib.ServerProxy('http://common-lisp.net:8185')
+ ui.status(server.newpaste(channel, nick, title, udiff, 'Unified Context Diff') + '\n')
+
+cmdtable = {
+ 'paste':
+ (paste,
+ [('N', 'nick', '', _('your nickname on Freenode')),
+ ('C', 'channel', '', _('the channel to associate with the paste')),
+ ('m', 'title', '', _('title for the paste')),
+ ] + commands.diffopts + commands.diffopts2 + commands.walkopts,
+ _('hg paste [OPTION]')),
+ }
+
|
Loading...