largefiles: speed up commit by only rewriting standins for modified largefiles
authorNa'Tosha Bard <natosha@unity3d.com>
Thu, 13 Oct 2011 12:11:25 +0200
changeset 15250 f172292cd416
parent 15249 f30c0a7b8346
child 15251 173b00827279
largefiles: speed up commit by only rewriting standins for modified largefiles
hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py	Thu Oct 13 17:54:38 2011 +0200
+++ b/hgext/largefiles/reposetup.py	Thu Oct 13 12:11:25 2011 +0200
@@ -248,26 +248,39 @@
                     # after the rebase.
                     lfcommands.updatelfiles(repo.ui, repo)
                 # Case 1: user calls commit with no specific files or
-                # include/exclude patterns: refresh and commit everything.
+                # include/exclude patterns: refresh and commit all files that
+                # are "dirty".
                 if (match is None) or (not match.anypats() and not \
                         match.files()):
+                    # Spend a bit of time here to get a list of files we know
+                    # are modified so we can compare only against those.
+                    # It can cost a lot of time (several seconds)
+                    # otherwise to update all standins if the largefiles are
+                    # large.
+                    lfdirstate = lfutil.openlfdirstate(ui, self)
+                    dirtymatch = match_.always(repo.root, repo.getcwd())
+                    s = lfdirstate.status(dirtymatch, [], False, False, False)
+                    modifiedfiles = []
+                    for i in s:
+                        modifiedfiles.extend(i)
                     lfiles = lfutil.listlfiles(self)
-                    lfdirstate = lfutil.openlfdirstate(ui, self)
                     # this only loops through lfiles that exist (not
                     # removed/renamed)
                     for lfile in lfiles:
-                        if os.path.exists(self.wjoin(lfutil.standin(lfile))):
-                            # this handles the case where a rebase is being
-                            # performed and the working copy is not updated
-                            # yet.
-                            if os.path.exists(self.wjoin(lfile)):
-                                lfutil.updatestandin(self,
-                                    lfutil.standin(lfile))
-                                lfdirstate.normal(lfile)
+                        if lfile in modifiedfiles:
+                            if os.path.exists(self.wjoin(lfutil.standin(lfile))):
+                                # this handles the case where a rebase is being
+                                # performed and the working copy is not updated
+                                # yet.
+                                if os.path.exists(self.wjoin(lfile)):
+                                    lfutil.updatestandin(self,
+                                        lfutil.standin(lfile))
+                                    lfdirstate.normal(lfile)
                     for lfile in lfdirstate:
-                        if not os.path.exists(
-                                repo.wjoin(lfutil.standin(lfile))):
-                            lfdirstate.drop(lfile)
+                        if lfile in modifiedfiles:
+                            if not os.path.exists(
+                                    repo.wjoin(lfutil.standin(lfile))):
+                                lfdirstate.drop(lfile)
                     lfdirstate.write()
 
                     return orig(text=text, user=user, date=date, match=match,