##// END OF EJS Templates
largefiles: factor out lfutil.getminsize()
Greg Ward -
r15227:a7686abf default
parent child Browse files
Show More
@@ -33,17 +33,7 b' def lfconvert(ui, src, dest, *pats, **op'
33 tolfile = False
33 tolfile = False
34 else:
34 else:
35 tolfile = True
35 tolfile = True
36 size = opts['size']
36 size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
37 if not size:
38 size = ui.config(lfutil.longname, 'size', default=None)
39 try:
40 size = int(size)
41 except ValueError:
42 raise util.Abort(_('largefiles.size must be integer, was %s\n')
43 % size)
44 except TypeError:
45 raise util.Abort(_('size must be specified'))
46
47 try:
37 try:
48 rsrc = hg.repository(ui, src)
38 rsrc = hg.repository(ui, src)
49 if not rsrc.local():
39 if not rsrc.local():
@@ -58,6 +58,20 b' def findoutgoing(repo, remote, force):'
58
58
59 # -- Private worker functions ------------------------------------------
59 # -- Private worker functions ------------------------------------------
60
60
61 def getminsize(ui, assumelfiles, opt, default=10):
62 lfsize = opt
63 if not lfsize and assumelfiles:
64 lfsize = ui.config(longname, 'size', default=default)
65 if lfsize:
66 try:
67 lfsize = int(lfsize)
68 except ValueError:
69 raise util.Abort(_('largefiles: size must be an integer, was %s\n')
70 % lfsize)
71 if lfsize is None:
72 raise util.Abort(_('minimum size for largefiles must be specified'))
73 return lfsize
74
61 def link(src, dest):
75 def link(src, dest):
62 try:
76 try:
63 util.oslink(src, dest)
77 util.oslink(src, dest)
@@ -16,6 +16,7 b' from mercurial import hg, commands, util'
16 from mercurial.i18n import _
16 from mercurial.i18n import _
17 from mercurial.node import hex
17 from mercurial.node import hex
18 from hgext import rebase
18 from hgext import rebase
19 import lfutil
19
20
20 try:
21 try:
21 from mercurial import scmutil
22 from mercurial import scmutil
@@ -64,16 +65,8 b' def restorematchfn():'
64 # version of add.
65 # version of add.
65 def override_add(orig, ui, repo, *pats, **opts):
66 def override_add(orig, ui, repo, *pats, **opts):
66 large = opts.pop('large', None)
67 large = opts.pop('large', None)
67
68 lfsize = lfutil.getminsize(
68 lfsize = opts.pop('lfsize', None)
69 ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
69 if not lfsize and lfutil.islfilesrepo(repo):
70 lfsize = ui.config(lfutil.longname, 'size', default='10')
71 if lfsize:
72 try:
73 lfsize = int(lfsize)
74 except ValueError:
75 raise util.Abort(_('largefiles: size must be an integer, was %s\n')
76 % lfsize)
77
70
78 lfmatcher = None
71 lfmatcher = None
79 if os.path.exists(repo.wjoin(lfutil.shortname)):
72 if os.path.exists(repo.wjoin(lfutil.shortname)):
General Comments 0
You need to be logged in to leave comments. Login now