Patchwork [1,of,2] tests: demonstrate inconsistencies with dirty state in various commands

login
register
mail settings
Submitter Matt Harbison
Date July 3, 2017, 2:50 a.m.
Message ID <0fcbcb681899ad44a333.1499050220@Envy>
Download mbox | patch
Permalink /patch/21943/
State Accepted
Headers show

Comments

Matt Harbison - July 3, 2017, 2:50 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1498699846 14400
#      Wed Jun 28 21:30:46 2017 -0400
# Node ID 0fcbcb681899ad44a33380788750ea375aa70864
# Parent  8ad015cc20a1feaf1f55b86ba6fb80d0b617d0ef
tests: demonstrate inconsistencies with dirty state in various commands

Not only is the output of these commands inconsistent with respect to each
other when a file is deleted, they are internally inconsistent depending upon
whether the deleted file is in the top level repo or a subrepo.  It seemed
easier to show the problems, rather than describe them.  The original goal was
to fix the summary command with respect to deleted files.  I haven't fixed any
of the other issues yet, in case anybody believes the current subrepo behavior
is correct.

I think a natural understanding of clean/dirty is that they are two opposite
values of a single binary repo state.  If `hg update --clean -r .` changes a
file, then naturally that repo was dirty, and `hg update --check` should have
blocked it.  Deleted files are special, in that they don't block a commit.  But
they make the filesystem content not the same as a clean checkout.
Yuya Nishihara - July 3, 2017, 1:53 p.m.
On Sun, 02 Jul 2017 22:50:20 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1498699846 14400
> #      Wed Jun 28 21:30:46 2017 -0400
> # Node ID 0fcbcb681899ad44a33380788750ea375aa70864
> # Parent  8ad015cc20a1feaf1f55b86ba6fb80d0b617d0ef
> tests: demonstrate inconsistencies with dirty state in various commands

Queued this, thanks.

Patch

diff --git a/tests/test-merge-subrepos.t b/tests/test-merge-subrepos.t
--- a/tests/test-merge-subrepos.t
+++ b/tests/test-merge-subrepos.t
@@ -23,3 +23,97 @@ 
   $ 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]