Skip to content
Browse files

Avoid git2hg and cat-file requests in GitHgStore.add_head

To do so, we keep a cache of branches for in-flight changesets.
Ideally, we'd just get rid of tracking branches (we don't /really/ need
it), and move the heads tracking to the helper, but we actually do need
the branch tracking for grafts, until we come up with something better
to handle the situation described in
  • Loading branch information
glandium committed Mar 29, 2017
1 parent eae15f7 commit 35c18e7586d8efcd872cce0e49b5c170e33552f8
Showing with 7 additions and 0 deletions.
  1. +7 −0 cinnabar/
@@ -809,6 +809,7 @@ def __init__(self):
self._graft = None

self._hgheads = VersionedDict()
self._branches = {}

self._replace = Git._replace
# While doing a for_each_ref, ensure refs/notes/cinnabar is in the
@@ -925,7 +926,12 @@ def heads(self, branches={}):
if not branches or b in branches)

def _head_branch(self, head):
if head in self._hgheads:
return self._hgheads[head], head
if head in self._branches:
return self._branches[head], head
branch = self.changeset(head).branch or 'default'
self._branches[head] = branch
return branch, head

def add_head(self, head, parent1=NULL_NODE_ID, parent2=NULL_NODE_ID):
@@ -1135,6 +1141,7 @@ def store_changeset(self, instance, commit=None):
ChangesetPatcher.from_diff(changeset, instance), want_sha1=False)
GitHgHelper.set('changeset-metadata', instance.node, ':1')

self._branches[instance.node] = instance.branch or 'default'
self.add_head(instance.node, instance.parent1, instance.parent2)

TYPE = {

0 comments on commit 35c18e7

Please sign in to comment.
You can’t perform that action at this time.