Merge lp:~roadmr/isitdeployable/revision-disappeared-ohnoes into lp:isitdeployable

Proposed by Daniel Manrique
Status: Merged
Approved by: Daniel Manrique
Approved revision: 298
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~roadmr/isitdeployable/revision-disappeared-ohnoes
Merge into: lp:isitdeployable
Diff against target: 23 lines (+5/-1)
1 file modified
revtracker/tasks.py (+5/-1)
To merge this branch: bzr merge lp:~roadmr/isitdeployable/revision-disappeared-ohnoes
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini Approve
Review via email: mp+370451@code.launchpad.net

Commit message

If self.branch.revparse_single(revspec) Keyerrors, it means the revspec we wanted doesn't exist in the source tree anymore - return None

Description of the change

This happened because the review-tools branch had its history rewritten, so a hash referenced in sca r5536 no longer exists; and we can't change sca history itself just to erase this fact; we noticed this when we moved sca's main trunk to git, so it's trying to re-scan all revisions and refetch dependency branches to update the db.

[2019-07-22 20:57:25,119: WARNING/Worker-13] Getting branch git+ssh://git.launchpad.net/review-tools
[2019-07-22 20:57:25,525: WARNING/Worker-13] Got branch
[2019-07-22 20:57:25,530: ERROR/MainProcess] Task revtracker.tasks.update_revisions_task[5cf03caa-51eb-40f2-827f-549dab189367] raised unexpected: KeyError('e8d7f8e7',)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/src/app/revtracker/tasks.py", line 735, in update_revisions_task
    update_revisions(project_id)
  File "/usr/src/app/revtracker/tasks.py", line 717, in update_revisions
    fetched_branches=fetched_branches)
  File "/usr/src/app/revtracker/tasks.py", line 660, in get_revisions
    parent_branch_url, fetched_branches=fetched_branches)
  File "/usr/src/app/revtracker/tasks.py", line 606, in sourcedeps_diff_revisions
    current_revision, fetched_branches=fetched_branches)
  File "/usr/src/app/revtracker/tasks.py", line 578, in sourcedeps_diff
    new_revision = branch.revspec_to_revision(new_revspec)
  File "/usr/src/app/revtracker/tasks.py", line 246, in revspec_to_revision
    revid = self.branch.revparse_single(revspec).id.hex
KeyError: 'e8d7f8e7'

It looks like the code in sourcedeps_diff already handles the case of revspec_to_revision returning None for a non-found revspec.

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

+1

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Jonathan Hartley (tartley) wrote :

The modified functon is also called here:

https://bazaar.launchpad.net/~roadmr/isitdeployable/revision-disappeared-ohnoes/view/head:/revtracker/tasks.py#L264

and the return value from that is used in iter_revisions(), here:

https://bazaar.launchpad.net/~roadmr/isitdeployable/revision-disappeared-ohnoes/view/head:/revtracker/tasks.py#L352

If our modification had returned None, we could guard the access to tip_revision.revno with:

        tip_revision = self.tip_revision()
+ if not tip_revision:
+ return
        if (start_revision is not None and
                tip_revision.revno <= start_revision.revno):
            return

It seems like if this were to occur, then iter_revisions has been asked to iterate over a range starting with a tip that doesn't exist, so returning without yielding anything, an empty generator, seems like the right thing to do maybe?

Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Jonathan Hartley (tartley) wrote :

I guess I meant:

  tip_revision = self.tip_revision()
  if (start_revision is not None and
+ tip_revision is not None and
      tip_revision.revno <= start_revision.revno):
          return

Revision history for this message
Jonathan Hartley (tartley) wrote :

Do I need to put code in markup to prevent whitespace mangling? Apologies for experimenting on your MP.

```
  tip_revision = self.tip_revision()
  if (start_revision is not None and
+ tip_revision is not None and
      tip_revision.revno <= start_revision.revno):
          return
```

Revision history for this message
Daniel Manrique (roadmr) wrote :

I don't think markup is supported here :/

I think I got it, please check latest set of changes :)

297. By Daniel Manrique

revert nonsensical

298. By Daniel Manrique

This makes more sense

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'revtracker/tasks.py'
2--- revtracker/tasks.py 2018-10-11 16:10:43 +0000
3+++ revtracker/tasks.py 2019-07-23 13:24:12 +0000
4@@ -243,7 +243,10 @@
5 revid = RevisionSpec.from_string(revspec).as_revision_id(
6 self.branch)
7 else:
8- revid = self.branch.revparse_single(revspec).id.hex
9+ try:
10+ revid = self.branch.revparse_single(revspec).id.hex
11+ except KeyError:
12+ return None
13 return self.get_revision(revid)
14
15 def null_revision(self):
16@@ -348,6 +351,7 @@
17 tip_only=False):
18 tip_revision = self.tip_revision()
19 if (start_revision is not None and
20+ tip_revision is not None and
21 tip_revision.revno <= start_revision.revno):
22 return
23 if start_revision is None:

Subscribers

People subscribed via source and target branches