chiark / gitweb /
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 74c54c4c6b0f4c205d18409cf62644858b417c69..45a629be3e1530e9b3bc040325c4fd2ed96ac9f4 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 8f26f4daf346c87e83b377de3a86c5e09e718d8b..227249e768e6dbc2824cd5641f170f5e196427a3 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 f9ea074f3537970821cef1dfa8790920fbb7bdf7..a2e29bb326eb62e1974df473fa557dd1252301ad 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 db3a89492dd6baed77cc62b934c114022ff36957..2a6ae91cc7606aa2aa7f6725d035da9751143ca9 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