tests/test-merge-subrepos.t
author Matt Harbison <matt_harbison@yahoo.com>
Sun, 09 Jul 2017 00:05:31 -0400
changeset 33359 583aa1e3658b
parent 33198 439b4d005b4a
child 33364 bf2daeddd42b
permissions -rw-r--r--
tests: tweak the subrepo dirty state tests This is a continuation of 439b4d005b4a. I overlooked that blackbox logs also have a dirty marker. Also, the `hg update --check` test was updating to a revision where the deleted file wasn't tracked, which is why status seemed to show the deleted file was restored.

  $ 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'
  $ 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

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

  $ hg id --config extensions.blackbox= --config blackbox.dirty=True
  9bfe45a197d7 tip
  $ cat .hg/blackbox.log
  * @9bfe45a197d7b0ab09bf287729dd57e9619c9da5 (*)> id (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

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

  $ hg up -r '.^' --check --config ui.interactive=True << EOF
  > c
  > EOF
  other [destination] changed b which local [working copy] deleted
  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ 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: de222c2e1eac, remote revision: 7d3f8eba8116)
  (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]