Comments
Patch
@@ -121,6 +121,25 @@
# Push hook
repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
+ class lfsrepo(repo.__class__):
+ @localrepo.unfilteredmethod
+ def commitctx(self, ctx, error=False):
+ pats = []
+ threshold = self.ui.config('lfs', 'threshold')
+ if threshold:
+ pats.append("set:size('>= %s')" % threshold)
+
+ m = lambda x: False
+ if pats:
+ m = scmutil.match(ctx, pats=pats, default='glob')
+
+ self.svfs.options['matcher'] = m
+ x = super(lfsrepo, self).commitctx(ctx, error)
+ self.svfs.options['matcher'] = lambda x: False
+ return x
+
+ repo.__class__ = lfsrepo
+
if 'lfs' not in repo.requirements:
def checkrequireslfs(ui, repo, **kwargs):
if 'lfs' not in repo.requirements:
@@ -135,14 +135,8 @@
def filelogaddrevision(orig, self, text, transaction, link, p1, p2,
cachedelta=None, node=None,
flags=revlog.REVIDX_DEFAULT_FLAGS, **kwds):
- threshold = self.opener.options['lfsthreshold']
- textlen = len(text)
- # exclude hg rename meta from file size
- meta, offset = filelog.parsemeta(text)
- if offset:
- textlen -= offset
-
- if threshold and textlen > threshold:
+ filename = _getfilename(self)
+ if self.opener.options['matcher'](filename):
flags |= revlog.REVIDX_EXTSTORED
return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta,
@@ -380,7 +380,14 @@
else:
raise error.ParseError(_("couldn't parse size: %s") % expr)
- return [f for f in mctx.existing() if m(mctx.ctx[f].size())]
+ # This explodes when converting largefiles -> lfs. It looks like the first
+ # commit converts fine, and then when converting the second commit,
+ # 'lfs.txt' is one of the files tested here, even though it wasn't modified
+ # in this commit (but it was added in the parent).
+
+ # XXX: 'f in mctx.ctx and ...' doesn't short circuit None.size(), so
+ # something appears to be wrong with the ctx for conversions.
+ return [f for f in mctx.existing() if mctx.ctx[f] and m(mctx.ctx[f].size())]
@predicate('encoding(name)', callexisting=True)
def encoding(mctx, x):