Associate orphan messages with revision 1
Technically in the REST API, the revision number for a message is optional. In practice, all current Gerrit messages have a revision. However, in reality (which is apparently different than practice) Gerrit's Gerrit sometimes omits the revision number for some old messages, even though the content of the message actually clearly states "Patch Set 1". To handle this case, just associate messages with the first patchset so they will at least show up without error. The main reason a message is associated with a patchset in the local DB is for when we are writing a message. So this solution is probably good enough. Change-Id: Ibf9d2a20277a89f24bb33d274342abce177f680e
This commit is contained in:
parent
9e7e8acd10
commit
387f3a7130
@ -400,7 +400,7 @@ class SyncChangeTask(Task):
|
||||
account = session.getSystemAccount()
|
||||
message = session.getMessageByID(remote_message['id'])
|
||||
if not message:
|
||||
revision = session.getRevisionByNumber(change, remote_message['_revision_number'])
|
||||
revision = session.getRevisionByNumber(change, remote_message.get('_revision_number', 1))
|
||||
# Normalize date -> created
|
||||
created = dateutil.parser.parse(remote_message['date'])
|
||||
message = revision.createMessage(remote_message['id'], account, created,
|
||||
|
Loading…
x
Reference in New Issue
Block a user