This version of Mercurial support might actually work.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 2 Oct 2012 19:43:03 +0000 (15:43 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 2 Oct 2012 19:43:03 +0000 (15:43 -0400)
Makefile
NEWS
README
control
install.txt
irkerhook.py
irkerhook.xml

index d6af763e87bf0422000aea079ff81c46a426064c..6e2f77900ad9a10ac98a95f02b45e6781306a68d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ uninstall:
        rm -f $(DESTDIR)/usr/share/man/man1/irkerhook.1
 
 clean:
-       rm -f irkerd.8 irker-*.tar.gz *~
+       rm -f irkerd.8 irkerhook.1 irker-*.tar.gz *~
        rm -f SHIPPER.* *.html
 
 PYLINTOPTS = --rcfile=/dev/null --reports=n --include-ids=y --disable="C0103,C0111,C0301,R0201,R0902,R0903,R0912,E1101,W0201,W0621,W0702,F0401"
diff --git a/NEWS b/NEWS
index 675d9095ab113f79ff9f9283dc696d6c7293f082..ff46cd06ac76471789ebb6b8e17725e4a12c26a5 100644 (file)
--- a/NEWS
+++ b/NEWS
   The color variable is no longer boolean; may be miRC or ANSI.
   The installation instructions for irkerhook.py have changed!
 
+1.5 @
+  Mercurial support.
+
+
 
 
 
diff --git a/README b/README
index f4d931c1c9a48fa49136c1fed6a776249d4143fd..5b33b3a4e3bd0d53e281f353dac3a8f247a2f946 100644 (file)
--- a/README
+++ b/README
@@ -6,7 +6,7 @@ listening socket.
 
 It is meant to be used by hook scripts in version-control
 repositories, allowing them to send commit notifications to project
-IRC channels.  A hook script, irkerhook.py, supporting git and
+IRC channels.  A hook script, irkerhook.py, supporting git, hg, and
 Subversion is included in the distribution; see the install.txt file
 for installation instructions.
 
diff --git a/control b/control
index dd71f7681b3e084bfb3f5859449d0b13f3ea8598..98b1725e8089271b85d70f358736cbc6497fe602 100644 (file)
--- a/control
+++ b/control
@@ -7,7 +7,7 @@ Description: An IRC client that runs as a daemon accepting notification requests
  as JSON objects presented to a listening socket. It is meant to be
  used by hook scripts in version-control repositories, allowing them
  to send commit notifications to project IRC channels.  A hook script 
- that works with git and svn is included in the distribution.
+ that works with git, hg, and svn is included in the distribution.
 
 XBS-Gitorious-URL: https://gitorious.org/irker
 
index 4666a6be1c0dd05b5ca735969c9b6890ac714b0b..0ed1d53cbecd5ef88fe85f541a67231843be1e3b 100644 (file)
@@ -41,7 +41,8 @@ installed to launch irkerd as a boot-time service on that system.
 
 Under git, a call to irkerhook.py should be installed in the update 
 hook script of your repo.  Under Subversion, the call goes in your
-repo's post-commit script. See the irkerhook manual page for details.
+repo's post-commit script. Under Mercurial there are twi different
+ways to install it. See the irkerhook manual page for details.
 
 == Testing ==
 
index d8b0719b638f7f6d0b5486ead044e4c1265763b6..983699b6fa2ac841023c420eb1112c66b3bc0292 100755 (executable)
@@ -269,25 +269,23 @@ class HgExtractor(GenericExtractor):
         # file is exercised).  In the first case, we already get repository and
         # ui objects from Mercurial, in the second case, we have to create them
         # from the root path.
+        self.repository = None
+        self.node = None
         if arguments and type(arguments[0]) == type(()):
             # Called from hg_hook function
-            ui, repo, self.node = arguments[0]
+            ui, self.repository, self.node = arguments[0]
             arguments = []  # Should not be processed further by do_overrides
         else:
             # Called from command line: create repo/ui objects
             from mercurial import hg, ui as uimod
 
             repopath = '.'
-            commit = '-1'   # i.e. tip
             for tok in arguments:
                 if tok.startswith('--repository='):
                     repopath = tok[13:]
-                elif tok.startswith('--commit='):
-                    commit = tok[9:]
             ui = uimod.ui()
             ui.readconfig(os.path.join(repopath, '.hg', 'hgrc'), repopath)
-            repo = hg.repository(ui, repopath)
-            node = repo.lookup(commit)
+            self.repository = hg.repository(ui, repopath)
 
         GenericExtractor.__init__(self, arguments)
 
@@ -297,7 +295,7 @@ class HgExtractor(GenericExtractor):
 
         if arguments and type(arguments[0]) == type(()):
             # Called from hg_hook function
-            ui, repo, node = arguments[0]
+            ui, self.repository, self.node = arguments[0]
 
         # Extract global values from the hg configuration file(s)
         self.project = ui.config('irker', 'project')
@@ -313,20 +311,24 @@ class HgExtractor(GenericExtractor):
             self.urlprefix = self.urlprefix.rstrip('/') + '/rev'
             # self.commit is appended to this by do_overrides
         if not self.project:
-            self.project = os.path.basename(repo.root.rstrip('/'))
-
-        # Extract commit-specific values from a "context" object
-        ctx = repo.changectx(node)
-        self.commit = short(node)
-        self.rev = '%d:%s' % (ctx.rev(), self.commit)
-        self.branch = ctx.branch()
-        self.author = person(ctx.user())
-        self.logmsg = ctx.description()
-
-        st = repo.status(ctx.p1().node(), ctx.node())
-        self.files = ' '.join(st[0] + st[1] + st[2])
-
+            self.project = os.path.basename(self.repo.root.rstrip('/'))
         self.do_overrides()
+    def commit_factory(self, commit_id=None):
+        # Extract commit-specific values from a "context" object
+        if commit_id is None:
+            node = self.node
+            commit_id = short(self.node)
+        else:
+            node = self.repository.lookup(commit_id) 
+        commit = Commit(self, commit_id)        
+        ctx = self.repository.changectx(node)
+        commit.rev = '%d:%s' % (ctx.rev(), commit_id)
+        commit.branch = ctx.branch()
+        commit.author = person(ctx.user())
+        commit.logmsg = ctx.description()
+        st = self.repository.status(ctx.p1().node(), ctx.node())
+        commit.files = ' '.join(st[0] + st[1] + st[2])
+        return commit
     def head(self):
         "Return a symbolic reference to the tip commit of the current branch."
         return "-1"
@@ -337,9 +339,9 @@ def hg_hook(ui, repo, _hooktype, node=None, _url=None, **_kwds):
     # [hooks]
     # incoming.irker = python:/path/to/irkerhook.py:hg_hook
     extractor = HgExtractor([(ui, repo, node)])
-    ship(extractor)
+    ship(extractor.commit_factory())
 
-def ship(commit, debug):
+def ship(commit, debug=False):
     "Ship a notification for the sspecified commit."
     metadata = extractor.commit_factory(commit) 
     # Message reduction.  The assumption here is that IRC can't handle
index 90a5f06fea2dfc5612829d15e911ab99a7e371f6..e10d5b838b5b576f7f96fb24b844d4920f2a63c2 100644 (file)
@@ -220,7 +220,7 @@ may have the following values:</para>
 accepts a --repository option with value (the absolute pathname of the
 Subversion repository) and a commit argument (the numeric revision level of
 the commit).  The defaults are the current working directory and HEAD,
-respectively.
+respectively.</para>
 
 <para>Note, however, that you <emphasis>cannot</emphasis> default the
 repository argumment inside a Subversion post-commit hook.  Instead,
@@ -263,9 +263,6 @@ that would have unhappy results.</para>
 
 <refsect2 id="hg"><title>Mercurial</title>
 
-<para>NOTE: Mercurial support is currently broken.  It is expected
-this will be fixed in the next release.</para>
-
 <para>Under Mercurial, <application>irkerhook.py</application> can be
 invoked in two ways: either as a Python hook (preferred) or as a
 script.</para>