Bug 1289514 - Handle empty changesets in push entry; r=catlee
Bug 1286426 made the pushlog possibly expose pushes with empty
changesets. This commit teaches the pushlog poller to handle that
scenario appropriately by ignoring the push.
MozReview-Commit-ID: 7Sgwfbv66im
--- a/changes/hgpoller.py
+++ b/changes/hgpoller.py
@@ -315,16 +315,21 @@ class BaseHgPoller(BasePoller):
# We want to add at most self.maxChanges changes per push. If
# mergePushChanges is True, then we'll get up to maxChanges pushes,
# each with up to maxChanges changes.
# Go through the list of pushes backwards, since we want to keep the
# latest ones and possibly discard earlier ones.
change_list = []
too_many = False
for push in reversed(push_data['pushes']):
+ # If no changesets in this push, do nothing. This likely
+ # occurs when changesets are obsoleted.
+ if not push['changesets']:
+ continue
+
# Used for merging push changes
c = dict(
user=push['user'],
date=push['date'],
files=[],
desc="",
node=None,
commit_titles=[],
--- a/test/test_hgpoller.py
+++ b/test/test_hgpoller.py
@@ -364,16 +364,53 @@ class PushlogReset(PollingTest):
}
}
""")
self.assertIsNone(poller.lastPushID, 'last push ID should be None')
self.assertEqual(poller._make_url(),
'http://localhost/whatever/json-pushes?version=2&full=1',
'pushlog URL should start from the end')
+class EmptyChangesets(PollingTest):
+ def testEmptyChangesets(self):
+ poller = self.doTest(data="""
+ {
+ "lastpushid": 42,
+ "pushes": {
+ "41": {
+ "changesets": [],
+ "date": 1282358416,
+ "user": "someone@somewhere.com"
+ },
+ "42": {
+ "changesets": [
+ {
+ "author": "Jim Chen <jchen@mozilla.com>",
+ "branch": "default",
+ "desc": "Bug 588456 - Properly commit Android IME composition on blur; r=mwu a=blocking-fennec",
+ "files": [
+ "embedding/android/GeckoInputConnection.java"
+ ],
+ "node": "4c23e51a484f077ea27af3ea4a4ee13da5aeb5e6",
+ "parents": [
+ "935c15d506516a2269cee35a1a80748aaec1ae08"
+ ],
+ "tags": []
+ }
+ ],
+ "date": 1282358417,
+ "user": "someoneelse@somewhere.com"
+ }
+ }
+ }
+ """)
+
+ self.assertEqual(poller.lastPushID, 42)
+ self.assertEqual(len(self.changes), 1)
+
class EmptyPushes(PollingTest):
def testEmptyPushes(self):
poller = self.doTest(data=validPushlog)
self.assertEqual(poller._make_url(), 'http://localhost/whatever/json-pushes?version=2&full=1&startID=15227')
# This simulates what happens on subsequent polls when no new
# data is available.