Create local refs to prevent pruning
By default git will prune dangling commits more than 2 weeks old. All the unmerged versions of reviews pushed up more than 2 weeks ago count as such commits, so we're downloading all the history again and again each time git-gc --auto ends up being invoked (which is triggered amongst other things by loose object counts. This leads to random stalls in gertty when it has to redownload those objects - and this is obviously worse when offline. This commit adds refs to prevent this behaviour, but doesn't remove them at any point. We probably want to facilitate gc of merged/abandoned/ignored commits at some point. I'm not sure if that needs to happen in this commit or if it could be added later. Change-Id: I01c61fd65207fe0dc99208241eefd5d6432c2ad0
This commit is contained in:
parent
7f0ebb25bd
commit
071c79f6fb
@ -255,7 +255,7 @@ class SyncChangeTask(Task):
|
|||||||
sync.app.config.password, url[1])
|
sync.app.config.password, url[1])
|
||||||
url = urlparse.urlunsplit(url)
|
url = urlparse.urlunsplit(url)
|
||||||
if (not revision) or self.force_fetch:
|
if (not revision) or self.force_fetch:
|
||||||
fetches[url].append(ref)
|
fetches[url].append('+%(ref)s:%(ref)s' % dict(ref=ref))
|
||||||
if not revision:
|
if not revision:
|
||||||
revision = change.createRevision(remote_revision['_number'],
|
revision = change.createRevision(remote_revision['_number'],
|
||||||
remote_revision['commit']['message'], remote_commit,
|
remote_revision['commit']['message'], remote_commit,
|
||||||
@ -435,7 +435,7 @@ class FetchRefTask(Task):
|
|||||||
url = urlparse.urlunsplit(url)
|
url = urlparse.urlunsplit(url)
|
||||||
self.log.debug("git fetch %s %s" % (url, self.refs))
|
self.log.debug("git fetch %s %s" % (url, self.refs))
|
||||||
repo = sync.app.getRepo(self.project_name)
|
repo = sync.app.getRepo(self.project_name)
|
||||||
refs = self.refs
|
refs = ['+%(ref)s:%(ref)s' % dict(ref=ref) for ref in self.refs]
|
||||||
try:
|
try:
|
||||||
repo.fetch(url, refs)
|
repo.fetch(url, refs)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -359,7 +359,7 @@ This Screen
|
|||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def checkGitRepo(self):
|
def checkGitRepo(self):
|
||||||
missing_revisions = False
|
missing_revisions = set()
|
||||||
change_number = None
|
change_number = None
|
||||||
change_id = None
|
change_id = None
|
||||||
with self.app.db.getSession() as session:
|
with self.app.db.getSession() as session:
|
||||||
@ -368,12 +368,15 @@ This Screen
|
|||||||
change_id = change.id
|
change_id = change.id
|
||||||
repo = self.app.getRepo(change.project.name)
|
repo = self.app.getRepo(change.project.name)
|
||||||
for revision in change.revisions:
|
for revision in change.revisions:
|
||||||
if not (repo.hasCommit(revision.parent) and
|
if not repo.hasCommit(revision.parent):
|
||||||
repo.hasCommit(revision.commit)):
|
missing_revisions.add(revision.parent)
|
||||||
missing_revisions = True
|
if not repo.hasCommit(revision.commit):
|
||||||
|
missing_revisions.add(revision.commit)
|
||||||
|
if missing_revisions:
|
||||||
break
|
break
|
||||||
if missing_revisions:
|
if missing_revisions:
|
||||||
self.app.log.warning("Missing some commits for change %s" % change_number)
|
self.app.log.warning("Missing some commits for change %s %s",
|
||||||
|
change_number, missing_revisions)
|
||||||
task = sync.SyncChangeTask(change_id, force_fetch=True,
|
task = sync.SyncChangeTask(change_id, force_fetch=True,
|
||||||
priority=sync.HIGH_PRIORITY)
|
priority=sync.HIGH_PRIORITY)
|
||||||
self.app.sync.submitTask(task)
|
self.app.sync.submitTask(task)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user