From 925ff4a7136e29976b88a0d820fd883c6dae5b88 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 8 Nov 2006 22:30:03 +0000 Subject: [PATCH] Optionally repack the object repository after every pull Add an option to .stgitrc which causes the object repository to be repacked after every "stg pull" operation. Especially on NFS, this improves overall performance considerably. The only downside is that the first time it runs it will take a very long time if the repository hasn't been packed recently. Signed-off-by: Chuck Lever --- examples/stgitrc | 3 +++ stgit/commands/pull.py | 5 +++++ stgit/config.py | 1 + stgit/git.py | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/examples/stgitrc b/examples/stgitrc index 74c54c4..45a629b 100644 --- a/examples/stgitrc +++ b/examples/stgitrc @@ -50,6 +50,9 @@ # Leave the original files in the working tree in case of a merge conflict #keeporig: yes +# Optimize (repack) the object store after every pull +#keepoptimized: yes + # Extensions for the files involved in a three-way merge (ancestor, # current, patched) #extensions: .ancestor .current .patched diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py index 8f26f4d..227249e 100644 --- a/stgit/commands/pull.py +++ b/stgit/commands/pull.py @@ -81,4 +81,9 @@ def func(parser, options, args): if not options.nopush: push_patches(applied, options.merged) + # maybe tidy up + repack = config.get('stgit', 'keepoptimized') + if repack == 'yes': + git.repack() + print_crt_patch() diff --git a/stgit/config.py b/stgit/config.py index f9ea074..a2e29bb 100644 --- a/stgit/config.py +++ b/stgit/config.py @@ -35,6 +35,7 @@ config.set('stgit', 'merger', 'diff3 -L current -L ancestor -L patched -m -E ' \ '"%(branch1)s" "%(ancestor)s" "%(branch2)s" > "%(output)s"') config.set('stgit', 'keeporig', 'yes') +config.set('stgit', 'keepoptimized', 'no') config.set('stgit', 'extensions', '.ancestor .current .patched') # Read the configuration files (if any) and override the default settings diff --git a/stgit/git.py b/stgit/git.py index db3a894..2a6ae91 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -705,6 +705,11 @@ def pull(repository = 'origin', refspec = None): if __run(config.get('stgit', 'pullcmd'), args) != 0: raise GitException, 'Failed "git-pull %s"' % repository +def repack(): + """Repack all objects into a single pack + """ + __run('git-repack -a -d -f') + def apply_patch(filename = None, diff = None, base = None, fail_dump = True): """Apply a patch onto the current or given index. There must not -- 2.11.0