Merge lp:~wgrant/loggerhead/fix-merge-point-recursion into lp:loggerhead

Proposed by William Grant on 2016-03-30
Status: Merged
Merged at revision: 490
Proposed branch: lp:~wgrant/loggerhead/fix-merge-point-recursion
Merge into: lp:loggerhead
Diff against target: 35 lines (+4/-14)
1 file modified
loggerhead/history.py (+4/-14)
To merge this branch: bzr merge lp:~wgrant/loggerhead/fix-merge-point-recursion
Reviewer Review Type Date Requested Status
Colin Watson 2016-03-30 Approve on 2016-03-30
Review via email: mp+290395@code.launchpad.net

Commit message

Rework get_merge_point_list to iterate rather than recurse.

Description of the change

Rework get_merge_point_list to iterate rather than recurse.

Fixes "maximum recursion depth exceeded" exceptions on exceptionally
deep and exceedingly recursive histories.

To post a comment you must log in.
490. By William Grant on 2016-03-30

Rework get_merge_point_list to iterate rather than recurse.

Fixes "maximum recursion depth exceeded" exceptions on exceptionally
deep and exceedingly recursive histories.

Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/history.py'
2--- loggerhead/history.py 2012-02-08 01:50:02 +0000
3+++ loggerhead/history.py 2016-03-30 06:19:19 +0000
4@@ -591,27 +591,17 @@
5 return []
6
7 merge_point = []
8- while True:
9+ nexts = [revid]
10+ while nexts:
11+ revid = nexts.pop()
12 children = self._rev_info[self._rev_indices[revid]][1]
13- nexts = []
14 for child in children:
15 child_parents = self._rev_info[self._rev_indices[child]][2]
16 if child_parents[0] == revid:
17 nexts.append(child)
18 else:
19 merge_point.append(child)
20-
21- if len(nexts) == 0:
22- # only merge
23- return merge_point
24-
25- while len(nexts) > 1:
26- # branch
27- next = nexts.pop()
28- merge_point_next = self.get_merge_point_list(next)
29- merge_point.extend(merge_point_next)
30-
31- revid = nexts[0]
32+ return merge_point
33
34 def simplify_merge_point_list(self, revids):
35 """if a revision is already merged, don't show further merge points"""

Subscribers

People subscribed via source and target branches