Skip to content

Commit

Permalink
Backwards compatible submit (#35)
Browse files Browse the repository at this point in the history
---
fel-version: 0.3.2
fel-stack: devel
fel-stack-index: 1
fel-branch: fel/devel/1
fel-amended-from: 92027f5
fel-pr: 35
  • Loading branch information
Zabot committed Jun 11, 2021
1 parent 0faefc3 commit a0a8e91
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions fel/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,8 @@ def __init__(self, repo, branch, upstream, branch_prefix="fel"):
def commits(self):
"""Return all of the commits in this stack."""

# Find the first commit on branch that isn't in upstream
root, _ = get_first_unique(self.repo, self.branch.commit, self.upstream)

# Find all of the commits in the tree
commits, refs = get_subtree(self.repo, root)

# Find all of the commits between HEAD and mergebase
commits.add(root)

s = [c for c in commits]
return s
_, commits = self.render_stack(None, None)
return commits

def filter(self, callback):
"""Run callback to rewrite every commit in the stack"""
Expand Down Expand Up @@ -107,15 +98,19 @@ def annotate(self, progress, branch_prefix="fel"):
stack.
"""
# The name of the stack is the name of the currently checked out branch
stack = self.repo.head.ref
stack = self.repo.head.ref.name

with progress.start("Annotating branches", False):

# Keep track of the filter-repo id of each commit we find
commit_indexes = {}

def do_annotate(sha, commit, meta):
if "fel-stack" not in meta:
try:
assert stack == meta["fel-stack"]
stack_index = meta["fel-stack-index"]

except KeyError:
# If this is the first commit in the stack, it has an index of 0
if sha == self.root.hexsha:
stack_index = 0
Expand All @@ -136,10 +131,16 @@ def do_annotate(sha, commit, meta):
meta["fel-version"] = __version__
meta["fel-stack"] = stack
meta["fel-stack-index"] = stack_index
meta["fel-branch"] = "{}/{}/{}".format(
branch_prefix, meta["fel-stack"], meta["fel-stack-index"]
)
commit_indexes[commit.id] = (stack, stack_index)

# If an older version of fel created this commit with a different
# branch, then it won't have a fel-stack. Still use the old
# branch
if "fel-branch" not in meta:
meta["fel-branch"] = "{}/{}/{}".format(
branch_prefix, meta["fel-stack"], meta["fel-stack-index"]
)

commit_indexes[commit.id] = (stack, stack_index)

# Run do_annotate over all of the commits in this stack
self.filter(do_annotate)
Expand Down

0 comments on commit a0a8e91

Please sign in to comment.