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 46647 235d0bc11e1d9cd89b9347eff6fa2b49e8d0a793
parent 46646 96871ca322705c08b56cc4e7037e9f1a6d8fa786
child 46648 6fcbab5c1e6e6c195ae1a7b8b191106658a98fef
push id818
push usergszorc@mozilla.com
push dateSat, 23 Jun 2018 18:31:31 +0000
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
+++ b/mercurial/fileset.py
@@ -443,19 +443,20 @@ def eol(mctx, x):
     styles.
     """
 
     # i18n: "eol" is a keyword
     enc = getstring(x, _("eol requires a style name"))
 
     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):
             s.append(f)
         elif enc == 'mac' and re.search('\r(?!\n)', d):
             s.append(f)
     return s
 
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -510,16 +510,27 @@ enabled adds the lfs requirement
   > EOF
   $ hg --config extensions.dumpbinary=$TESTTMP/dumpbinary.py id --trace
   a: binary=True
   b: binary=False
   c: binary=True
   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
 
   $ hg init repo12
   $ cd repo12
   $ cat >> .hg/hgrc <<EOF
   > [lfs]