diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py index c64b9adfb371b6e9dfd2257d3e2f62d5121341df_aGdleHQvbGZzL19faW5pdF9fLnB5..eefb5d603482ae88c2d9cb75676ec1d2deae1b52_aGdleHQvbGZzL19faW5pdF9fLnB5 100644 --- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -193,6 +193,7 @@ command = registrar.command(cmdtable) templatekeyword = registrar.templatekeyword() +filesetpredicate = registrar.filesetpredicate() def featuresetup(ui, supported): # don't die on seeing a repo with the lfs requirement @@ -349,6 +350,14 @@ # when writing a bundle via "hg bundle" command, upload related LFS blobs wrapfunction(bundle2, 'writenewbundle', wrapper.writenewbundle) +@filesetpredicate('lfs()') +def lfsfileset(mctx, x): + """File that uses LFS storage.""" + # i18n: "lfs" is a keyword + fileset.getargs(x, 0, 0, _("lfs takes no arguments")) + return [f for f in mctx.subset + if wrapper.pointerfromctx(mctx.ctx, f) is not None] + @templatekeyword('lfs_files') def lfsfiles(repo, ctx, **args): """List of strings. LFS files added or modified by the changeset.""" diff --git a/tests/test-lfs.t b/tests/test-lfs.t index c64b9adfb371b6e9dfd2257d3e2f62d5121341df_dGVzdHMvdGVzdC1sZnMudA==..eefb5d603482ae88c2d9cb75676ec1d2deae1b52_dGVzdHMvdGVzdC1sZnMudA== 100644 --- a/tests/test-lfs.t +++ b/tests/test-lfs.t @@ -154,7 +154,13 @@ $ hg add . -q $ hg commit -m 'commit with lfs content' + $ hg files -r . 'set:added()' + large + small + $ hg files -r . 'set:added() & lfs()' + large + $ hg mv large l $ hg mv small s $ hg commit -m 'renames' @@ -157,7 +163,13 @@ $ hg mv large l $ hg mv small s $ hg commit -m 'renames' + $ hg files -r . 'set:copied()' + l + s + $ hg files -r . 'set:copied() & lfs()' + l + $ echo SHORT > l $ echo BECOME-LARGER-FROM-SHORTER > s $ hg commit -m 'large to small, small to large' @@ -1006,7 +1018,7 @@ The LFS policy stops when the .hglfs is gone - $ hg rm .hglfs + $ mv .hglfs .hglfs_ $ echo 'largefile3' > lfs.test $ echo '012345678901234567890abc' > nolfs.exclude $ echo '01234567890123456abc' > lfs.catchall @@ -1014,6 +1026,18 @@ $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n' 4: + $ mv .hglfs_ .hglfs + $ echo '012345678901234567890abc' > lfs.test + $ hg ci -m 'back to lfs' + $ hg rm lfs.test + $ hg ci -qm 'remove lfs' + +TODO: This should notice the deleted lfs files in rev 6 + $ hg log -r 'file("set:lfs()")' -T '{rev} {join(lfs_files, ", ")}\n' + 2 lfs.catchall, lfs.test + 3 lfs.catchall, lfs.test + 5 lfs.test + $ cd .. Unbundling adds a requirement to a non-lfs repo, if necessary.