Issue 2548 inconsistent pending after addfile f; rm f; mkdir f

Title inconsistent pending after addfile f; rm f; mkdir f
Priority urgent Status resolved
Milestone Resolved in
Superseder Nosy List bf
Assigned To

Created on 2017-09-10.13:11:22 by bf, last changed 2020-07-29.16:35:30 by bf.

File name Uploaded Type Edit Remove
resolve-issue2548_-inconsistent-pending.dpatch bf, 2018-06-13.18:03:36 text/x-darcs-patch
msg19657 (view) Author: bf Date: 2017-09-10.13:11:21
1. Summarise the issue (what were doing, what went wrong?)

repo1: create file f and record
repo2: create directory f and record
pull from repo1 into repo2
resolve the conflict by removing file f and renaming dir f.~0~ to f


1) darcs whatsnew reports no changes
2) revert -a therefore does nothing
3) but we still have a silent 'addfile f' in pending,
   which can be seen when doing darcs record
4) when we record -l, we get asked about addfile f *and* adddir f (!)
5) this is actually recorded as a patch that contains both changes

This is pretty bad. I will send a patch with a test script separately.
msg19659 (view) Author: bf Date: 2017-09-10.13:17:26
See patch1600 for the failing test script.
msg20153 (view) Author: bf Date: 2018-06-13.10:55:02
This bug is not about merge at all and is independent of the patch
format. The same buggy state can be reached by merely adding a file,
then removing it and creating a directory with the same name, both with
darcs-1 and darcs-2 format:

ben@yuiitsu[1]:/tmp/pending>darcs init
ben@yuiitsu[1]:/tmp/pending>touch f
ben@yuiitsu[1]:/tmp/pending>darcs add f
Adding 'f'
ben@yuiitsu[1]:/tmp/pending>rm f
ben@yuiitsu[1]:/tmp/pending>mkdir f
ben@yuiitsu[1]:/tmp/pending>darcs whatsnew -l
a ./f/
ben@yuiitsu[1]:/tmp/pending>cat _darcs/patches/pending
addfile ./f

This is inconsistent: the pending patch contradicts what is in the
working tree. If we record that state we get the bogus patch with both

ben@yuiitsu[1]:/tmp/pending>darcs record -lam bogus
Do you want to add a long comment? [yn]n
Finished recording patch 'bogus'
ben@yuiitsu[1]:/tmp/pending>darcs log -v
patch 9a476d6d4dda009b1bad9edd645df5b2a5dcccf4
Author: Ben Franksen <ben.franksen@online.de>
Date:   Wed Jun 13 11:37:10 CEST 2018
  * bogus
    addfile ./f
    adddir ./f

Will send an update to the test script.
msg20154 (view) Author: bf Date: 2018-06-13.18:03:36
I found the what causes this, but the fix (attached) reveals another

patch 7f3ab0fff5332c65713911c03dd64155df04c46f
Author: Ben Franksen <ben.franksen@online.de>
Date:   Wed Jun 13 19:50:34 CEST 2018
  * resolve issue2548: inconsistent pending
  In Darcs.Repository.Diff.treeDiff we did not correctly handle the case
  a file is changed to a subTree: we only emptied the file but failed to add
  an rmfile patch before adding the dir.
  With a pending "addfile ./f" and a working tree where f has been
changed to
  a directory, we now get only the "adddir ./f" when recording with -l.
  However, this leaves us with a new pending "rmdir ./f; addfile ./f". This
  pending change can be reverted but does not show up with whatsnew -l and
  cannot be recorded with record -l.
msg22282 (view) Author: bf Date: 2020-07-29.16:35:27
patch 940da5fdbc54e64875e3ef9a962e582cef9b0423
Author: Ben Franksen <ben.franksen@online.de>
Date:   Wed Jun 13 19:50:34 CEST 2018
  * resolve issue2548: inconsistent pending

The remaining problem mentioned in msg20154 has been fixed.
Date User Action Args
2017-09-10 13:11:23bfcreate
2017-09-10 13:17:27bfsetmessages: + msg19659
2018-06-13 10:55:04bfsetmessages: + msg20153
title: inconsistent pending after merge (darcs-2 only) -> inconsistent pending after addfile f; rm f; mkdir f
2018-06-13 18:03:38bfsetfiles: + resolve-issue2548_-inconsistent-pending.dpatch
messages: + msg20154
2020-07-29 16:35:30bfsetstatus: unknown -> resolved
messages: + msg22282