Mercurial > hg-stable
changeset 15227:a7686abf73a6
largefiles: factor out lfutil.getminsize()
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Tue, 11 Oct 2011 21:11:01 -0400 |
parents | 2223ea21c98f |
children | ee625de3541e |
files | hgext/largefiles/lfcommands.py hgext/largefiles/lfutil.py hgext/largefiles/overrides.py |
diffstat | 3 files changed, 18 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py Tue Oct 11 14:01:24 2011 +0200 +++ b/hgext/largefiles/lfcommands.py Tue Oct 11 21:11:01 2011 -0400 @@ -33,17 +33,7 @@ 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():
--- a/hgext/largefiles/lfutil.py Tue Oct 11 14:01:24 2011 +0200 +++ b/hgext/largefiles/lfutil.py Tue Oct 11 21:11:01 2011 -0400 @@ -58,6 +58,20 @@ # -- 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)
--- a/hgext/largefiles/overrides.py Tue Oct 11 14:01:24 2011 +0200 +++ b/hgext/largefiles/overrides.py Tue Oct 11 21:11:01 2011 -0400 @@ -16,6 +16,7 @@ from mercurial.i18n import _ from mercurial.node import hex from hgext import rebase +import lfutil try: from mercurial import scmutil @@ -64,16 +65,8 @@ # 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)):