##// END OF EJS Templates
lfs: don't require the .hglfs file to be tracked to control the policy...
Matt Harbison -
r35825:4425790f stable
parent child Browse files
Show More
@@ -25,14 +25,15 b' becomes burdensome. However, the pre an'
25 not be able to communicate with each other unless the extension is
25 not be able to communicate with each other unless the extension is
26 enabled on both.
26 enabled on both.
27
27
28 To start a new repository, or add new LFS files, just create and add
28 To start a new repository, or to add LFS files to an existing one, just
29 an ``.hglfs`` file as described below. Because the file is tracked in
29 create an ``.hglfs`` file as described below in the root directory of
30 the repository, all clones will use the same selection policy. During
30 the repository. Typically, this file should be put under version
31 subsequent commits, Mercurial will consult this file to determine if
31 control, so that the settings will propagate to other repositories with
32 an added or modified file should be stored externally. The type of
32 push and pull. During any commit, Mercurial will consult this file to
33 storage depends on the characteristics of the file at each commit. A
33 determine if an added or modified file should be stored externally. The
34 file that is near a size threshold may switch back and forth between
34 type of storage depends on the characteristics of the file at each
35 LFS and normal storage, as needed.
35 commit. A file that is near a size threshold may switch back and forth
36 between LFS and normal storage, as needed.
36
37
37 Alternately, both normal repositories and largefile controlled
38 Alternately, both normal repositories and largefile controlled
38 repositories can be converted to LFS by using :hg:`convert` and the
39 repositories can be converted to LFS by using :hg:`convert` and the
@@ -240,29 +241,19 b' def reposetup(ui, repo):'
240 def _trackedmatcher(repo, ctx):
241 def _trackedmatcher(repo, ctx):
241 """Return a function (path, size) -> bool indicating whether or not to
242 """Return a function (path, size) -> bool indicating whether or not to
242 track a given file with lfs."""
243 track a given file with lfs."""
243 data = ''
244 if not repo.wvfs.exists('.hglfs'):
244
245 # No '.hglfs' in wdir. Fallback to config for now.
245 if '.hglfs' in ctx.added() or '.hglfs' in ctx.modified():
246 trackspec = repo.ui.config('lfs', 'track')
246 data = ctx['.hglfs'].data()
247 elif '.hglfs' not in ctx.removed():
248 p1 = repo['.']
249
250 if '.hglfs' not in p1:
251 # No '.hglfs' in wdir or in parent. Fallback to config
252 # for now.
253 trackspec = repo.ui.config('lfs', 'track')
254
247
255 # deprecated config: lfs.threshold
248 # deprecated config: lfs.threshold
256 threshold = repo.ui.configbytes('lfs', 'threshold')
249 threshold = repo.ui.configbytes('lfs', 'threshold')
257 if threshold:
250 if threshold:
258 fileset.parse(trackspec) # make sure syntax errors are confined
251 fileset.parse(trackspec) # make sure syntax errors are confined
259 trackspec = "(%s) | size('>%d')" % (trackspec, threshold)
252 trackspec = "(%s) | size('>%d')" % (trackspec, threshold)
260
253
261 return minifileset.compile(trackspec)
254 return minifileset.compile(trackspec)
262
255
263 data = p1['.hglfs'].data()
256 data = repo.wvfs.tryread('.hglfs')
264
265 # In removed, or not in parent
266 if not data:
257 if not data:
267 return lambda p, s: False
258 return lambda p, s: False
268
259
@@ -984,27 +984,28 b' Bad .hglfs files will block the commit w'
984 > ** = size(">10B")
984 > ** = size(">10B")
985 > EOF
985 > EOF
986
986
987 The LFS policy takes effect as the .hglfs file is committed
987 The LFS policy takes effect without tracking the .hglfs file
988
988
989 $ echo 'largefile' > lfs.test
989 $ echo 'largefile' > lfs.test
990 $ echo '012345678901234567890' > nolfs.exclude
990 $ echo '012345678901234567890' > nolfs.exclude
991 $ echo '01234567890123456' > lfs.catchall
991 $ echo '01234567890123456' > lfs.catchall
992 $ hg ci -Aqm 'added .hglfs'
992 $ hg add *
993 $ hg ci -qm 'before add .hglfs'
993 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
994 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
994 2: lfs.catchall: d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
995 2: lfs.catchall: d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
995 lfs.test: 5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
996 lfs.test: 5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
996
997
997 The existing .hglfs file is used even when it is not in the 'A' or 'M' states
998 The .hglfs file works when tracked
998
999
999 $ echo 'largefile2' > lfs.test
1000 $ echo 'largefile2' > lfs.test
1000 $ echo '012345678901234567890a' > nolfs.exclude
1001 $ echo '012345678901234567890a' > nolfs.exclude
1001 $ echo '01234567890123456a' > lfs.catchall
1002 $ echo '01234567890123456a' > lfs.catchall
1002 $ hg ci -qm 'unmodified .hglfs'
1003 $ hg ci -Aqm 'after adding .hglfs'
1003 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1004 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1004 3: lfs.catchall: 31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
1005 3: lfs.catchall: 31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
1005 lfs.test: 8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
1006 lfs.test: 8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
1006
1007
1007 Excluding the .hglfs file from the commit postpones the policy change
1008 The LFS policy stops when the .hglfs is gone
1008
1009
1009 $ hg rm .hglfs
1010 $ hg rm .hglfs
1010 $ echo 'largefile3' > lfs.test
1011 $ echo 'largefile3' > lfs.test
@@ -1012,17 +1013,7 b' Excluding the .hglfs file from the commi'
1012 $ echo '01234567890123456abc' > lfs.catchall
1013 $ echo '01234567890123456abc' > lfs.catchall
1013 $ hg ci -qm 'file test' -X .hglfs
1014 $ hg ci -qm 'file test' -X .hglfs
1014 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1015 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1015 4: lfs.catchall: 6747cfb1b83965b4a884e7a6061813ae31e4122028bc6a88d2ac5e5f9e05c5af
1016 4:
1016 lfs.test: 3f40b70c2294e91e0fa789ebcf73c5a1d1c7aef270f83e477e40cb0513237e8c
1017
1018 The policy change takes effect when the .hglfs is committed
1019
1020 $ echo 'largefile4' > lfs.test
1021 $ echo '012345678901234567890abcdef' > nolfs.exclude
1022 $ echo '01234567890123456abcdef' > lfs.catchall
1023 $ hg ci -qm 'file test'
1024 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1025 5:
1026
1017
1027 $ cd ..
1018 $ cd ..
1028
1019
General Comments 0
You need to be logged in to leave comments. Login now