diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -1208,7 +1208,16 @@ sub = ctx.workingsub(subpath) submatch = matchmod.subdirmatcher(subpath, match) subprefix = prefix + subpath + b'/' - with lfstatus(sub._repo): + + # TODO: Only hgsubrepo instances have `_repo`, so figure out how to + # infer and possibly set lfstatus in hgsubrepoarchive. That would + # allow only hgsubrepos to set this, instead of the current scheme + # where the parent sets this for the child. + with ( + util.safehasattr(sub, '_repo') + and lfstatus(sub._repo) + or util.nullcontextmanager() + ): sub.archive(archiver, subprefix, submatch) archiver.done() @@ -1266,7 +1275,15 @@ sub = ctx.workingsub(subpath) submatch = matchmod.subdirmatcher(subpath, match) subprefix = prefix + subpath + b'/' - with lfstatus(sub._repo): + # TODO: Only hgsubrepo instances have `_repo`, so figure out how to + # infer and possibly set lfstatus at the top of this function. That + # would allow only hgsubrepos to set this, instead of the current scheme + # where the parent sets this for the child. + with ( + util.safehasattr(sub, '_repo') + and lfstatus(sub._repo) + or util.nullcontextmanager() + ): sub.archive(archiver, subprefix, submatch, decode) diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t --- a/tests/test-subrepo-git.t +++ b/tests/test-subrepo-git.t @@ -376,6 +376,15 @@ a s/g + $ hg -R ../tc archive -S ../lf_archive.tgz --prefix '.' \ + > --config extensions.largefiles= 2>/dev/null + $ tar -tzf ../lf_archive.tgz | sort | grep -v pax_global_header + .hg_archival.txt + .hgsub + .hgsubstate + a + s/g + create nested repo $ cd ..