D4713: largefiles: automatically load largefiles extension when required (BC)
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Mon Sep 24 16:13:47 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This is very similar to what we just did for LFS but for largefiles.
See recent commit messages for the rationale here.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4713
AFFECTED FILES
hgext/largefiles/overrides.py
hgext/largefiles/uisetup.py
mercurial/localrepo.py
tests/test-largefiles-misc.t
tests/test-largefiles.t
tests/test-subrepo-deep-nested-change.t
CHANGE DETAILS
diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -203,21 +203,8 @@
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
Largefiles is NOT enabled in the clone if the source repo doesn't require it
- $ cat cloned/.hg/hgrc
- # example repository config (see 'hg help config' for more info)
- [paths]
- default = $TESTTMP/main
-
- # path aliases to other clones of this repo in URLs or filesystem paths
- # (see 'hg help config.paths' for more info)
- #
- # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
- # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
- # my-clone = /home/jdoe/jdoes-clone
-
- [ui]
- # name and email (local to this repository, optional), e.g.
- # username = Jane Doe <jdoe at example.com>
+ $ grep largefiles cloned/.hg/hgrc
+ [1]
Checking cloned repo ids
@@ -790,29 +777,13 @@
$ rm -rf ../archive_lf
The local repo enables largefiles if a largefiles repo is cloned
+
$ hg showconfig extensions
- abort: repository requires features unknown to this Mercurial: largefiles!
- (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
- [255]
+ extensions.largefiles=
+
$ hg --config extensions.largefiles= clone -qU . ../lfclone
- $ cat ../lfclone/.hg/hgrc
- # example repository config (see 'hg help config' for more info)
- [paths]
- default = $TESTTMP/cloned
-
- # path aliases to other clones of this repo in URLs or filesystem paths
- # (see 'hg help config.paths' for more info)
- #
- # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
- # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
- # my-clone = /home/jdoe/jdoes-clone
-
- [ui]
- # name and email (local to this repository, optional), e.g.
- # username = Jane Doe <jdoe at example.com>
-
- [extensions]
- largefiles=
+ $ grep largefiles ../lfclone/.hg/requires
+ largefiles
Find an exact match to a standin (should archive nothing)
$ hg --config extensions.largefiles= archive -S -I 'sub/sub2/.hglf/large.bin' ../archive_lf
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1206,12 +1206,12 @@
adding file changes
added 1 changesets with 2 changes to 2 files (+1 heads)
new changesets a381d2c8c80e (1 drafts)
+ 0 largefiles cached
rebasing 8:f574fb32bb45 "modify normal file largefile in repo d"
Invoking status precommit hook
M sub/normal4
M sub2/large6
saved backup bundle to $TESTTMP/d/.hg/strip-backup/f574fb32bb45-dd1d9f80-rebase.hg
- 0 largefiles cached
$ [ -f .hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 ]
$ hg log --template '{rev}:{node|short} {desc|firstline}\n'
9:598410d3eb9a modify normal file largefile in repo d
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -1,6 +1,53 @@
This file contains testcases that tend to be related to special cases or less
common commands affecting largefile.
+ $ hg init requirements
+ $ cd requirements
+
+# largefiles not loaded by default.
+
+ $ hg config extensions
+ [1]
+
+# Adding largefiles to requires file will auto-load largefiles extension.
+
+ $ echo largefiles >> .hg/requires
+ $ hg config extensions
+ extensions.largefiles=
+
+# But only if there is no config entry for the extension already.
+
+ $ cat > .hg/hgrc << EOF
+ > [extensions]
+ > largefiles=!
+ > EOF
+
+ $ hg config extensions
+ abort: repository requires features unknown to this Mercurial: largefiles!
+ (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
+ [255]
+
+ $ cat > .hg/hgrc << EOF
+ > [extensions]
+ > largefiles=
+ > EOF
+
+ $ hg config extensions
+ extensions.largefiles=
+
+ $ cat > .hg/hgrc << EOF
+ > [extensions]
+ > largefiles = missing.py
+ > EOF
+
+ $ hg config extensions
+ *** failed to import extension largefiles from missing.py: [Errno 2] $ENOENT$: 'missing.py'
+ abort: repository requires features unknown to this Mercurial: largefiles!
+ (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
+ [255]
+
+ $ cd ..
+
Each sections should be independent of each others.
$ USERCACHE="$TESTTMP/cache"; export USERCACHE
@@ -220,10 +267,8 @@
getting changed largefiles
1 largefiles updated, 0 removed
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
- $ cat ../shared_lfrepo/.hg/hgrc
-
- [extensions]
- largefiles=
+ $ grep largefiles ../shared_lfrepo/.hg/requires
+ largefiles
verify that large files in subrepos handled properly
$ hg init subrepo
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -588,6 +588,7 @@
# Map of requirements to list of extensions to load automatically when
# requirement is present.
autoextensions = {
+ b'largefiles': [b'largefiles'],
b'lfs': [b'lfs'],
}
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -126,7 +126,6 @@
_('download all versions of all largefiles'))]
entry[1].extend(cloneopt)
extensions.wrapfunction(hg, 'clone', overrides.hgclone)
- extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
entry = extensions.wrapcommand(commands.table, 'cat',
overrides.overridecat)
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -889,11 +889,6 @@
if not repo:
return result
- # If largefiles is required for this repo, permanently enable it locally
- if 'largefiles' in repo.requirements:
- repo.vfs.append('hgrc',
- util.tonativeeol('\n[extensions]\nlargefiles=\n'))
-
# Caching is implicitly limited to 'rev' option, since the dest repo was
# truncated at that point. The user may expect a download count with
# this option, so attempt whether or not this is a largefile repo.
@@ -905,14 +900,6 @@
return result
-def hgpostshare(orig, sourcerepo, destrepo, defaultpath=None):
- orig(sourcerepo, destrepo, defaultpath=defaultpath)
-
- # If largefiles is required for this repo, permanently enable it locally
- if 'largefiles' in destrepo.requirements:
- destrepo.vfs.append('hgrc',
- util.tonativeeol('\n[extensions]\nlargefiles=\n'))
-
def overriderebase(orig, ui, repo, **opts):
if not util.safehasattr(repo, '_largefilesenabled'):
return orig(ui, repo, **opts)
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list