Skip to content

Commit

Permalink
[merge] make sure to get all text revisions during merge (aaron)
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Nov 22, 2005
2 parents e21afba + 614c4a3 commit 84b4db4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
1 change: 0 additions & 1 deletion bzrlib/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def branch_files(file_list, default_branch='.'):
try:
return inner_branch_files(file_list, default_branch)
except FileInWrongBranch, e:
print file_list
raise BzrCommandError("%s is not in the same branch as %s" %
(e.path, file_list[0]))

Expand Down
22 changes: 13 additions & 9 deletions bzrlib/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Check(object):

def __init__(self, branch):
self.branch = branch
self.inventory_weave = branch._get_inventory_weave()
self.checked_text_cnt = 0
self.checked_rev_cnt = 0
self.ghosts = []
Expand All @@ -54,24 +55,27 @@ def __init__(self, branch):

def check(self):
self.branch.lock_read()
self.progress = bzrlib.ui.ui_factory.progress_bar()
try:
self.history = self.branch.revision_history()
if not len(self.history):
# nothing to see here
return
self.planned_revisions = self.branch.get_ancestry(self.history[-1])
self.planned_revisions.remove(None)
revno = 0
if not self.branch.revision_store.listable():
raise BzrCheckError("Branch must be local")
self.planned_revisions = set(self.branch.revision_store)
inventoried = set(self.inventory_weave.names())
awol = self.planned_revisions - inventoried
if len(awol) > 0:
raise BzrCheckError('Stored revisions missing from inventory'
'{%s}' % ','.join([f for f in awol]))

self.progress = bzrlib.ui.ui_factory.progress_bar()
while revno < len(self.planned_revisions):
rev_id = self.planned_revisions[revno]
self.progress.update('checking revision', revno,
for revno, rev_id in enumerate(self.planned_revisions):
self.progress.update('checking revision', revno+1,
len(self.planned_revisions))
revno += 1
self.check_one_rev(rev_id)
self.progress.clear()
finally:
self.progress.clear()
self.branch.unlock()

def report_results(self, verbose):
Expand Down
7 changes: 7 additions & 0 deletions bzrlib/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,10 @@ class MustUseDecorated(Exception):
This should never escape bzr, so does not need to be printable.
"""

class MissingText(BzrNewError):
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
def __init__(self, branch, text_revision, file_id):
self.branch = branch
self.base = branch.base
self.text_revision = text_revision
self.file_id = file_id
24 changes: 11 additions & 13 deletions bzrlib/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import bzrlib
import bzrlib.errors as errors
from bzrlib.errors import InstallFailed, NoSuchRevision, WeaveError
from bzrlib.errors import (InstallFailed, NoSuchRevision, WeaveError,
MissingText)
from bzrlib.trace import mutter, note, warning
from bzrlib.branch import Branch
from bzrlib.progress import ProgressBar
Expand Down Expand Up @@ -212,22 +213,19 @@ def _copy_new_texts(self, rev_id, inv):
# in memory until everything's done? But this way is nicer
# if it's interrupted.
for path, ie in inv.iter_entries():
if ie.revision != rev_id:
continue
mutter('%s {%s} is changed in this revision',
path, ie.file_id)
self._copy_one_weave(rev_id, ie.file_id)
self._copy_one_weave(rev_id, ie.file_id, ie.revision)

def _copy_one_weave(self, rev_id, file_id):
"""Copy one file weave."""
mutter('copy file {%s} modified in {%s}', file_id, rev_id)
if file_id in self.copied_file_ids:
mutter('file {%s} already copied', file_id)
def _copy_one_weave(self, rev_id, file_id, text_revision):
"""Copy one file weave, esuring the result contains text_revision."""
to_weave = self.to_weaves.get_weave_or_empty(file_id,
self.to_branch.get_transaction())
if text_revision in to_weave:
return
from_weave = self.from_weaves.get_weave(file_id,
self.from_branch.get_transaction())
to_weave = self.to_weaves.get_weave_or_empty(file_id,
self.to_branch.get_transaction())
if text_revision not in from_weave:
raise MissingText(self.from_branch, text_revision, file_id)
mutter('copy file {%s} modified in {%s}', file_id, rev_id)
try:
to_weave.join(from_weave)
except errors.WeaveParentMismatch:
Expand Down
3 changes: 3 additions & 0 deletions bzrlib/weave.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ def __init__(self, weave_name=None):
self._name_map = {}
self._weave_name = weave_name

def __repr__(self):
return "Weave(%r)" % self._weave_name


def copy(self):
"""Return a deep copy of self.
Expand Down

0 comments on commit 84b4db4

Please sign in to comment.