Patchwork D3893: ui: make the large file warning limit fully configurable

login
register
mail settings
Submitter phabricator
Date July 6, 2018, 3:58 p.m.
Message ID <differential-rev-PHID-DREV-smug5npqfynlfarwik6e-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32671/
State Superseded
Headers show

Comments

phabricator - July 6, 2018, 3:58 p.m.
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While add --large can be used to override it selectively, often enough
  the user simply doesn't care about machines with less than 100MB RAM or
  so, so make it possible to just specify a larger limit in hgrc.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3893

AFFECTED FILES
  mercurial/configitems.py
  mercurial/context.py
  mercurial/help/config.txt
  tests/test-largefiles.t

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - July 7, 2018, 2:43 a.m.
The idea looks good.

>   While add --large can be used to override it selectively, often enough
>   the user simply doesn't care about machines with less than 100MB RAM or
>   so, so make it possible to just specify a larger limit in hgrc.

I think --large is the option to add a file as largefile of the largefiles
extension.

> -                if st.st_size > 10000000:
> +                limit = ui.config('ui', 'largefilelimit')
> +                if limit != 0 and st.st_size > limit:

`ui.config()` returns a string. Perhaps `ui.configbytes()` can be used
instead.

Can you add tests for limit=0 and st_size <= limit?
phabricator - July 7, 2018, 2:51 a.m.
yuja added a comment.


  The idea looks good.
  
  >   While add --large can be used to override it selectively, often enough
  >   the user simply doesn't care about machines with less than 100MB RAM or
  >   so, so make it possible to just specify a larger limit in hgrc.
  
  I think --large is the option to add a file as largefile of the largefiles
  extension.
  
  > - if st.st_size > 10000000: +                limit = ui.config('ui', 'largefilelimit') +                if limit != 0 and st.st_size > limit:
  
  `ui.config()` returns a string. Perhaps `ui.configbytes()` can be used
  instead.
  
  Can you add tests for limit=0 and st_size <= limit?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3893

To: joerg.sonnenberger, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - July 7, 2018, 6:39 a.m.
av6 added inline comments.

INLINE COMMENTS

> configitems.py:1080
>  )
> +coreconfigitem('ui', 'largefilelimit',
> +    default=10000000,

Suggestion: `large-file-limit`. https://www.mercurial-scm.org/wiki/UIGuideline#naming_config_options

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3893

To: joerg.sonnenberger, #hg-reviewers
Cc: av6, yuja, mercurial-devel

Patch

diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1860,6 +1860,8 @@ 
   $ hg add --normal new-largefile
   new-largefile: up to 69 MB of RAM may be required to manage this file
   (use 'hg revert new-largefile' to cancel the pending addition)
+  $ hg revert new-largefile
+  $ hg --config ui.largefilelimit=30000000 add --normal new-largefile
 
 Test explicit commit of switch between normal and largefile - make sure both
 the add and the remove is committed.
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -2125,6 +2125,10 @@ 
     Possible values are 'text' and 'curses'.
     This config overrides the interface specified by ui.interface.
 
+``largefilelimit``
+    Largest file size that gives no memory use warning.
+    Possible values are integers or 0 to disable the check.
+
 ``logtemplate``
     Template string for commands that print changesets.
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1332,7 +1332,8 @@ 
                     ui.warn(_("%s does not exist!\n") % uipath(f))
                     rejected.append(f)
                     continue
-                if st.st_size > 10000000:
+                limit = ui.config('ui', 'largefilelimit')
+                if limit != 0 and st.st_size > limit:
                     ui.warn(_("%s: up to %d MB of RAM may be required "
                               "to manage this file\n"
                               "(use 'hg revert %s' to cancel the "
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1077,6 +1077,9 @@ 
 coreconfigitem('ui', 'interface.chunkselector',
     default=None,
 )
+coreconfigitem('ui', 'largefilelimit',
+    default=10000000,
+)
 coreconfigitem('ui', 'logblockedtimes',
     default=False,
 )