← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/db-merge-stable into lp:launchpad/db-devel

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/db-merge-stable into lp:launchpad/db-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/db-merge-stable/+merge/72301

Merge stable r13744, resolving conflicts.
-- 
https://code.launchpad.net/~stevenk/launchpad/db-merge-stable/+merge/72301
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/db-merge-stable into lp:launchpad/db-devel.
=== modified file 'lib/canonical/launchpad/daemons/tachandler.py'
--- lib/canonical/launchpad/daemons/tachandler.py	2011-08-18 10:13:17 +0000
+++ lib/canonical/launchpad/daemons/tachandler.py	2011-08-20 13:47:26 +0000
@@ -151,6 +151,24 @@
             return
         os.kill(pid, sig)
 
+    def truncateLog(self):
+        """Truncate the log file.
+
+        Leaves everything up to and including the `LOG_MAGIC` marker in
+        place. If the `LOG_MAGIC` marker is not found the log is truncated to
+        0 bytes.
+        """
+        if os.path.exists(self.logfile):
+            with open(self.logfile, "r+b") as logfile:
+                position = 0
+                for line in logfile:
+                    position += len(line)
+                    if readyservice.LOG_MAGIC in line:
+                        logfile.truncate(position)
+                        break
+                else:
+                    logfile.truncate(0)
+
     def setUpRoot(self):
         """Override this.
 

=== modified file 'lib/canonical/launchpad/daemons/tests/test_tachandler.py'
--- lib/canonical/launchpad/daemons/tests/test_tachandler.py	2011-08-18 11:14:54 +0000
+++ lib/canonical/launchpad/daemons/tests/test_tachandler.py	2011-08-20 13:47:26 +0000
@@ -21,6 +21,7 @@
     Not,
     )
 
+from canonical.launchpad.daemons.readyservice import LOG_MAGIC
 from canonical.launchpad.daemons.tachandler import (
     TacException,
     TacTestSetup,
@@ -132,3 +133,40 @@
         # One deprecation warning is emitted.
         self.assertEqual(1, len(warnings_log))
         self.assertIs(DeprecationWarning, warnings_log[0].category)
+
+    def test_truncateLog(self):
+        """
+        truncateLog truncates the log, if it exists, leaving the record of the
+        service start in place.
+        """
+        tempdir = self.useFixture(TempDir()).path
+        fixture = SimpleTac("okay.tac", tempdir)
+
+        # Truncating the log is a no-op if the log does not exist.
+        fixture.truncateLog()
+        self.assertFalse(exists(fixture.logfile))
+
+        # Put something in the log file.
+        with open(fixture.logfile, "wb") as logfile:
+            logfile.write("Hello\n")
+
+        # Truncating the log does not remove the log file.
+        fixture.truncateLog()
+        self.assertTrue(exists(fixture.logfile))
+        with open(fixture.logfile, "rb") as logfile:
+            self.assertEqual("", logfile.read())
+
+        # Put something in the log again, along with LOG_MAGIC.
+        with open(fixture.logfile, "wb") as logfile:
+            logfile.write("One\n")
+            logfile.write("Two\n")
+            logfile.write("Three, %s\n" % LOG_MAGIC)
+            logfile.write("Four\n")
+
+        # Truncating the log leaves everything up to and including the line
+        # containing LOG_MAGIC.
+        fixture.truncateLog()
+        with open(fixture.logfile, "rb") as logfile:
+            self.assertEqual(
+                "One\nTwo\nThree, %s\n" % LOG_MAGIC,
+                logfile.read())

=== modified file 'lib/canonical/librarian/testing/server.py'
--- lib/canonical/librarian/testing/server.py	2011-06-21 16:47:51 +0000
+++ lib/canonical/librarian/testing/server.py	2011-08-20 13:47:26 +0000
@@ -228,6 +228,11 @@
         """Get a list with the contents of the librarian log in it."""
         return open(self.logfile, 'rb').readlines()
 
+    def reset(self):
+        """Reset the librarian to a consistent initial state."""
+        self.clear()
+        self.truncateLog()
+
 
 def fillLibrarianFile(fileid, content='Fake Content'):
     """Write contents in disk for a librarian sampledata."""

=== modified file 'lib/canonical/testing/layers.py'
--- lib/canonical/testing/layers.py	2011-08-12 14:39:51 +0000
+++ lib/canonical/testing/layers.py	2011-08-20 13:47:26 +0000
@@ -913,9 +913,7 @@
     @classmethod
     @profiled
     def _check_and_reset(cls):
-        """Raise an exception if the Librarian has been killed.
-        Reset the storage unless this has been disabled.
-        """
+        """Raise an exception if the Librarian has been killed, else reset."""
         try:
             f = urlopen(config.librarian.download_url)
             f.read()
@@ -926,7 +924,8 @@
                     "LibrarianLayer.reveal() where possible, and ensure "
                     "the Librarian is restarted if it absolutely must be "
                     "shutdown: " + str(e))
-        cls.librarian_fixture.clear()
+        else:
+            cls.librarian_fixture.reset()
 
     @classmethod
     @profiled

=== modified file 'lib/lp/app/javascript/formoverlay/formoverlay.js'
--- lib/lp/app/javascript/formoverlay/formoverlay.js	2011-07-21 09:27:45 +0000
+++ lib/lp/app/javascript/formoverlay/formoverlay.js	2011-08-20 13:47:26 +0000
@@ -27,6 +27,7 @@
 
     Y.after(this._renderUIFormOverlay, this, RENDERUI);
     Y.after(this._bindUIFormOverlay, this, BINDUI);
+    Y.after(this._bindDestroyOnHide, this, BINDUI);
 
 }
 
@@ -184,6 +185,19 @@
      */
     form_submit_callback: {
         value: null
+    },
+
+    /**
+     * A boolean indicating whether or not this overlay should destroy
+     * itself when hidden.
+     *
+     * @attribute destroy_on_hide
+     * @type: boolean
+     * @default: false
+     */
+    destroy_on_hide: {
+        value: false,
+        writeOnce: "initOnly"
     }
 };
 
@@ -270,6 +284,23 @@
     },
 
     /**
+     * If destroy_on_hide, call the destroy method when this formoverlay
+     * is hidden.
+     *
+     * @method _bindDestroyOnHide
+     * @protected
+     */
+    _bindDestroyOnHide: function(){
+        if (this.get('destroy_on_hide')) {
+            this.after('visibleChange', function(e) {
+                if (!e.newVal) {
+                    this.destroy();
+                }
+            });
+        }
+    },
+
+    /**
      * Setup and add the form to the DOM.
      *
      * @method _setFormContent

=== modified file 'lib/lp/app/javascript/formoverlay/tests/test_formoverlay.js'
--- lib/lp/app/javascript/formoverlay/tests/test_formoverlay.js	2011-07-08 05:12:39 +0000
+++ lib/lp/app/javascript/formoverlay/tests/test_formoverlay.js	2011-08-20 13:47:26 +0000
@@ -264,9 +264,35 @@
         Assert.isTrue(centered,
             "The overlay centers itself when it is shown with the centered " +
             "attribute set.");
+    },
+
+    test_destroy_on_hide: function() {
+        this.destroy_form_overlay = make_form_overlay({
+            destroy_on_hide: true,
+            headerContent: 'Form for testing',
+            form_content: [
+                'Here is an input: ',
+                '<input type="text" name="field1" id="field1" />',
+                'Here is another input: ',
+                '<input type="text" name="field2" id="field2" />'].join(""),
+            xy: [0, 0]
+        });
+
+        var destroy_fired = false;
+        var onDestroy = function(e) {
+            destroy_fired = true;
+        };
+        this.destroy_form_overlay.on('destroy', onDestroy);
+
+        this.destroy_form_overlay.hide();
+
+        Assert.isTrue(
+            destroy_fired,
+            "The destroy event should have been fired.");
     }
 }));
 
+
 suite.add(new Y.Test.Case({
 
     name: 'form_overlay_data',
@@ -414,7 +440,7 @@
         var external_form_content = '<div id="loaded-content"></div>';
 
         var form_overlay = make_form_overlay({
-            headerContent: 'Form for testing',
+            headerContent: 'Form for testing'
             });
         var mock_io = new Y.lazr.testing.MockIo();
         form_overlay.loadFormContentAndRender(
@@ -434,7 +460,8 @@
         // checking the form content is present in the HTML.
         var form_node_text = form_overlay.form_node.get('innerHTML');
         Assert.areEqual(
-            external_form_content, form_node_text.match(external_form_content),
+            external_form_content,
+            form_node_text.match(external_form_content),
             "Failed to render the form.");
         cleanup_form_overlay(form_overlay);
     },
@@ -443,7 +470,7 @@
         // If something goes wrong when loading the form contents, an
         // error message is displayed.
         var form_overlay = make_form_overlay({
-            headerContent: 'Form for testing',
+            headerContent: 'Form for testing'
             });
         var mock_io = new Y.lazr.testing.MockIo();
         form_overlay.loadFormContentAndRender(
@@ -456,7 +483,7 @@
             'failure');
         mock_io.simulateXhr(response, true);
 
-        var error_message = "Sorry, an error occurred while loading the form."
+        var error_message = "Sorry, an error occurred while loading the form.";
         Assert.areEqual(
             error_message, form_overlay.get('form_content'),
             "Failure to set form content.");

=== modified file 'lib/lp/registry/javascript/distroseriesdifferences_details.js'
--- lib/lp/registry/javascript/distroseriesdifferences_details.js	2011-08-11 13:58:54 +0000
+++ lib/lp/registry/javascript/distroseriesdifferences_details.js	2011-08-20 13:47:26 +0000
@@ -302,7 +302,8 @@
             form_submit_button: submit_button,
             form_cancel_button: cancel_button,
             form_submit_callback: submit_callback,
-            visible: true
+            visible: true,
+            destroy_on_hide: true
         });
         overlay.render();
         return overlay;

=== modified file 'utilities/sourcedeps.cache'
--- utilities/sourcedeps.cache	2011-08-19 09:57:43 +0000
+++ utilities/sourcedeps.cache	2011-08-20 13:47:26 +0000
@@ -1,4 +1,8 @@
 {
+    "bzr-builder": [
+        68, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20101123183213-777lz46xgagn1deg"
+    ], 
     "testresources": [
         16, 
         "robertc@xxxxxxxxxxxxxxxxx-20050911111209-ee5da49011cf936a"
@@ -27,18 +31,14 @@
         24, 
         "launchpad@xxxxxxxxxxxxxxxxx-20100601182722-wo7h2fh0fvyw3aaq"
     ], 
+    "lpreview": [
+        23, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20090720061538-euyh68ifavhy0pi8"
+    ], 
     "bzr-git": [
         259, 
         "launchpad@xxxxxxxxxxxxxxxxx-20110601140035-gl5merbechngjw5s"
     ], 
-    "loggerhead": [
-        452, 
-        "andrew.bennetts@xxxxxxxxxxxxx-20110628173100-owrifrnckvoi60af"
-    ], 
-    "bzr-builder": [
-        68, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20101123183213-777lz46xgagn1deg"
-    ], 
     "bzr-loom": [
         50, 
         "launchpad@xxxxxxxxxxxxxxxxx-20110722102404-hl1z8uzhhwiol34l"
@@ -47,17 +47,17 @@
         4, 
         "sinzui-20090526164636-1swugzupwvjgomo4"
     ], 
-    "lpreview": [
-        23, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20090720061538-euyh68ifavhy0pi8"
+    "loggerhead": [
+        452, 
+        "andrew.bennetts@xxxxxxxxxxxxx-20110628173100-owrifrnckvoi60af"
     ], 
     "difftacular": [
         6, 
         "aaron@xxxxxxxxxxxxxxxx-20100715135013-uoi3q430urx9gwb8"
     ], 
     "bzr-svn": [
-        2716, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20110813142415-1izlitsieztuzkly"
+        2717, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20110819140025-1a6tgsdwtjx3plii"
     ], 
     "bzr-hg": [
         290, 

=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf	2011-08-19 09:57:43 +0000
+++ utilities/sourcedeps.conf	2011-08-20 13:47:26 +0000
@@ -2,7 +2,7 @@
 bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=259
 bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=290
 bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=50
-bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2716
+bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2717
 cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=432
 dulwich lp:~launchpad-pqm/dulwich/devel;revno=426
 difftacular lp:difftacular;revno=6

=== modified file 'versions.cfg'
--- versions.cfg	2011-08-19 09:57:43 +0000
+++ versions.cfg	2011-08-20 13:47:26 +0000
@@ -31,7 +31,7 @@
 launchpadlib = 1.9.9
 lazr.amqp = 0.1
 lazr.authentication = 0.1.1
-lazr.batchnavigator = 1.2.7
+lazr.batchnavigator = 1.2.8
 lazr.config = 1.1.3
 lazr.delegates = 1.2.0
 lazr.enum = 1.1.3


Follow ups