This should repair a branch.

import bzrlib.branch
from bzrlib.revision import NULL_REVISION
b = bzrlib.branch.Branch.open(argv[1])

def main():
    b.lock_read()
    if not b.repository._fallback_repositories:
        return
    raw_r = b.repository.bzrdir.open_repository()
    raw_r.lock_write()
    try:
      revs = raw_r.all_revision_ids()
      rev_parents = raw_r.get_graph().get_parent_map(revs)
      needed = set()
      map(needed.update, rev_parents.itervalues())
      needed.discard(NULL_REVISION)
      needed = set((rev,) for rev in needed)
      needed = needed - raw_r.inventories.keys()
      print "Missing inventories: %r" % needed
      if not needed:
        return
      assert raw_r._format.network_name() ==
b.repository._format.network_name()
      stream = b.repository.inventories.get_record_stream(needed,
'topological', True)
      raw_r.start_write_group()
      try:
        raw_r.inventories.insert_recort_stream(stream)
      except:
        raw_r.abort_write_group()
        raise
      else:
        raw_r.commit_write_group()
    finally:
      raw_r.unlock()

main()



** Attachment added: "foo.py"
   http://launchpadlibrarian.net/25841405/foo.py

-- 
ErrorFromSmartServer - AbsentContentFactory object has no attribute 
'get_bytes_as' exception while pulling from Launchpad
https://bugs.launchpad.net/bugs/354036
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to