"bzr branch -r nnn" fails because of ghost revision

Bug #248540 reported by Tom Cato Amundsen
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Jelmer Vernooij

Bug Description

Yet another ghost revision bug.
The repository checked was on my local disk, but it is mirrored as http://www.solfege.org/bzr/solfege.dev

tom@tomsin-laptop:~/tmp/bzr/bzr.dev$ ./bzr check /home/tom/src/solfege.repo/solfege.dev
/home/tom/.bazaar/plugins/bzr_cia/__init__.py:204: DeprecationWarning: bzrlib.branch.BranchHooks.install_hook was deprecated in version 1.5.
  Branch.hooks.install_hook('post_commit', branch_commit_hook)
Checking repository at 'file:///home/tom/src/solfege.repo/'.
checked repository <bzrlib.transport.local.LocalTransport url=file:///home/tom/src/solfege.repo/> format <RepositoryFormatKnitPack1>
  1203 revisions
  1432 file-ids
  7174 unique file texts
1176939 repeated file texts
     0 unreferenced text versions
     3 ghost revisions
     3 revisions missing parents in ancestry
   814 inconsistent parents
Checking branch at 'file:///home/tom/src/solfege.repo/solfege.dev/'.
bzr: ERROR: exceptions.KeyError: 'Arch-1:<email address hidden>%solfege--unstable--3.1--version-0'

Traceback (most recent call last):
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/commands.py", line 857, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/builtins.py", line 2312, in run
    check_dwim(path, verbose)
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/check.py", line 299, in check_dwim
    check_branch(branch, verbose)
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/check.py", line 266, in check_branch
    branch_result = branch.check()
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/decorators.py", line 138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/branch.py", line 778, in check
    real_rev_history = list(self.repository.iter_reverse_revision_history(
  File "/home/tom/tmp/bzr/bzr.dev/bzrlib/repository.py", line 1595, in iter_reverse_revision_history
    parents = graph.get_parent_map([next_id])[next_id]
KeyError: 'Arch-1:<email address hidden>%solfege--unstable--3.1--version-0'

bzr 1.6b3 on python 2.4.5 (linux2)
arguments: ['./bzr', 'check', '/home/tom/src/solfege.repo/solfege.dev']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'nb_NO.UTF-8'
plugins:
  bzr_cia /home/tom/.bazaar/plugins/bzr_cia [1.0.0dev0]
  bzrtools /home/tom/.bazaar/plugins/bzrtools [1.2.0]
  launchpad /home/tom/tmp/bzr/bzr.dev/bzrlib/plugins/launchpad [unknown]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Tags: ghosts

Related branches

Revision history for this message
James Westby (james-w) wrote : Re: [Bug 248540] [NEW] bzr check fails because of ghost revision

On Mon, 2008-07-14 at 22:04 +0000, Tom Cato Amundsen wrote:
> Public bug reported:
>
> Yet another ghost revision bug.
> The repository checked was on my local disk, but it is mirrored as http://www.solfege.org/bzr/solfege.dev
>

And quoth the source:

  # Note: The following line may raise KeyError in the event of
  # truncated history. We decided not to have a try:except:raise
  # RevisionNotPresent here until we see a use for it, because of the
  # cost in an inner loop that is by its very nature O(history).
  # Robert Collins 20080326
  parents = graph.get_parent_map([next_id])[next_id]

Thanks,

James

Revision history for this message
Tom Cato Amundsen (tca) wrote : Re: bzr check fails because of ghost revision

The patch below seems to work. But I don't understand bzr internals, so I cannot say if this is correct. I compared the output of "bzr selftest" before and after applying this, and it does not break any new tests.

=== modified file 'bzrlib/repository.py'
--- bzrlib/repository.py 2008-07-14 16:16:48 +0000
+++ bzrlib/repository.py 2008-07-15 21:25:40 +0000
@@ -1592,7 +1592,10 @@
             # RevisionNotPresent here until we see a use for it, because of the
             # cost in an inner loop that is by its very nature O(history).
             # Robert Collins 20080326
- parents = graph.get_parent_map([next_id])[next_id]
+ try:
+ parents = graph.get_parent_map([next_id])[next_id]
+ except KeyError:
+ raise errors.RevisionNotPresent(next_id, self)
             if len(parents) == 0:
                 return
             else:

Revision history for this message
Tom Cato Amundsen (tca) wrote :

With bzr 3.8 or 3.10.0, the ghost revisions bites me when I want to branch. It does not matter if I specify the revision by tag or revision number. But a checkout works ok.

tom@tomsin-laptop:~/src$ bzr branch -r tag:solfege-3.12.0 ~/src/solfege.repo/solfege.dev/ solfege-3.12
bzr: ERROR: exceptions.KeyError: 'Arch-1:<email address hidden>%solfege--unstable--3.1--version-0'

Traceback (most recent call last):
  File "/home/tom/lib/python/bzrlib/commands.py", line 893, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/tom/lib/python/bzrlib/commands.py", line 839, in run_bzr
    ret = run(*run_argv)
  File "/home/tom/lib/python/bzrlib/commands.py", line 539, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/tom/lib/python/bzrlib/builtins.py", line 981, in run
    source_branch=br_from)
  File "/home/tom/lib/python/bzrlib/bzrdir.py", line 1133, in sprout
    source_branch.copy_content_into(result_branch, revision_id)
  File "/home/tom/lib/python/bzrlib/decorators.py", line 138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/home/tom/lib/python/bzrlib/branch.py", line 745, in copy_content_into
    self._synchronize_history(destination, revision_id)
  File "/home/tom/lib/python/bzrlib/branch.py", line 2141, in _synchronize_history
    Branch._synchronize_history(self, destination, revision_id)
  File "/home/tom/lib/python/bzrlib/branch.py", line 735, in _synchronize_history
    revision_id)))
  File "/home/tom/lib/python/bzrlib/repository.py", line 1652, in iter_reverse_revision_history
    parents = graph.get_parent_map([next_id])[next_id]
KeyError: 'Arch-1:<email address hidden>%solfege--unstable--3.1--version-0'

bzr 1.10 on python 2.5.2 (linux2)
arguments: ['/home/tom/bin/bzr', 'branch', '-r', 'tag:solfege-3.12.0', '/home/tom/src/solfege.repo/solfege.dev/', 'solfege-3.12']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'nb_NO.UTF-8'
plugins:
  bzrtools /home/tom/.bazaar/plugins/bzrtools [1.10]
  cia /home/tom/.bazaar/plugins/cia [1.0dev]
  launchpad /home/tom/lib/python/bzrlib/plugins/launchpad [unknown]
  upload /home/tom/.bazaar/plugins/upload [0.1]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Revision history for this message
Tom Cato Amundsen (tca) wrote :

The try-except-block in comment #2 above is not enough to make "bzr branch -r 898" work:
bzr: ERROR: Revision {Arch-1:<email address hidden>%solfege--unstable--3.1--version-0} not present in "KnitPackRepository('file:///home/tom/src/solfege.repo/.bzr/repository/')"

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

My branch fixes the original issue and "bzr check" with a ghost in the mainline. It does not yet fix "bzr reconcile".

Changed in bzr:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

patch submitted to the list

Changed in bzr:
assignee: nobody → Jelmer Vernooij (jelmer)
status: Triaged → Fix Committed
Jelmer Vernooij (jelmer)
Changed in bzr:
status: Fix Committed → 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.