# # # patch "viewmtn.py" # from [78255ee04b4c50220ae89a9dc08a9b6f99e820fc] # to [6f367b50c5e91faf4fc5405d7b9beb9f8092779d] # ============================================================ --- viewmtn.py 78255ee04b4c50220ae89a9dc08a9b6f99e820fc +++ viewmtn.py 6f367b50c5e91faf4fc5405d7b9beb9f8092779d @@ -399,12 +399,13 @@ class BranchChanges: raise Exception("get_last_changes() unable to find somewhere to start - probably a non-existent branch?") last_result = None + in_result = set() result = [] revq = [] for rev in heads: heapq.heappush(revq, ComparisonRev(rev)) while len(result) < to_change: -# print >>sys.stderr, "revq state:", map(lambda x: (x.revision, x.date), revq) +# print >>sys.stderr, "start_revq state:", map(lambda x: (x.revision, x.date), revq) # update based on the last result we output if last_result != None: parents = filter(None, ops.parents(last_result.revision)) @@ -412,10 +413,18 @@ class BranchChanges: if parent_rev == None or not on_our_branch(parent_rev): continue heapq.heappush(revq, ComparisonRev(parent_rev)) - if len(revq) == 0: + + # try and find something we haven't already output in the heap + last_result = None + while revq: + candidate = heapq.heappop(revq) + if not (candidate.revision in in_result): + last_result = candidate + break + if last_result == None: break # follow the newest edge - last_result = heapq.heappop(revq) + in_result.add(last_result.revision) result.append(last_result) rv = map (lambda x: (x.revision, x.certs), result[from_change:to_change]), revq