diff options
author | Ian Clatworthy <ian.clatworthy@internode.on.net> | 2008-02-27 18:21:24 +1000 |
---|---|---|
committer | Ian Clatworthy <ian.clatworthy@internode.on.net> | 2008-02-27 18:21:24 +1000 |
commit | 64cb21b1ffb8b64f90c77b0d09f6b1751bc641e1 (patch) | |
tree | 4298d2132ccf14d22a74da38322a232e8c32fccf /processors | |
parent | 87ad7162e7bb5d0549aa58fb2647271b6f3ea7f6 (diff) | |
download | bzr-fastimport-64cb21b1ffb8b64f90c77b0d09f6b1751bc641e1.tar.gz |
handle existing branches and only count the branches really updated
Diffstat (limited to 'processors')
-rw-r--r-- | processors/generic_processor.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/processors/generic_processor.py b/processors/generic_processor.py index b698bde..c7db0de 100644 --- a/processors/generic_processor.py +++ b/processors/generic_processor.py @@ -253,7 +253,11 @@ class GenericProcessor(processor.ImportProcessor): # Update the working trees as requested and dump stats self._tree_count = 0 remind_about_update = True - if self.params.get('trees', False): + if self._branch_count == 0: + self.note("no branches to update") + self.note("no working trees to update") + remind_about_update = False + elif self.params.get('trees', False): trees = self._get_working_trees(branches_updated) if trees: self.note("Updating the working trees ...") @@ -838,8 +842,8 @@ class GenericBranchUpdater(object): updated = [] branch_tips, lost_heads = self._get_matching_branches() for br, tip in branch_tips: - self._update_branch(br, tip) - updated.append(br) + if self._update_branch(br, tip): + updated.append(br) return updated, lost_heads def _get_matching_branches(self): @@ -904,8 +908,11 @@ class GenericBranchUpdater(object): return self.last_ref def make_branch(self, location): - """Create a branch in the repository.""" - return bzrdir.BzrDir.create_branch_convenience(location) + """Make a branch in the repository if not already there.""" + try: + return bzrdir.BzrDir.open(location).open_branch() + except errors.NotBranchError, ex: + return bzrdir.BzrDir.create_branch_convenience(location) def _get_bzr_names_from_ref_names(self, ref_names): """Generate Bazaar branch names from import ref names. @@ -926,11 +933,19 @@ class GenericBranchUpdater(object): return bazaar_names def _update_branch(self, br, last_mark): - """Update a branch with last revision and tag information.""" + """Update a branch with last revision and tag information. + + :return: whether the branch was changed or not + """ last_rev_id = self.cache_mgr.revision_ids[last_mark] revno = len(list(self.repo.iter_reverse_revision_history(last_rev_id))) - br.set_last_revision_info(revno, last_rev_id) + existing_revno, existing_last_rev_id = br.last_revision_info() + changed = False + if revno != existing_revno or last_rev_id != existing_last_rev_id: + br.set_last_revision_info(revno, last_rev_id) + changed = True + note("\t branch %s now has %d revisions", br.nick, revno) # TODO: apply tags known in this branch #if self.tags: # br.tags._set_tag_dict(self.tags) - note("\t branch %s has %d revisions", br.nick, revno) + return changed |