summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-09-24 10:03:13 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-09-24 15:03:55 +0100
commit291120ecd777de4439b10a07c6f355c7c9af32ed (patch)
treebd5fac75f2f60abc2777fb4f04aa37969773bd43
parenta7f8b1b63a97c66aea6f39342313d7a5b919cfa7 (diff)
downloadlorry-danielsilverstone/all-repos-bare.tar.gz
Alter repack so that we do a 'git gc' instead.danielsilverstone/all-repos-bare
Git has a garbage collection 'porcelain' command called 'gc' which does more than just repack the repository. Use that in preference to 'git repack' and also configure the repositories so that they don't use too much RAM whilst repacking. Also, we allow gitify_* routines to set self.needs_aggressive on their initial imports so that we aggressively repack the first clone.
-rwxr-xr-xlorry16
-rw-r--r--tests/git-backup-on-error.stdout6
2 files changed, 16 insertions, 6 deletions
diff --git a/lorry b/lorry
index 39fed88..5fea080 100755
--- a/lorry
+++ b/lorry
@@ -189,11 +189,17 @@ class Lorry(cliapp.Application):
gitdir = os.path.join(dirname, 'git')
backupdir = self.backup_gitdir(name, dirname, gitdir)
try:
+ self.needs_aggressive = False
table[vcstype](name, dirname, gitdir, spec)
if self.settings['repack']:
self.progress('.. repacking %s git repository' % name)
- self.run_program(['git', 'repack', '-a', '-d', '--depth=250',
- '--window=250'], cwd=gitdir)
+ self.run_program(['git', 'config',
+ 'pack.windowMemory', '128M'], cwd=gitdir)
+ args = ['git', 'gc']
+ if self.needs_aggressive:
+ args += ['--aggressive']
+ self.run_program(args, cwd=gitdir)
+
self.bundle(name, gitdir)
self.make_tarball(name, gitdir)
except:
@@ -294,6 +300,7 @@ class Lorry(cliapp.Application):
self.progress('.. creating git repo')
os.mkdir(gitdir)
self.run_program(['git', 'init', '--bare', gitdir])
+ self.needs_aggressive = True
# branches are the listed branches, plus the branch specified in url
if 'branches' in spec:
@@ -348,7 +355,7 @@ class Lorry(cliapp.Application):
def gitify_svn(self, project_name, dirname, gitdir, spec):
if not os.path.exists(gitdir):
self.progress('.. doing initial clone')
- os.mkdir(gitdir)
+ self.needs_aggressive = True
layout = spec["layout"]
# if standard layour specified, fill in the defaults
if layout == "standard":
@@ -381,6 +388,7 @@ class Lorry(cliapp.Application):
self.run_program(['git', 'svn', 'fetch'], cwd=gitdir)
def gitify_cvs(self, project_name, dirname, gitdir, spec):
+ self.needs_aggressive = True
self.run_program(['git', 'cvsimport', '-a', '-d', spec['url'],
'-C', gitdir, spec['module']])
@@ -394,6 +402,7 @@ class Lorry(cliapp.Application):
self.run_program(['hg', 'clone', '--quiet', spec['url'], hgdir])
if not os.path.exists(gitdir):
+ self.needs_aggressive = True
self.run_program(['git', 'init', '--bare', gitdir])
self.progress('.. fast-exporting into git')
@@ -418,6 +427,7 @@ class Lorry(cliapp.Application):
self.run_program(['git', 'init', '--bare', gitdir])
cmdline = ["%s.tar-importer" % __file__, tardest]
self.run_program(cmdline, cwd=gitdir)
+ self.needs_aggressive = True
def push_to_mirror_server(self, name, gitdir,
diff --git a/tests/git-backup-on-error.stdout b/tests/git-backup-on-error.stdout
index 7e18431..b284701 100644
--- a/tests/git-backup-on-error.stdout
+++ b/tests/git-backup-on-error.stdout
@@ -12,9 +12,9 @@ DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/info
DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/info/exclude
DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/info/refs
DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/objects
+DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/packed-refs
DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs
DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs/heads
-DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs/heads/master
DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs/tags
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/FETCH_HEAD
@@ -27,9 +27,9 @@ DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/info
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/info/exclude
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/info/refs
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/objects
+DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/packed-refs
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs/heads
-DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs/heads/master
DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs/tags
DATADIR/work-dir/git-backup-test-repo/git/FETCH_HEAD
DATADIR/work-dir/git-backup-test-repo/git/HEAD
@@ -41,7 +41,7 @@ DATADIR/work-dir/git-backup-test-repo/git/info
DATADIR/work-dir/git-backup-test-repo/git/info/exclude
DATADIR/work-dir/git-backup-test-repo/git/info/refs
DATADIR/work-dir/git-backup-test-repo/git/objects
+DATADIR/work-dir/git-backup-test-repo/git/packed-refs
DATADIR/work-dir/git-backup-test-repo/git/refs
DATADIR/work-dir/git-backup-test-repo/git/refs/heads
-DATADIR/work-dir/git-backup-test-repo/git/refs/heads/master
DATADIR/work-dir/git-backup-test-repo/git/refs/tags