Mercurial > hg
comparison hgext/largefiles/overrides.py @ 44015:7ca8aa8840c0 stable
subrepo: fix a crash when archiving an svn or git subrepo
Only hgsubrepos have a repository attribute. This is pretty hacky, but probably
the best we can do on stable. Pushing the lfstatus check down into the wrapper
for hgsubrepo (and dropping the check for lfstatus at the top of
`hgsubrepoarchive()`) resulted in various test failures because:
1) hgsubrepoarchive isn't returning the number of files archived at the
bottom, resulting in an error about += NoneType
2) These copypasta archive wrappers don't use progress bars
3) Largefiles are *not* currently archived when using extdiff (68822b7cdd01),
but pushing this context manager down into the subrepo resulted in it
apparently doing so (as evidenced by progress bars being dropped)
The other uses of `lfstatus()` are not in the substate processing loop, so they
shouldn't be an issue.
I initially put testcases in this test for largefiles-{on,off}, and it flagged
a bunch of exit code differences for `cat` and `diff`, so I backed that off.
Differential Revision: https://phab.mercurial-scm.org/D7714
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 24 Dec 2019 01:38:02 -0500 |
parents | 2cb787b65cf2 |
children | 84a0102c05c7 |
comparison
equal
deleted
inserted
replaced
43999:b89144b81c5d | 44015:7ca8aa8840c0 |
---|---|
1206 if subrepos: | 1206 if subrepos: |
1207 for subpath in sorted(ctx.substate): | 1207 for subpath in sorted(ctx.substate): |
1208 sub = ctx.workingsub(subpath) | 1208 sub = ctx.workingsub(subpath) |
1209 submatch = matchmod.subdirmatcher(subpath, match) | 1209 submatch = matchmod.subdirmatcher(subpath, match) |
1210 subprefix = prefix + subpath + b'/' | 1210 subprefix = prefix + subpath + b'/' |
1211 with lfstatus(sub._repo): | 1211 |
1212 # TODO: Only hgsubrepo instances have `_repo`, so figure out how to | |
1213 # infer and possibly set lfstatus in hgsubrepoarchive. That would | |
1214 # allow only hgsubrepos to set this, instead of the current scheme | |
1215 # where the parent sets this for the child. | |
1216 with ( | |
1217 util.safehasattr(sub, '_repo') | |
1218 and lfstatus(sub._repo) | |
1219 or util.nullcontextmanager() | |
1220 ): | |
1212 sub.archive(archiver, subprefix, submatch) | 1221 sub.archive(archiver, subprefix, submatch) |
1213 | 1222 |
1214 archiver.done() | 1223 archiver.done() |
1215 | 1224 |
1216 | 1225 |
1264 | 1273 |
1265 for subpath in sorted(ctx.substate): | 1274 for subpath in sorted(ctx.substate): |
1266 sub = ctx.workingsub(subpath) | 1275 sub = ctx.workingsub(subpath) |
1267 submatch = matchmod.subdirmatcher(subpath, match) | 1276 submatch = matchmod.subdirmatcher(subpath, match) |
1268 subprefix = prefix + subpath + b'/' | 1277 subprefix = prefix + subpath + b'/' |
1269 with lfstatus(sub._repo): | 1278 # TODO: Only hgsubrepo instances have `_repo`, so figure out how to |
1279 # infer and possibly set lfstatus at the top of this function. That | |
1280 # would allow only hgsubrepos to set this, instead of the current scheme | |
1281 # where the parent sets this for the child. | |
1282 with ( | |
1283 util.safehasattr(sub, '_repo') | |
1284 and lfstatus(sub._repo) | |
1285 or util.nullcontextmanager() | |
1286 ): | |
1270 sub.archive(archiver, subprefix, submatch, decode) | 1287 sub.archive(archiver, subprefix, submatch, decode) |
1271 | 1288 |
1272 | 1289 |
1273 # If a largefile is modified, the change is not reflected in its | 1290 # If a largefile is modified, the change is not reflected in its |
1274 # standin until a commit. cmdutil.bailifchanged() raises an exception | 1291 # standin until a commit. cmdutil.bailifchanged() raises an exception |