changeset 954:393bde462133

init: only activate git ignore logic in reposetup This will massively speed up 'hg status' on repos that are not git based. On my macports repo, status went from Before: 0m0.591s After: 0m0.297s
author Sean Farley <sean@farley.io>
date Thu, 29 Oct 2015 15:57:17 -0700
parents 584961625a58
children 528015bde034
files hggit/__init__.py
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -203,6 +203,17 @@
 
 def reposetup(ui, repo):
     if not isinstance(repo, gitrepo.gitrepo):
+
+        if (getattr(dirstate, 'rootcache', False) and
+            (not ignoremod or getattr(ignore, 'readpats', False))):
+            # only install our dirstate wrapper if it has a hope of working
+            import gitdirstate
+            if ignoremod:
+                def ignorewrap(orig, *args, **kwargs):
+                    return gitdirstate.gignore(*args, **kwargs)
+                extensions.wrapfunction(ignore, 'ignore', ignorewrap)
+            dirstate.dirstate = gitdirstate.gitdirstate
+
         klass = hgrepo.generate_repo_subclass(repo.__class__)
         repo.__class__ = klass
 
@@ -241,16 +252,6 @@
     ctx = scmutil.revsingle(repo, opts.get('rev'), '.')
     return verify.verify(ui, repo, ctx)
 
-if (getattr(dirstate, 'rootcache', False) and
-    (not ignoremod or getattr(ignore, 'readpats', False))):
-    # only install our dirstate wrapper if it has a hope of working
-    import gitdirstate
-    if ignoremod:
-        def ignorewrap(orig, *args, **kwargs):
-            return gitdirstate.gignore(*args, **kwargs)
-        extensions.wrapfunction(ignore, 'ignore', ignorewrap)
-    dirstate.dirstate = gitdirstate.gitdirstate
-
 @command('git-cleanup')
 def git_cleanup(ui, repo):
     '''clean up Git commit map after history editing'''