sapling/tests/test-merge-subrepos.t
Jun Wu effa0da8de test-helpers: add a helper to run test using chg
Summary:
The helper could be used in individual tests to enable chg if chg exists.
This allows us to have more precise control on what tests to use chg instead
of using a global flag in run-tests.py.

This makes certain tests containing many hg commands much faster. For example,
`test-revset.t` took 99 seconds before:

  % ./run-tests.py test-revset.t --time
  .
  # Ran 1 tests, 0 skipped, 0 failed.
  # Producing time report
  start   end     cuser   csys    real      Test
    0.000  99.990  86.410  12.000  99.990   test-revset.t

And 10 seconds after:

  % ./run-tests.py test-revset.t --time
  .
  # Ran 1 tests, 0 skipped, 0 failed.
  # Producing time report
  start   end     cuser   csys    real      Test
    0.000  10.080   0.380   0.130  10.080   test-revset.t

Also enable it for some other tests. Note the whitelist is not complete.  We
probably want to whitelist more tests in the future.

The feature could be opted out by deleting `contrib/chg/chg`.

Reviewed By: phillco

Differential Revision: D6767036

fbshipit-source-id: 8220cf408aa198d5d8e2ca5127ca60e2070d3444
2018-04-13 21:50:54 -07:00

140 lines
3.4 KiB
Perl

$ . helpers-usechg.sh
$ 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'
$ 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'
$ echo change > subrepo/b
$ hg ci -Sm 'change b'
committing subrepository subrepo
$ rm a
$ hg id
9bfe45a197d7+ tip
$ hg sum
parent: 4:9bfe45a197d7 tip
change b
branch: default
commit: 1 deleted (clean)
update: 1 new changesets, 2 branch heads (merge)
phases: 5 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
A deleted subrepo file is flagged as dirty, like the top level repo
$ hg id --config extensions.blackbox= --config blackbox.dirty=True
9bfe45a197d7+ tip
$ cat .hg/blackbox.log
* @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> serve --cmdserver chgunix * (glob) (chg !)
* @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> id --config *extensions.blackbox=* --config *blackbox.dirty=True* (glob)
* @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> id --config *extensions.blackbox=* --config *blackbox.dirty=True* exited 0 * (glob)
TODO: a deleted file should be listed as such, like the top level repo
$ hg sum
parent: 4:9bfe45a197d7 tip
change b
branch: default
commit: (clean)
update: 1 new changesets, 2 branch heads (merge)
phases: 5 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: 4:9bfe45a197d7 tip
change b
branch: default
commit: 1 subrepos
update: 1 new changesets, 2 branch heads (merge)
phases: 5 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
`hg update --check` notices a subrepo with a missing file, like it notices a
missing file in the top level repo.
$ hg up -r '.^' --check
abort: uncommitted changes in subrepository "subrepo"
[255]
$ hg up -r '.^' --config ui.interactive=True << EOF
> d
> EOF
other [destination] changed b which local [working copy] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? d
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
XXX: There's a difference between wdir() and '.', so there should be a status.
`hg files -S` from the top is also missing 'subrepo/b'.
$ hg st -S
$ hg st -R subrepo
$ hg files -R subrepo
[1]
$ hg files -R subrepo -r '.'
subrepo/b
$ hg bookmark -r tip @other
$ echo xyz > subrepo/c
$ hg ci -SAm 'add c'
adding subrepo/c
committing subrepository subrepo
$ rm subrepo/c
Merge sees deleted subrepo files as an uncommitted change
$ hg merge @other
abort: uncommitted changes in subrepository "subrepo"
[255]