Optionally repack the object repository after every pull
authorChuck Lever <chuck.lever@oracle.com>
Wed, 8 Nov 2006 22:30:03 +0000 (22:30 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 8 Nov 2006 22:30:03 +0000 (22:30 +0000)
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 <chuck.lever@oracle.com>
examples/stgitrc
stgit/commands/pull.py
stgit/config.py
stgit/git.py

index 74c54c4..45a629b 100644 (file)
@@ -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
index 8f26f4d..227249e 100644 (file)
@@ -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()
index f9ea074..a2e29bb 100644 (file)
@@ -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
index db3a894..2a6ae91 100644 (file)
@@ -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