Can I supress large file warning?

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Sep 3 17:09:10 CDT 2008


On Wed, 03 Sep 2008 21:45:23 +0200, Paul R <paul.r.ml at gmail.com> wrote:
> Hello hg list,
>
> Matt> This is a real warning and you ignore it at your own peril.
>
> The fact that a 9.5Mb file would equally alter performances without
> triggering a warning, shows that this warning, by its nature, is not
> a ideal safety gard.
>
> So maybe we could either let the user desactivate the warning, or let
> him set the limit. In the later case, we can maybe even set the
> default to a lower value.

Something like the attached patch perhaps?

    $ hg debugconfig ui.largefilesize
    1000

    $ ls -l lala
    -rw-rw-r--  1 keramida  users  - 3276800 Sep  4 01:01 lala

    $ ./hg --debug add lala
    adding lala
    large file size limit set to 2000000 bytes
    lala: files over 2000000 bytes may cause memory and performance problems
    (use 'hg revert lala' to unadd the file)

The patch isn't exactly `perfect', and the lower cap-limit of 2.000.000
bytes is somewhat arbitrary, but if it seems useful I'll clean it up and
update the tests...

%%%
diff -r 63d1d3e489f8 doc/hgrc.5.txt
--- a/doc/hgrc.5.txt	Tue Sep 02 15:12:50 2008 +0200
+++ b/doc/hgrc.5.txt	Thu Sep 04 01:06:23 2008 +0300
@@ -569,6 +569,11 @@
     format, see the hgignore(5) man page.
   interactive;;
     Allow to prompt the user. True or False. Default is True.
+  largefilesize;;
+    If a file is larger than largefilesize, we warn the user about
+    potential performance issues on "hg add".  The default limit for
+    file sizes is 10.000.000 bytes.  largefilesize should be a number
+    of bytes larger than or equal to 2.000.000.
   logtemplate;;
     Template string for commands that print changesets.
   merge;;
diff -r 63d1d3e489f8 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Sep 02 15:12:50 2008 +0200
+++ b/mercurial/localrepo.py	Thu Sep 04 01:06:23 2008 +0300
@@ -1026,6 +1026,13 @@
         return r
 
     def add(self, list):
+        maxbytes = 10 ** 7
+        try:
+            maxbytes = int(self.ui.config('ui', 'largefilesize'))
+        except ValueError, inst:
+            pass
+        maxbytes = max(maxbytes, 2000000)
+        self.ui.debug(_("large file size limit set to %d bytes\n" % maxbytes))
         wlock = self.wlock()
         try:
             rejected = []
@@ -1037,11 +1044,11 @@
                     self.ui.warn(_("%s does not exist!\n") % f)
                     rejected.append(f)
                     continue
-                if st.st_size > 10000000:
-                    self.ui.warn(_("%s: files over 10MB may cause memory and"
+                if st.st_size > maxbytes:
+                    self.ui.warn(_("%s: files over %d bytes may cause memory and"
                                    " performance problems\n"
                                    "(use 'hg revert %s' to unadd the file)\n")
-                                   % (f, f))
+                                   % (f, maxbytes, f))
                 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
                     self.ui.warn(_("%s not added: only files and symlinks "
                                    "supported currently\n") % f)
%%%



More information about the Mercurial mailing list