"bzr update" in checkout of empty branch fails and breaks dirstate

Bug #120968 reported by Andrew Bennetts
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Unassigned

Bug Description

The following shell script:

"""
# Make a branch with zero revisions.
bzr init master
# Check it out
bzr co master slave
# Make a local commit
cd slave
bzr ci --local --unchanged -m "Empty commit."
# Update. Boom!
bzr update
"""

Will trigger the following traceback:

bzr: ERROR: exceptions.TypeError: sequence item 1: expected string, NoneType found

Traceback (most recent call last):
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 717, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 678, in run_bzr
    ret = run(*run_argv)
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 375, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/andrew/code/bzr/bzrlib/builtins.py", line 1045, in run
    tree.unlock()
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 1119, in unlock
    self.flush()
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 311, in flush
    self.current_dirstate().save()
  File "/home/andrew/code/bzr/bzrlib/dirstate.py", line 1728, in save
    self._state_file.writelines(self.get_lines())
  File "/home/andrew/code/bzr/bzrlib/dirstate.py", line 1221, in get_lines
    lines.append(self._get_parents_line(self.get_parent_ids()))
  File "/home/andrew/code/bzr/bzrlib/dirstate.py", line 1233, in _get_parents_line
    return '\0'.join([str(len(parent_ids))] + parent_ids)
TypeError: sequence item 1: expected string, NoneType found

bzr 0.18.0dev0 on python 2.5.1.final.0 (linux2)
arguments: ['/home/andrew/code/bzr/bzr', 'update']

I've reproduced this with current bzr.dev.

A use case that prompts this is An obvious way to create a start a branch for a new project that you want to host remotely is to "bzr init REMOTE_URL" then immediately "bzr checkout REMOTE_URL LOCAL_CHECKOUT".

A workaround would be to do "bzr init LOCAL_CHECKOUT", and once there's at least one revision there, then do "bzr push REMOTE_URL; bzr bind" to create the remote branch and convert the local branch into a checkout.

Tags: dirstate
Revision history for this message
Mary Gardiner (puzzlement) wrote :

subscribe

Revision history for this message
Wouter van Heyst (larstiq) wrote : Re: "bzr update" in checkout of empty branch tracebacks

Same symptom as 127115, different cause.

Changed in bzr:
assignee: nobody → larstiq
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Martin Pool (mbp) wrote :

What's worse is that this also seems to do an incorrect merge against the empty revision, causing any locally added files to be deleted.

Changed in bzr:
importance: Medium → High
Revision history for this message
Martin Pool (mbp) wrote :

bug 127115 is now fixed, but as of 0.91 this one is not.

Revision history for this message
Martin Pool (mbp) wrote :

bug 127115 is now fixed, but as of 0.91 this one is not.

There is a workaround for this: do a blank (or non-blank) commit on the main branch before doing the local commits.

Revision history for this message
James Westby (james-w) wrote : Re: TypeError: sequence item 1: expected string, NoneType found

On (14/09/07 16:54), Martin Pool wrote:
> This is https://bugs.launchpad.net/bzr/+bug/120968 "bzr update" in
> checkout of empty branch fails and breaks dirstate

The sequence at the top now fails with the following error instead:

All changes applied successfully.
bzr: ERROR: bzrlib.errors.ReservedId: Reserved revision-id {null:}

Traceback (most recent call last):
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/commands.py", line 800, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/builtins.py", line 1039, in run
    possible_transports=possible_transports)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/workingtree.py", line 2061, in update
    return self._update_tree(old_tip, change_reporter)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/mutabletree.py", line 50, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/workingtree.py", line 2119, in _update_tree
    self.set_parent_trees(parent_trees)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/mutabletree.py", line 50, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/workingtree_4.py", line 1099, in set_parent_trees
    _mod_revision.check_not_reserved_id(rev_id)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/revision.py", line 451, in check_not_reserved_id
    raise errors.ReservedId(revision_id)
ReservedId: Reserved revision-id {null:}

presumably with Aaron's null: changes.

Here is a testcase to exercise this bug:

=== modified file 'bzrlib/tests/blackbox/test_update.py'
--- bzrlib/tests/blackbox/test_update.py 2007-08-08 02:01:10 +0000
+++ bzrlib/tests/blackbox/test_update.py 2007-09-14 16:36:30 +0000
@@ -210,3 +210,11 @@
                                                    lightweight=True)
         tree.commit('empty commit')
         self.run_bzr('update checkout')
+
+ def test_update_checkout_of_empty_branch(self):
+ """Run update in a checkout of an empty branch: #438137."""
+ tree = self.make_branch_and_tree('branch')
+ checkout = tree.branch.create_checkout('checkout', lightweight=False)
+ checkout.commit('empty commit', local=True)
+ self.run_bzr('update checkout')
+

--
  James Westby -- GPG Key ID: B577FE13 -- http://jameswestby.net/
  seccure key - (3+)k7|M*edCX/.A:n*N!>|&7U.L#9E)Tu)T0>AM - secp256r1/nistp256

Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> On (14/09/07 16:54), Martin Pool wrote:
>> This is https://bugs.launchpad.net/bzr/+bug/120968 "bzr update" in
>> checkout of empty branch fails and breaks dirstate
> ReservedId: Reserved revision-id {null:}
>
> presumably with Aaron's null: changes.

The error here is correct; if the parent is null, you should do
set_parent_trees([]).

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6scF0F+nu1YWqI0RAgu6AJ4l3wDz9tdfUigwHzjrDdFI6k4IfACggQQP
S7IaIbRLXJOnQ8bUHvDdK8g=
=Fiu2
-----END PGP SIGNATURE-----

Revision history for this message
Wouter van Heyst (larstiq) wrote :

This seems to work fine with 1.5, I'll get back to checking up and closing it after reporting a related bug.

Revision history for this message
Otaci Martins (otaci) wrote :

Same problem to me.

My specs:

- Bazaar 1.9
- Fedora 10
- Kernel 2.6.27.7-134

Steps:

In central host:

    # bzr init-repo myprojetc
    # cd myproject
    # bzr init trunk

In developer's laptop:

     # bzr init-repo myproject
     # cd myproject
     # bzr branch sftp://centralhost/projects/myproject/trunk
     # bzr branch trunk v1.0
     # cd v1.0
     # (hack, hack, hack)
     # bzr commit
     # cd ../trunk
     # bzr pull
     # bzr merge ../v1.0
     # bzr status
         working tree is out of date, run 'bzr update'
      # bzr update
          (deletes some files)
          bzr: ERROR: Reserved revision-id {null:}

Changed in bzr:
assignee: Wouter van Heyst (larstiq) → nobody
status: In Progress → Confirmed
tags: added: dirstate
Revision history for this message
Robert Collins (lifeless) wrote :

Don't know how, don't know who, don't know when, but the sample snippet works.

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.