##// END OF EJS Templates
largefiles: automatically load largefiles extension when required (BC)...
Gregory Szorc -
r39890:823a5804 default
parent child Browse files
Show More
@@ -889,11 +889,6 b' def hgclone(orig, ui, opts, *args, **kwa'
889 if not repo:
889 if not repo:
890 return result
890 return result
891
891
892 # If largefiles is required for this repo, permanently enable it locally
893 if 'largefiles' in repo.requirements:
894 repo.vfs.append('hgrc',
895 util.tonativeeol('\n[extensions]\nlargefiles=\n'))
896
897 # Caching is implicitly limited to 'rev' option, since the dest repo was
892 # Caching is implicitly limited to 'rev' option, since the dest repo was
898 # truncated at that point. The user may expect a download count with
893 # truncated at that point. The user may expect a download count with
899 # this option, so attempt whether or not this is a largefile repo.
894 # this option, so attempt whether or not this is a largefile repo.
@@ -905,14 +900,6 b' def hgclone(orig, ui, opts, *args, **kwa'
905
900
906 return result
901 return result
907
902
908 def hgpostshare(orig, sourcerepo, destrepo, defaultpath=None):
909 orig(sourcerepo, destrepo, defaultpath=defaultpath)
910
911 # If largefiles is required for this repo, permanently enable it locally
912 if 'largefiles' in destrepo.requirements:
913 destrepo.vfs.append('hgrc',
914 util.tonativeeol('\n[extensions]\nlargefiles=\n'))
915
916 def overriderebase(orig, ui, repo, **opts):
903 def overriderebase(orig, ui, repo, **opts):
917 if not util.safehasattr(repo, '_largefilesenabled'):
904 if not util.safehasattr(repo, '_largefilesenabled'):
918 return orig(ui, repo, **opts)
905 return orig(ui, repo, **opts)
@@ -126,7 +126,6 b' def uisetup(ui):'
126 _('download all versions of all largefiles'))]
126 _('download all versions of all largefiles'))]
127 entry[1].extend(cloneopt)
127 entry[1].extend(cloneopt)
128 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
128 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
129 extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
130
129
131 entry = extensions.wrapcommand(commands.table, 'cat',
130 entry = extensions.wrapcommand(commands.table, 'cat',
132 overrides.overridecat)
131 overrides.overridecat)
@@ -588,6 +588,7 b' def afterhgrcload(ui, wdirvfs, hgvfs, re'
588 # Map of requirements to list of extensions to load automatically when
588 # Map of requirements to list of extensions to load automatically when
589 # requirement is present.
589 # requirement is present.
590 autoextensions = {
590 autoextensions = {
591 b'largefiles': [b'largefiles'],
591 b'lfs': [b'lfs'],
592 b'lfs': [b'lfs'],
592 }
593 }
593
594
@@ -1,6 +1,53 b''
1 This file contains testcases that tend to be related to special cases or less
1 This file contains testcases that tend to be related to special cases or less
2 common commands affecting largefile.
2 common commands affecting largefile.
3
3
4 $ hg init requirements
5 $ cd requirements
6
7 # largefiles not loaded by default.
8
9 $ hg config extensions
10 [1]
11
12 # Adding largefiles to requires file will auto-load largefiles extension.
13
14 $ echo largefiles >> .hg/requires
15 $ hg config extensions
16 extensions.largefiles=
17
18 # But only if there is no config entry for the extension already.
19
20 $ cat > .hg/hgrc << EOF
21 > [extensions]
22 > largefiles=!
23 > EOF
24
25 $ hg config extensions
26 abort: repository requires features unknown to this Mercurial: largefiles!
27 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
28 [255]
29
30 $ cat > .hg/hgrc << EOF
31 > [extensions]
32 > largefiles=
33 > EOF
34
35 $ hg config extensions
36 extensions.largefiles=
37
38 $ cat > .hg/hgrc << EOF
39 > [extensions]
40 > largefiles = missing.py
41 > EOF
42
43 $ hg config extensions
44 *** failed to import extension largefiles from missing.py: [Errno 2] $ENOENT$: 'missing.py'
45 abort: repository requires features unknown to this Mercurial: largefiles!
46 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
47 [255]
48
49 $ cd ..
50
4 Each sections should be independent of each others.
51 Each sections should be independent of each others.
5
52
6 $ USERCACHE="$TESTTMP/cache"; export USERCACHE
53 $ USERCACHE="$TESTTMP/cache"; export USERCACHE
@@ -220,10 +267,8 b' sharing a largefile repo automatically e'
220 getting changed largefiles
267 getting changed largefiles
221 1 largefiles updated, 0 removed
268 1 largefiles updated, 0 removed
222 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
269 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
223 $ cat ../shared_lfrepo/.hg/hgrc
270 $ grep largefiles ../shared_lfrepo/.hg/requires
224
271 largefiles
225 [extensions]
226 largefiles=
227
272
228 verify that large files in subrepos handled properly
273 verify that large files in subrepos handled properly
229 $ hg init subrepo
274 $ hg init subrepo
@@ -1206,12 +1206,12 b' rebased or not.'
1206 adding file changes
1206 adding file changes
1207 added 1 changesets with 2 changes to 2 files (+1 heads)
1207 added 1 changesets with 2 changes to 2 files (+1 heads)
1208 new changesets a381d2c8c80e (1 drafts)
1208 new changesets a381d2c8c80e (1 drafts)
1209 0 largefiles cached
1209 rebasing 8:f574fb32bb45 "modify normal file largefile in repo d"
1210 rebasing 8:f574fb32bb45 "modify normal file largefile in repo d"
1210 Invoking status precommit hook
1211 Invoking status precommit hook
1211 M sub/normal4
1212 M sub/normal4
1212 M sub2/large6
1213 M sub2/large6
1213 saved backup bundle to $TESTTMP/d/.hg/strip-backup/f574fb32bb45-dd1d9f80-rebase.hg
1214 saved backup bundle to $TESTTMP/d/.hg/strip-backup/f574fb32bb45-dd1d9f80-rebase.hg
1214 0 largefiles cached
1215 $ [ -f .hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 ]
1215 $ [ -f .hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 ]
1216 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
1216 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
1217 9:598410d3eb9a modify normal file largefile in repo d
1217 9:598410d3eb9a modify normal file largefile in repo d
@@ -203,21 +203,8 b' Clone main'
203 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
203 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
204
204
205 Largefiles is NOT enabled in the clone if the source repo doesn't require it
205 Largefiles is NOT enabled in the clone if the source repo doesn't require it
206 $ cat cloned/.hg/hgrc
206 $ grep largefiles cloned/.hg/hgrc
207 # example repository config (see 'hg help config' for more info)
207 [1]
208 [paths]
209 default = $TESTTMP/main
210
211 # path aliases to other clones of this repo in URLs or filesystem paths
212 # (see 'hg help config.paths' for more info)
213 #
214 # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
215 # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
216 # my-clone = /home/jdoe/jdoes-clone
217
218 [ui]
219 # name and email (local to this repository, optional), e.g.
220 # username = Jane Doe <jdoe@example.com>
221
208
222 Checking cloned repo ids
209 Checking cloned repo ids
223
210
@@ -790,29 +777,13 b' Find an exact largefile match in a large'
790 $ rm -rf ../archive_lf
777 $ rm -rf ../archive_lf
791
778
792 The local repo enables largefiles if a largefiles repo is cloned
779 The local repo enables largefiles if a largefiles repo is cloned
780
793 $ hg showconfig extensions
781 $ hg showconfig extensions
794 abort: repository requires features unknown to this Mercurial: largefiles!
782 extensions.largefiles=
795 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
783
796 [255]
797 $ hg --config extensions.largefiles= clone -qU . ../lfclone
784 $ hg --config extensions.largefiles= clone -qU . ../lfclone
798 $ cat ../lfclone/.hg/hgrc
785 $ grep largefiles ../lfclone/.hg/requires
799 # example repository config (see 'hg help config' for more info)
786 largefiles
800 [paths]
801 default = $TESTTMP/cloned
802
803 # path aliases to other clones of this repo in URLs or filesystem paths
804 # (see 'hg help config.paths' for more info)
805 #
806 # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
807 # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
808 # my-clone = /home/jdoe/jdoes-clone
809
810 [ui]
811 # name and email (local to this repository, optional), e.g.
812 # username = Jane Doe <jdoe@example.com>
813
814 [extensions]
815 largefiles=
816
787
817 Find an exact match to a standin (should archive nothing)
788 Find an exact match to a standin (should archive nothing)
818 $ hg --config extensions.largefiles= archive -S -I 'sub/sub2/.hglf/large.bin' ../archive_lf
789 $ hg --config extensions.largefiles= archive -S -I 'sub/sub2/.hglf/large.bin' ../archive_lf
General Comments 0
You need to be logged in to leave comments. Login now