( )⚙ D10734 narrow: widen when files are excluded by sparse and not included by narrow

This is an archive of the discontinued Mercurial Phabricator instance.

narrow: widen when files are excluded by sparse and not included by narrow
ClosedPublic

Authored by charlesetc on May 18 2021, 4:15 PM.

Details

Summary

In a repo where some directories are included by narrow and the complement are
excluded by sparse, it was previously impossible to widen either because trying
to widen narrow would complain that the requested files are outside the sparse
checkout and trying to widen sparse would complain that the requested files are
outside the narrow checkout.

This changes the hg tracked --addinclude command to only actually update any
newly accessible files in the dirstate if they are also accessible via sparse.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

charlesetc created this revision.May 18 2021, 4:15 PM
charlesetc retitled this revision from Enable widen when files are excluded by sparse and not included by narrow to narrow: widen when files are excluded by sparse and not included by narrow.May 18 2021, 4:18 PM

Without the change in narrowspec.py, the new test case fails at the first hg tracked with:

   $ hg tracked -q --addinclude outside/f
+  abort: cannot add 'outside/f' - it is outside the sparse checkout
+  (include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding)
+  [255]
martinvonz added inline comments.
tests/test-narrow-sparse.t
74–76

I was confused by this so I experimented a bit with it myself. It seems that it's hg debugsparse that fails. Could you update the text to clarify that? Alternatively, we could include coverage for the treemanifest case by manually updating .hg/sparse. I checked that that works, which was a bit of a relief (it seems less concerning if it's just the command for updating the sparse profile that fails).

charlesetc retitled this revision from narrow: widen when files are excluded by sparse and not included by narrow to Enable widen when files are excluded by sparse and not included by narrow.May 19 2021, 2:26 PM
charlesetc updated this revision to Diff 28129.
charlesetc retitled this revision from Enable widen when files are excluded by sparse and not included by narrow to narrow: widen when files are excluded by sparse and not included by narrow.May 19 2021, 2:30 PM
charlesetc added inline comments.May 19 2021, 2:30 PM
tests/test-narrow-sparse.t
74–76

I tried to word it more clearly, thanks! I'm not sure what you mean by 'manually updating .hg/sparse'.

martinvonz added inline comments.May 19 2021, 2:33 PM
tests/test-narrow-sparse.t
74–76

I mean this:

$ cat >> .hg/sparse <<EOF
> [exclude]
> outside/f 
> widest/f 
> EOF
charlesetc added inline comments.May 19 2021, 4:11 PM
tests/test-narrow-sparse.t
74–76

Ah I see. We would also have to remove the test of hg debugsparse -d outside/f which isn't working with tree manifest but is necessary to fully show we can widen.

charlesetc marked an inline comment as not done.May 19 2021, 4:11 PM
martinvonz accepted this revision.May 20 2021, 1:25 PM
martinvonz added inline comments.
tests/test-narrow-sparse.t
74–76

I see. I've never used sparse so I didn't understand what the point of the command was (I thought it was just to update .hg/sparse). Sounds good then. I'll queue this patch.

This revision is now accepted and ready to land.May 20 2021, 1:25 PM
charlesetc added inline comments.May 20 2021, 2:00 PM
tests/test-narrow-sparse.t
74–76

Ah yeah it also checks out the newly accessible files if any. Not sure if there's another way to do that. Thanks!

This change assumes the presence of the tree executable, which makes our CI fail. Please use find instead. I'll amend the changeset because it's a small amount of work.