InconsistentDelta by recreating a known ID in a new location

Bug #314251 reported by Charles Duffy (M1)
4
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Unassigned

Bug Description

Running against bzrlib 1.10rc1, the below reproducer results in the error shown:

###########################
$ python test.py
Standalone tree (format: pack-0.92)
Location:
  branch root: .
No handlers could be found for logger "bzr"
Traceback (most recent call last):
  File "/tmp/bzr-test/test.py", line 29, in <module>
    wt.commit(message='second commit')
  File "<string>", line 4, in commit_write_locked
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 235, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "<string>", line 4, in commit_write_locked
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 202, in commit
    *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 417, in commit
    self._basis_delta)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 1275, in update_basis_by_delta
    self.current_dirstate().update_basis_by_delta(delta, new_revid)
  File "/usr/lib/python2.5/site-packages/bzrlib/dirstate.py", line 1391, in update_basis_by_delta
    self._update_basis_apply_deletes(deletes)
  File "/usr/lib/python2.5/site-packages/bzrlib/dirstate.py", line 1497, in _update_basis_apply_deletes
    'The entry was considered a rename, but the source path'
bzrlib.errors.InconsistentDelta: An inconsistent delta was supplied involving 'file-A', 'id-A'
reason: The entry was considered a rename, but the source path is marked as absent.
###########################

###########################
#!/usr/bin/env python

import os
import tempfile
import shutil

import bzrlib.commands
import bzrlib.workingtree

temp_dir = tempfile.mkdtemp(prefix='bzr-test-dir')
try:
        # initial setup
        os.chdir(temp_dir)
        bzrlib.commands.run_bzr(['init', '.'])
        wt = bzrlib.workingtree.WorkingTree.open(temp_dir)
        # create a directory dir and a file dir/A
        f = open('file-A', 'w')
        f.write('A')
        f.close()
        wt.add(['file-A'], ids=['id-A'])
        wt.commit(message='initial commit', strict=True)
        # now remove and recreate, with id A on a file in location B (should be a move)
        wt.remove('file-A', force=True, keep_files=False)
        f = open('file-B', 'w')
        f.write('A')
        f.close()
        wt.add(['file-B'], ids=['id-A'])
        # and try to commit
        wt.commit(message='second commit')
finally:
        shutil.rmtree(temp_dir)
###########################

Martin Pool (mbp)
Changed in bzr:
importance: Undecided → High
status: New → Confirmed
description: updated
Revision history for this message
Charles Duffy (M1) (cduffy-messageone) wrote :

Running "bzr check" before the commit indicates that the tree is in a bad state:

[ 3522] 2009-01-06 17:05:40.210 INFO: Checking working tree at 'file:///tmp/bzr-test-dirtkmJUN/'.
0.181 Traceback (most recent call last):
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/commands.py", line 893, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/commands.py", line 839, in run_bzr
    ret = run(*run_argv)
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/commands.py", line 539, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/builtins.py", line 2533, in run
    check_dwim(path, verbose, do_branch=branch, do_repo=repo, do_tree=tree)
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/check.py", line 283, in check_dwim
    tree._check()
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/decorators.py", line 138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/workingtree.py", line 2495, in _check
    self._validate()
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/decorators.py", line 138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/workingtree_4.py", line 1269, in _validate
    self._dirstate._validate()
  File "/home/cduffy/public_html/bzr/bzr.cduffy.bug314251/bzrlib/dirstate.py", line 2677, in _validate
    (entry, previous_path, previous_loc))
AssertionError: entry (('', 'file-B', 'id-A'), [('f', '', 0, False, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'), ('a', '', 0, False, '')]) inconsistent with previous path None seen at 'file-A'

Revision history for this message
Charles Duffy (M1) (cduffy-messageone) wrote :

When the rename is done via the test script given here, entry[1][1][0:2] for file-B is ('a',''):
^@^@file-B^@id-A^@f^@^@0^@n^@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^@a^@^@0^@n^@^@

When the rename is done via bzr mv, entry[1][1][0:2] for file-B is ('r', 'file-A'):
^@^@file-B^@id-A^@f^@^@0^@n^@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^@r^@file-A^@0^@n^@^@

Manually tweaking this in the dirstate file results in "bzr check", and any subsequent commit, running smoothly.

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 314251] Re: InconsistentDelta by recreating a known ID in a new location

On Wed, 2009-01-07 at 02:56 +0000, Charles Duffy (M1) wrote:
> When the rename is done via the test script given here, entry[1][1][0:2] for file-B is ('a',''):
> ^@^@file-B^@id-A^@f^@^@0^@n^@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^@a^@^@0^@n^@^@
>
> When the rename is done via bzr mv, entry[1][1][0:2] for file-B is ('r', 'file-A'):
> ^@^@file-B^@id-A^@f^@^@0^@n^@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^@r^@file-A^@0^@n^@^@
>
> Manually tweaking this in the dirstate file results in "bzr check", and
> any subsequent commit, running smoothly.

So, my estimate of the problem is that 'add' with an explicit file id
needs to look for file_id in the other trees to correctly set relocated
paths.

-Rob

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Charles Duffy (M1) (cduffy-messageone) wrote :

Patch attached; also sent to the mailing list.

Jelmer Vernooij (jelmer)
Changed in bzr:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.