diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -33,17 +33,7 @@ def lfconvert(ui, src, dest, *pats, **op tolfile = False else: tolfile = True - size = opts['size'] - if not size: - size = ui.config(lfutil.longname, 'size', default=None) - try: - size = int(size) - except ValueError: - raise util.Abort(_('largefiles.size must be integer, was %s\n') - % size) - except TypeError: - raise util.Abort(_('size must be specified')) - + size = lfutil.getminsize(ui, True, opts.get('size'), default=None) try: rsrc = hg.repository(ui, src) if not rsrc.local(): diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -58,6 +58,20 @@ def findoutgoing(repo, remote, force): # -- Private worker functions ------------------------------------------ +def getminsize(ui, assumelfiles, opt, default=10): + lfsize = opt + if not lfsize and assumelfiles: + lfsize = ui.config(longname, 'size', default=default) + if lfsize: + try: + lfsize = int(lfsize) + except ValueError: + raise util.Abort(_('largefiles: size must be an integer, was %s\n') + % lfsize) + if lfsize is None: + raise util.Abort(_('minimum size for largefiles must be specified')) + return lfsize + def link(src, dest): try: util.oslink(src, dest) diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -16,6 +16,7 @@ from mercurial import hg, commands, util from mercurial.i18n import _ from mercurial.node import hex from hgext import rebase +import lfutil try: from mercurial import scmutil @@ -64,16 +65,8 @@ def restorematchfn(): # version of add. def override_add(orig, ui, repo, *pats, **opts): large = opts.pop('large', None) - - lfsize = opts.pop('lfsize', None) - if not lfsize and lfutil.islfilesrepo(repo): - lfsize = ui.config(lfutil.longname, 'size', default='10') - if lfsize: - try: - lfsize = int(lfsize) - except ValueError: - raise util.Abort(_('largefiles: size must be an integer, was %s\n') - % lfsize) + lfsize = lfutil.getminsize( + ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None)) lfmatcher = None if os.path.exists(repo.wjoin(lfutil.shortname)):