launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04488
[Merge] lp:~julian-edwards/launchpad/queue-links into lp:launchpad
Julian Edwards has proposed merging lp:~julian-edwards/launchpad/queue-links into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~julian-edwards/launchpad/queue-links/+merge/70554
= Summary =
Make the distro package sync information more useful.
== Proposed fix ==
On the distroseries differences pages (like https://dogfood.launchpad.net/ubuntu/oneiric/+missingpackages) when a package is currently syncing, there's some text next to it that says "Synchronizing ..."
User feedback said that it would be more useful to say if it was stuck in the distroseries queues waiting for archive admin moderation.
== Implementation details ==
This branch adds a new message if it detects that the sync job is in the queues. It puts a "Waiting in <name>" message up where <name> is the name of the queue (e.g. NEW) and the text is linked to the queue page.
== Tests ==
bin/test -cvv test_distroseries test_describeJobs
== Demo and Q/A ==
See above dogfood page link!
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/registry/browser/tests/test_distroseries.py
lib/lp/registry/browser/distroseries.py
--
https://code.launchpad.net/~julian-edwards/launchpad/queue-links/+merge/70554
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/launchpad/queue-links into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2011-08-04 14:17:38 +0000
+++ lib/lp/registry/browser/distroseries.py 2011-08-05 12:33:34 +0000
@@ -66,6 +66,7 @@
stepthrough,
stepto,
)
+from canonical.launchpad.webapp.url import urlappend
from lp.app.browser.launchpadform import (
LaunchpadEditFormView,
LaunchpadFormView,
@@ -959,10 +960,9 @@
"""Have there been changes that `dsd` is still being updated for?"""
return dsd in self.pending_dsd_updates
- def hasPendingSync(self, dsd):
+ def pendingSync(self, dsd):
"""Is there a package-copying job pending to resolve `dsd`?"""
- pending_sync = self.pending_syncs.get(dsd.source_package_name.name)
- return pending_sync is not None
+ return self.pending_syncs.get(dsd.source_package_name.name)
def isNewerThanParent(self, dsd):
"""Is the child's version of this package newer than the parent's?
@@ -993,28 +993,42 @@
# sync if the child's version of the package is newer than the
# parent's version, or if there is already a sync pending.
return (
- not self.isNewerThanParent(dsd) and not self.hasPendingSync(dsd))
+ not self.isNewerThanParent(dsd) and not self.pendingSync(dsd))
def describeJobs(self, dsd):
"""Describe any jobs that may be pending for `dsd`.
- Shows "synchronizing..." if the entry is being synchronized, and
- "updating..." if the DSD is being updated with package changes.
+ Shows "synchronizing..." if the entry is being synchronized,
+ "updating..." if the DSD is being updated with package changes and
+ "waiting in <queue>..." if the package is in the distroseries
+ queues (<queue> will be NEW or UNAPPROVED and links to the
+ relevant queue page).
:param dsd: A `DistroSeriesDifference` on the page.
:return: An HTML text describing work that is pending or in
progress for `dsd`; or None.
"""
has_pending_dsd_update = self.hasPendingDSDUpdate(dsd)
- has_pending_sync = self.hasPendingSync(dsd)
- if not has_pending_dsd_update and not has_pending_sync:
+ pending_sync = self.pendingSync(dsd)
+ if not has_pending_dsd_update and not pending_sync:
return None
description = []
if has_pending_dsd_update:
description.append("updating")
- if has_pending_sync:
- description.append("synchronizing")
+ if pending_sync is not None:
+ # If the pending sync is waiting in the distroseries queues,
+ # provide a handy link to there.
+ pu = getUtility(IPackageUploadSet).getByPackageCopyJobIDs(
+ (pending_sync.id,)).any()
+ if pu is None:
+ description.append("synchronizing")
+ else:
+ url = urlappend(
+ canonical_url(self.context), "+queue?queue_state=%s" %
+ pu.status.value)
+ description.append('waiting in <a href="%s">%s</a>' %
+ (url, pu.status.name))
return " and ".join(description) + "…"
@property
=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py 2011-08-04 14:17:38 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py 2011-08-05 12:33:34 +0000
@@ -1798,18 +1798,18 @@
dsd.derived_series, '+localpackagediffs')
self.assertTrue(view.hasPendingDSDUpdate(dsd))
- def test_hasPendingSync_returns_False_if_no_pending_sync(self):
+ def test_pendingSync_returns_None_if_no_pending_sync(self):
dsd = self.factory.makeDistroSeriesDifference()
view = create_initialized_view(
dsd.derived_series, '+localpackagediffs')
- self.assertFalse(view.hasPendingSync(dsd))
+ self.assertIs(None, view.pendingSync(dsd))
- def test_hasPendingSync_returns_True_if_pending_sync(self):
+ def test_pendingSync_returns_not_None_if_pending_sync(self):
dsd = self.factory.makeDistroSeriesDifference()
view = create_initialized_view(
dsd.derived_series, '+localpackagediffs')
view.pending_syncs = {dsd.source_package_name.name: object()}
- self.assertTrue(view.hasPendingSync(dsd))
+ self.assertIsNot(None, view.pendingSync(dsd))
def test_isNewerThanParent_compares_versions_not_strings(self):
# isNewerThanParent compares Debian-style version numbers, not
@@ -1894,7 +1894,7 @@
view = create_initialized_view(
dsd.derived_series, '+localpackagediffs')
view.hasPendingDSDUpdate = FakeMethod(result=True)
- view.hasPendingSync = FakeMethod(result=False)
+ view.pendingSync = FakeMethod(result=None)
self.assertEqual("updating…", view.describeJobs(dsd))
def test_describeJobs_reports_pending_sync(self):
@@ -1902,15 +1902,36 @@
view = create_initialized_view(
dsd.derived_series, '+localpackagediffs')
view.hasPendingDSDUpdate = FakeMethod(result=False)
- view.hasPendingSync = FakeMethod(result=True)
+ pcj = self.factory.makePlainPackageCopyJob()
+ view.pending_syncs = {dsd.source_package_name.name: pcj}
self.assertEqual("synchronizing…", view.describeJobs(dsd))
+ def test_describeJobs_reports_pending_queue(self):
+ dsd = self.factory.makeDistroSeriesDifference()
+ view = create_initialized_view(
+ dsd.derived_series, '+localpackagediffs')
+ view.hasPendingDSDUpdate = FakeMethod(result=False)
+ pcj = self.factory.makePlainPackageCopyJob()
+ pu = self.factory.makePackageUpload(distroseries=dsd.derived_series)
+ # A copy job with an attached packageupload means the job is
+ # waiting in the queues.
+ removeSecurityProxy(pu).package_copy_job=pcj.id
+ view.pending_syncs = {dsd.source_package_name.name: pcj}
+ expected = (
+ 'waiting in <a href="%s/+queue?queue_state=%s">%s</a>…'
+ % (canonical_url(dsd.derived_series), pu.status.value,
+ pu.status.name))
+ self.assertEqual(expected, view.describeJobs(dsd))
+
def test_describeJobs_reports_pending_sync_and_update(self):
dsd = self.factory.makeDistroSeriesDifference()
view = create_initialized_view(
dsd.derived_series, '+localpackagediffs')
view.hasPendingDSDUpdate = FakeMethod(result=True)
- view.hasPendingSync = FakeMethod(result=True)
+ pcj = self.factory.makePlainPackageCopyJob()
+ self.factory.makePackageUpload(distroseries=dsd.derived_series,
+ package_copy_job=pcj.id)
+ view.pending_syncs = {dsd.source_package_name.name: pcj}
self.assertEqual(
"updating and synchronizing…", view.describeJobs(dsd))