Can I supress large file warning?

Giorgos Keramidas keramida at ceid.upatras.gr
Thu Sep 4 14:19:30 UTC 2008


On Thu, 04 Sep 2008 08:42:25 +0200, Martin Geisler <mg at daimi.au.dk> wrote:
>Giorgos Keramidas <keramida at ceid.upatras.gr> writes:
>> 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.
>
> I think it is a good idea to make this configurable, maybe with 0
> meaning "stop bothering me". Also, would it not be better to make the
> unit be mebibytes, that is, 2**20 bytes?

Switching to MB as units would be easy, yes.  Disabling the check too.
The following patch seems to do both and rewords the old help text of
largefilesize to reflect the changes.

Running a patched hg version you should see something like this:

  $ dd if=/dev/random of=lala bs=3276800 count=1

  $ ls -lh lala
  -rw-rw-r--  1 keramida  users  -  3.1M Sep  4 17:09 lala

  $ hg revert lala

  $ ./hg --config 'ui.largefilesize=2' add lala
  lala: files over 2MB may cause memory and performance problems
  (use 'hg revert lala' to unadd the file)

  $ hg revert lala

  $ ./hg --config 'ui.largefilesize=0' add lala

  $

FWIW, I don't really care too much if the 'unit' is (10 ** 6) bytes, or
if it changed to (2 ** 20) bytes.  Keeping it as 10**6 matches the
current style of showing 10MB for 10**7 bytes, so I kept this one mostly
because of inertia :)

%%%
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 17:17:08 2008 +0300
@@ -569,6 +569,10 @@
     format, see the hgignore(5) man page.
   interactive;;
     Allow to prompt the user. True or False. Default is True.
+  largefilesize;;
+    The maximum file size (in MB) that "hg add" will accept without a
+    warning about performance problems.  If "largefilesize" is set to
+    zero, then no warning is printed by "hg add" for any file size.
   logtemplate;;
     Template string for commands that print changesets.
   merge;;
diff -r 63d1d3e489f8 lala
Binary file lala has changed
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 17:17:08 2008 +0300
@@ -1026,6 +1026,14 @@
         return r
 
     def add(self, list):
+        maxmb = 10
+        maxbytes = maxmb * (10 ** 6)
+        try:
+            maxmb = int(self.ui.config('ui', 'largefilesize'))
+            maxbytes = maxmb * (10 ** 6)
+        except ValueError:
+            pass
+        self.ui.debug(_("large file size limit set to %d MB\n" % maxmb))
         wlock = self.wlock()
         try:
             rejected = []
@@ -1037,11 +1045,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 maxbytes and st.st_size > maxbytes:
+                    self.ui.warn(_("%s: files over %dMB may cause memory and"
                                    " performance problems\n"
                                    "(use 'hg revert %s' to unadd the file)\n")
-                                   % (f, f))
+                                   % (f, maxmb, 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