view tests/test-merge-subrepos.t @ 33289:abd7dedbaa36

sparse: vendor Facebook-developed extension Facebook has developed an extension to enable "sparse" checkouts - a working directory with a subset of files. This feature is a critical component in enabling repositories to scale to infinite number of files while retaining reasonable performance. It's worth noting that sparse checkout is only one possible solution to this problem: another is virtual filesystems that realize files on first access. But given that virtual filesystems may not be accessible to all users, sparse checkout is necessary as a fallback. Per mailing list discussion at https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/095868.html we want to add sparse checkout to the Mercurial distribution via roughly the following mechanism: 1. Vendor extension as-is with minimal modifications (this patch) 2. Refactor extension so it is more clearly experimental and inline with Mercurial practices 3. Move code from extension into core where possible 4. Drop experimental labeling and/or move feature into core after sign-off from narrow clone feature owners This commit essentially copies the sparse extension and tests from revision 71e0a2aeca92a4078fe1b8c76e32c88ff1929737 of the https://bitbucket.org/facebook/hg-experimental repository. A list of modifications made as part of vendoring is as follows: * "EXPERIMENTAL" added to module docstring * Imports were changed to match Mercurial style conventions * "testedwith" value was updated to core Mercurial special value and comment boilerplate was inserted * A "clone_sparse" function was renamed to "clonesparse" to appease the style checker * Paths to the sparse extension in tests reflect built-in location * test-sparse-extensions.t was renamed to test-sparse-fsmonitor.t and references to "simplecache" were removed. The test always skips because it isn't trivial to run it given the way we currently run fsmonitor tests * A double empty line was removed from test-sparse-profiles.t There are aspects of the added code that are obviously not ideal. The goal is to make a minimal number of modifications as part of the vendoring to make it easier to track changes from the original implementation. Refactoring will occur in subsequent patches.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 01 Jul 2017 10:43:29 -0700
parents 439b4d005b4a
children 583aa1e3658b
line wrap: on
line source

  $ hg init

  $ echo a > a
  $ hg ci -qAm 'add a'

  $ hg init subrepo
  $ echo 'subrepo = http://example.net/libfoo' > .hgsub
  $ hg ci -qAm 'added subrepo'

  $ hg up -qC 0
  $ echo ax > a
  $ hg ci -m 'changed a'
  created new head

  $ hg up -qC 1
  $ cd subrepo
  $ echo b > b
  $ hg add b
  $ cd ..

Should fail, since there are added files to subrepo:

  $ hg merge
  abort: uncommitted changes in subrepository 'subrepo'
  [255]

Deleted files trigger a '+' marker in top level repos.  Deleted files are also
noticed by `update --check` in the top level repo.

  $ hg ci -Sqm 'add b'
  $ rm a
  $ hg id
  cb66ec850af7+ tip
  $ hg sum
  parent: 3:cb66ec850af7 tip
   add b
  branch: default
  commit: 1 deleted (clean)
  update: 1 new changesets, 2 branch heads (merge)
  phases: 4 draft

  $ hg up --check -r '.^'
  abort: uncommitted changes
  [255]
  $ hg st -S
  ! a
  $ hg up -Cq .

Test that dirty is consistent through subrepos

  $ rm subrepo/b

TODO: a deleted subrepo file should be flagged as dirty, like the top level repo

  $ hg id
  cb66ec850af7 tip

TODO: a deleted file should be listed as such, like the top level repo

  $ hg sum
  parent: 3:cb66ec850af7 tip
   add b
  branch: default
  commit: (clean)
  update: 1 new changesets, 2 branch heads (merge)
  phases: 4 draft

Modified subrepo files are noticed by `update --check` and `summary`

  $ echo mod > subrepo/b
  $ hg st -S
  M subrepo/b

  $ hg up -r '.^' --check
  abort: uncommitted changes in subrepository 'subrepo'
  [255]

  $ hg sum
  parent: 3:cb66ec850af7 tip
   add b
  branch: default
  commit: 1 subrepos
  update: 1 new changesets, 2 branch heads (merge)
  phases: 4 draft

TODO: why is -R needed here?  If it's because the subrepo is treated as a
discrete unit, then this should probably warn or something.
  $ hg revert -R subrepo --no-backup subrepo/b -r .

  $ rm subrepo/b
  $ hg st -S
  ! subrepo/b

TODO: --check should notice a subrepo with a missing file.  It already notices
a modified file.

  $ hg up -r '.^' --check
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

TODO: update without --clean shouldn't restore a deleted subrepo file, since it
doesn't restore a deleted top level repo file.
  $ hg st -S

  $ hg bookmark -r tip @other
  $ echo xyz > subrepo/c
  $ hg ci -SAm 'add c'
  adding subrepo/c
  committing subrepository subrepo
  created new head
  $ rm subrepo/c

Merge sees deleted subrepo files as an uncommitted change

  $ hg merge @other
   subrepository subrepo diverged (local revision: 2b4750dcc93f, remote revision: cde40f86152f)
  (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
  abort: uncommitted changes (in subrepo subrepo)
  (use 'hg status' to list changes)
  [255]