Your message dated Fri, 15 May 2009 09:17:24 +0000
with message-id <[email protected]>
and subject line Bug#527092: fixed in cia-clients 20090515
has caused the Debian Bug report #527092,
regarding New version of bzr-cia
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
527092: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=527092
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: cia-clients
Version: 20081025
Severity: wishlist

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The attached patch updates the copy of bzr-cia included in cia-clients.

- -- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (650, 'unstable'), (600, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.29-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages cia-clients depends on:
ii  python                        2.5.4-2    An interactive high-level object-o
ii  python-central                0.6.11     register and build utility for Pyt

cia-clients recommends no packages.

Versions of packages cia-clients suggests:
ii  bzr                         1.14-2       easy to use distributed version co
ii  cvs                         1:1.12.13-12 Concurrent Versions System
ii  darcs                       2.2.0-1      a distributed, interactive, smart 
ii  git-core                    1:1.6.2.4-1  fast, scalable, distributed revisi
ii  mercurial                   1.2-1        scalable distributed version contr
ii  subversion                  1.6.1dfsg-1  Advanced version control system

- -- no debconf information
diff -r d2fd0351c5f4 bzr-cia/__init__.py
--- a/bzr-cia/__init__.py	Sat Oct 25 18:14:34 2008 +0200
+++ b/bzr-cia/__init__.py	Tue May 05 17:53:43 2009 +0200
@@ -1,3 +1,19 @@
+# Copyright (C) 2005-2009 Jelmer Vernooij <[email protected]>
+ 
+# 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, see <http://www.gnu.org/licenses/>.
+
+
 """Post-commit hook to submit the commit to CIA (http://cia.navi.cx/)
 
 Requires bzr 0.15 or higher.
@@ -21,16 +37,11 @@
 
 version_info = (1, 0, 0, 'dev', 0)
 
-import socket
-import sys
-import xmlrpclib
-from xml.sax import saxutils
 
 import bzrlib
 from bzrlib.branch import Branch
 from bzrlib.commands import Command, register_command
 from bzrlib.option import Option
-import bzrlib.errors as errors
 from bzrlib.trace import info, warning
 
 
@@ -53,15 +64,18 @@
         pass
 
 
-def generate_cia_xml(repository, revid, project, revname=None, author=None):
-    revision = repository.get_revision(revid)
-    delta = repository.get_revision_delta(revid)
+def generate_cia_xml(branch, revid, project, revname=None, author=None):
+    from xml.sax import saxutils
+    revision = branch.repository.get_revision(revid)
+    delta = branch.repository.get_revision_delta(revid)
 
     if revname is None:
         revname = revid
 
     if author is None:
-        author = revision.committer
+        authors = revision.get_apparent_authors()
+    else:
+        authors = [author]
 
     files = []
     [files.append(f) for (f,_,_) in delta.added]
@@ -69,6 +83,8 @@
     [files.append(f) for (_,f,_,_,_,_) in delta.renamed]
     [files.append(f) for (f,_,_,_,_) in delta.modified]
 
+    authors_xml = "".join(["      <author>%s</author>\n" % saxutils.escape(author) for author in authors])
+
     return """
 <message>
   <generator> 
@@ -85,17 +101,62 @@
     <commit>
       <revision>%s</revision>
       <files>%s</files>
-      <author>%s</author>
+      %s
       <log>%s</log>
     </commit>
   </body>
 </message>
-""" % (bzrlib.version_string, project, revision.properties['branch-nick'], revision.timestamp, revname,
+""" % (bzrlib.version_string, project, branch.nick, revision.timestamp, revname,
         "\n".join(["<file>%s</file>" % saxutils.escape(f) for f in files]), 
-        saxutils.escape(author), 
+        authors_xml, 
         saxutils.escape(revision.message))
 
 
+def cia_cache_dir():
+    from bzrlib.config import config_dir
+    import os
+    return os.path.join(config_dir(), "cia")
+
+
+def store_failed_message(revid, message):
+    import os
+    cache_dir = cia_cache_dir()
+    if not os.path.isdir(cache_dir):
+        os.mkdir(cache_dir)
+    cache_file = os.path.join(cache_dir, revid)
+    f = open(cache_file, 'w')
+    f.write(message)
+    f.close()
+    return cache_file
+
+
+def cia_connect(config):
+    import xmlrpclib
+    server = config.get_user_option('cia_server')
+    if server is None:
+        server = "http://cia.navi.cx";
+
+    return xmlrpclib.ServerProxy(server)
+
+
+class CIADeliverError(Exception):
+
+    def __init__(self, message):
+        self.message = message
+
+
+def cia_deliver(server, msg):
+    import socket, xmlrpclib
+    try:
+        server.hub.deliver(msg)
+    except xmlrpclib.ProtocolError, e:
+        raise CIADeliverError(e.errmsg)
+    except socket.gaierror, (_, errmsg):
+        raise CIADeliverError(errmsg)
+    except socket.error, (_, errmsg):
+        raise CIADeliverError(errmsg)
+
+
 def cia_submit(branch, revid, revno, dry_run=False):
     config = branch.get_config()
 
@@ -103,10 +164,6 @@
     if project is None:
         return
 
-    server = config.get_user_option('cia_server')
-    if server is None:
-        server = "http://cia.navi.cx";
-
     author = config.get_user_option('cia_user')
     quiet = config.get_user_option('cia_quiet')
 
@@ -116,17 +173,17 @@
     else:
         revspec = revid
 
-    msg = generate_cia_xml(branch.repository, revid, project, revspec, author)
+    msg = generate_cia_xml(branch, revid, project, revspec, author)
 
     if not quiet:
         info("Submitting revision to CIA.")
     if not dry_run:
         try:
-            xmlrpclib.ServerProxy(server).hub.deliver(msg)
-        except xmlrpclib.ProtocolError, e:
-            warning("Unable to submit revision to CIA: %s" % e.errmsg)
-        except socket.gaierror, (_, msg):
-            warning("Unable to submit revision to CIA: %s" % msg)
+            cia_deliver(cia_connect(config), msg)
+        except CIADeliverError, (error, ):
+            warning("Unable to submit revision to CIA: %s" % error)
+            store_failed_message(revid, msg)
+            info("To retry submit later, run 'bzr cia-submit --pending'.")
     else:
         print msg
 
@@ -148,40 +205,63 @@
             print config.get_user_option('cia_project')
 
 
+def submit_pending(config):
+    import os
+    server = cia_connect(config)
+    cache_dir = cia_cache_dir()
+    for revid in os.listdir(cache_dir):
+        path = os.path.join(cache_dir, revid)
+        msg = open(path, 'r').read()
+        try:
+            cia_deliver(server, msg)
+        except CIADeliverError, (error, ):
+            warning("Submitting %s failed: %s" % (revid, error))
+        else:
+            os.remove(path)
+
+
 class cmd_cia_submit(Command):
     """Submit a revision to CIA
 
     """
     takes_args = ['branch?']
     takes_options = ['revision', 
+        Option('pending', 
+            help="Submit all pending CIA submissions."),
         Option('dry-run', 
             help="Show what would be done, but don't actually do anything.")]
 
-    def run(self, branch='.', revision=None,dry_run=False):
-        br = Branch.open(branch)
+    def run(self, branch=None, revision=None, dry_run=False, pending=False):
+        if pending and (branch is not None or revision is not None):
+            raise BzrCommandError("--pending and specifying a branch are mutually exclusive")
+        if pending:
+            from bzrlib.config import GlobalConfig
+            submit_pending(GlobalConfig())
+        else:
+            if branch is not None:
+                branch = "."
+            br = Branch.open(branch)
 
-        if revision is None:
-            revs = [br.last_revision()]
-        elif len(revision) == 1:
-            revs = [revision[0].in_history(br).rev_id]
-        elif len(revision) == 2:
-            if revision[0].spec is None:
-                from_revno = 1
+            if revision is None:
+                revs = [br.last_revision()]
+            elif len(revision) == 1:
+                revs = [revision[0].in_history(br).rev_id]
+            elif len(revision) == 2:
+                if revision[0].spec is None:
+                    from_revno = 1
+                else:
+                    from_revno = revision[0].in_history(br).revno
+
+                if revision[1].spec is None:
+                    to_revno = br.revno()
+                else:
+                    to_revno = revision[1].in_history(br).revno
+                revs = br.revision_history()[from_revno:to_revno]
             else:
-                from_revno = revision[0].in_history(br).revno
+                raise BzrCommandError('bzr submit-cia --revision takes one or two arguments')
 
-            if revision[1].spec is None:
-                to_revno = br.revno()
-            else:
-                to_revno = revision[1].in_history(br).revno
-            revs = br.revision_history()[from_revno:to_revno]
-        else:
-            raise BzrCommandError('bzr submit-cia --revision takes one or two arguments')
-
-        for rev_id in revs:
-            cia_submit(br, rev_id, br.revision_id_to_revno(rev_id), dry_run)
-        
-        return 0
+            for rev_id in revs:
+                cia_submit(br, rev_id, br.revision_id_to_revno(rev_id), dry_run)
 
 
 register_command(cmd_cia_project)
@@ -202,7 +282,7 @@
 
 def test_suite():
     from unittest import TestSuite, TestLoader
-    import tests
+    from bzrlib.plugins.cia import tests
     suite = TestSuite()
     suite.addTest(tests.test_suite())
     return suite
diff -r d2fd0351c5f4 bzr-cia/tests/test_xml.py
--- a/bzr-cia/tests/test_xml.py	Sat Oct 25 18:14:34 2008 +0200
+++ b/bzr-cia/tests/test_xml.py	Tue May 05 17:53:43 2009 +0200
@@ -28,7 +28,7 @@
         revid = tree.commit("bla", timestamp=1180551778, 
                 committer="Jelmer Vernooij <[email protected]>")
 
-        xml = generate_cia_xml(tree.branch.repository, revid, "myproject")
+        xml = generate_cia_xml(tree.branch, revid, "myproject")
 
         self.assertEqualDiff("""
 <message>
@@ -57,7 +57,7 @@
         tree = self.make_branch_and_tree("bla")
         revid = tree.commit("bla", timestamp=1180551778)
 
-        xml = generate_cia_xml(tree.branch.repository, revid, "myproject", 
+        xml = generate_cia_xml(tree.branch, revid, "myproject", 
                 author="somebody")
 
         self.assertEqualDiff("""
@@ -87,7 +87,7 @@
         tree = self.make_branch_and_tree("bla")
         revid = tree.commit("bla", timestamp=1180551778)
 
-        xml = generate_cia_xml(tree.branch.repository, revid, "myproject", 
+        xml = generate_cia_xml(tree.branch, revid, "myproject", 
                 revname="42", author="somebody")
 
         self.assertEqualDiff("""

--- End Message ---
--- Begin Message ---
Source: cia-clients
Source-Version: 20090515

We believe that the bug you reported is fixed in the latest version of
cia-clients, which is due to be installed in the Debian FTP archive:

cia-clients_20090515.dsc
  to pool/main/c/cia-clients/cia-clients_20090515.dsc
cia-clients_20090515.tar.gz
  to pool/main/c/cia-clients/cia-clients_20090515.tar.gz
cia-clients_20090515_all.deb
  to pool/main/c/cia-clients/cia-clients_20090515_all.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Christoph Berg <[email protected]> (supplier of updated cia-clients package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Fri, 15 May 2009 10:24:51 +0200
Source: cia-clients
Binary: cia-clients
Architecture: source all
Version: 20090515
Distribution: unstable
Urgency: low
Maintainer: Christoph Berg <[email protected]>
Changed-By: Christoph Berg <[email protected]>
Description: 
 cia-clients - clients scripts for CIA commit notification on IRC
Closes: 527088 527092
Changes: 
 cia-clients (20090515) unstable; urgency=low
 .
   * Moving packaging to collab-maint git on alioth.
   * Removing baz (arch-based bazaar) support. Suggested by Jelmer.
     (Closes: 527088)
   * Updating bzr-cia. By Jelmer. (Closes: #527092)
Checksums-Sha1: 
 0be29f7302bc4aaf99519d7c8cbf7ad8ef798ff3 927 cia-clients_20090515.dsc
 5ff1c50d11b8e0e5be19eab532571b08c9a963fb 30385 cia-clients_20090515.tar.gz
 8869e12dd8054105f02de576765d3b64e053054a 27316 cia-clients_20090515_all.deb
Checksums-Sha256: 
 15d47bd27609ecf1628fe59da1b2e8d6b4de20664b40fa35c07c449393aaa7db 927 
cia-clients_20090515.dsc
 fdbd75a10edbeabd0bcb979189b051f5a5efd5b7025793a92edfc03dfc576208 30385 
cia-clients_20090515.tar.gz
 f4ffd6d0941c73a69492f38e5bbc72c825fb5263dddebad5a9143d6da3ec21b3 27316 
cia-clients_20090515_all.deb
Files: 
 3af350224aceb013da045621f5ff60af 927 net optional cia-clients_20090515.dsc
 39e79a2feb5334f0d785a6118a5cb556 30385 net optional cia-clients_20090515.tar.gz
 4c66e23feb41787d857387c06e72ae20 27316 net optional 
cia-clients_20090515_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkoNJ84ACgkQxa93SlhRC1rExgCfbcrnTQm9KAU/hzaKtnVn2S+X
D0IAoNFR3C60eDxaID7x4rMkLqbwsA53
=7gHg
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to