fileset: use filectx.isbinary() to filter out binaries in eol()
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 21 Jun 2018 00:05:26 -0400
changeset 38414 235d0bc11e1d
parent 38413 96871ca32270
child 38415 6fcbab5c1e6e
fileset: use filectx.isbinary() to filter out binaries in eol() Since LFS stores the binary attribute in the pointer file, this means that the file doesn't need to be downloaded in order to be skipped. This function also catches an IOError if the data can't be loaded in the non-LFS case. I wonder if it's worth storing the unix/dos attributes in the pointer file as well, though I'd expect LFS files to be binary most of the time.
mercurial/fileset.py
tests/test-lfs.t
--- a/mercurial/fileset.py	Tue Jun 19 13:07:18 2018 +0300
+++ b/mercurial/fileset.py	Thu Jun 21 00:05:26 2018 -0400
@@ -448,9 +448,10 @@
 
     s = []
     for f in mctx.existing():
-        d = mctx.ctx[f].data()
-        if stringutil.binary(d):
+        fctx = mctx.ctx[f]
+        if fctx.isbinary():
             continue
+        d = fctx.data()
         if (enc == 'dos' or enc == 'win') and '\r\n' in d:
             s.append(f)
         elif enc == 'unix' and re.search('(?<!\r)\n', d):
--- a/tests/test-lfs.t	Tue Jun 19 13:07:18 2018 +0300
+++ b/tests/test-lfs.t	Thu Jun 21 00:05:26 2018 -0400
@@ -515,6 +515,17 @@
   d: binary=False
   b55353847f02 tip
 
+Binary blobs don't need to be present to be skipped in filesets.  (And their
+absence doesn't cause an abort.)
+
+  $ rm .hg/store/lfs/objects/96/a296d224f285c67bee93c30f8a309157f0daa35dc5b87e410b78630a09cfc7
+  $ rm .hg/store/lfs/objects/92/f76135a4baf4faccb8586a60faf830c2bdfce147cefa188aaf4b790bd01b7e
+
+  $ hg files --debug -r . 'set:eol("unix")' --config 'experimental.lfs.disableusercache=True'
+  lfs: found c04b5bb1a5b2eb3e9cd4805420dba5a9d133da5b7adeeafb5474c4adae9faa80 in the local lfs store
+  lfs: found 5dde896887f6754c9b15bfe3a441ae4806df2fde94001311e08bf110622e0bbe in the local lfs store
+           2   b
+
   $ cd ..
 
 # Test fctx.cmp fastpath - diff without LFS blobs