Changeset - 6834e1265415
[Not reviewed]
default
0 1 0
Mads Kiilerich - 7 years ago 2018-10-29 01:20:21
mads@kiilerich.com
graph: don't try to get obsolete status for fake parent revisions

Fake parents use negative revision numbers as internal placeholders.
Previous Mercurial versions could handle negative non-existing revision
numbers, but Mercurial 4.8 will fail on this invalid input when getting the
obsolete status.
Instead, make sure we only get obsolete status for actual revisions.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/graphmod.py
Show inline comments
 
@@ -104,75 +104,75 @@ def _colored(repo, dag):
 
      - A list of tuples indicating the edges between the current node and its
 
        parents.
 
    """
 
    branch_cache = {}
 

	
 
    def branch(rev):
 
        """Return branch for rev, using cache for efficiency.
 
        For Mercurial, always return the named branch name (which may be 'default').
 
        For Git, return a branch name for branch heads, otherwise None."""
 
        if rev not in branch_cache:
 
            branch_cache[rev] = repo[rev].branch
 
        return branch_cache[rev]
 

	
 
    row = []  # the ancestor revision that each column is tracking
 
    colors = {}  # color number for revisions - set by descendants
 
    obs = {}  # obsolete flag for revisions - set by descendants
 
    newcolor = 1  # the next available color
 

	
 
    for (rev, dagparents) in dag:
 

	
 
        # Compute row and nextrow
 
        if rev not in row:
 
            row.append(rev)  # new head
 
            colors[rev] = newcolor
 
            obs[rev] = int(repo[rev].obsolete)
 
            newcolor += 1
 

	
 
        col = row.index(rev)
 
        addparents = [p for p in dagparents if p not in row]
 

	
 
        # Add unknown parents to nextrow
 
        tmprow = row[:]
 
        tmprow[col:col + 1] = reversed(addparents) # highest revs first (to the right), dead ends last (to the left)
 
        # Filter old fake parents but keep new ones
 
        nextrow = []
 
        for r in tmprow:
 
            if r >= 0 or r in dagparents:
 
                nextrow.append(r)
 
            else:
 
                colors.pop(r)
 
                obs.pop(r)
 

	
 
        # Let color and obs for this rev be "inherited" by the first "parent"
 
        color = colors.pop(rev)
 
        if addparents:
 
            b = branch(rev)
 
            searching = True
 
            for p in reversed(addparents):
 
                obs[p] = int(repo[p].obsolete)
 
                obs[p] = int(repo[p].obsolete) if p >= 0 else 0
 
                if searching and branch(abs(p)) in [b, None]:
 
                    # This is the first parent on the same branch - inherit the color
 
                    colors[p] = color
 
                    searching = False # make sure we don't give the color away twice
 
                else:
 
                    colors[p] = newcolor
 
                    newcolor += 1
 

	
 
        # Add edges to the graph
 
        edges = []
 
        for ecol, ep in enumerate(row):
 
            if ep in nextrow:
 
                edges.append((ecol, nextrow.index(ep), colors[ep], obs[ep]))
 
            elif ep == rev:
 
                for p in dagparents:
 
                    edges.append((ecol, nextrow.index(p), colors[p], obs[p]))
 

	
 
        # Yield and move on
 
        closing = int(repo[rev].closesbranch)
 
        obsolete = int(repo[rev].obsolete)
 
        bumped = int(repo[rev].bumped)
 
        divergent = int(repo[rev].divergent)
 
        extinct = int(repo[rev].extinct)
 
        unstable = int(repo[rev].unstable)
 
        yield ((col, color), edges, closing, obsolete, bumped, divergent, extinct, unstable)
 
        row = nextrow
0 comments (0 inline, 0 general)