def set_last_revision_info(self, revno, revision_id): if not revision_id or not isinstance(revision_id, basestring): raise errors.InvalidRevisionId(revision_id=revision_id, branch=self) revision_id = _mod_revision.ensure_null(revision_id) old_revno, old_revid = self.last_revision_info() # TODO: Check append_revisions_only ? self._run_pre_change_branch_tip_hooks(revno, revision_id) self._write_last_revision_info(revno, revision_id) self._clear_cached_state() self._last_revision_info_cache = revno, revision_id self._run_post_change_branch_tip_hooks(old_revno, old_revid)
def test_local_commit_does_not_push_to_master(self): # a --local commit does not require access to the master branch # at all, or even for it to exist. # we test that even when its available it does not push to it. master = self.make_branch('master') tree = self.make_branch_and_tree('tree') try: tree.branch.bind(master) except branch.BindingUnsupported: # older format. return committed_id = tree.commit('foo', local=True) self.assertFalse(master.repository.has_revision(committed_id)) self.assertEqual(_mod_revision.NULL_REVISION, (_mod_revision.ensure_null(master.last_revision())))
def test_sprout_bzrdir_repository(self): tree = self.make_branch_and_tree('commit_tree') self.build_tree(['foo'], transport=tree.controldir.transport.clone('..')) tree.add('foo') tree.commit('revision 1', rev_id=b'1') dir = self.make_controldir('source') repo = dir.create_repository() repo.fetch(tree.branch.repository) self.assertTrue(repo.has_revision(b'1')) try: self.assertTrue( _mod_revision.is_null( _mod_revision.ensure_null( dir.open_branch().last_revision()))) except errors.NotBranchError: pass target = dir.sprout(self.get_url('target')) self.assertNotEqual(dir.transport.base, target.transport.base) # testing inventory isn't reasonable for repositories self.assertDirectoriesEqual(dir.root_transport, target.root_transport, [ './.bzr/branch', './.bzr/checkout', './.bzr/inventory', './.bzr/parent', './.bzr/repository/inventory.knit', ]) try: local_inventory = dir.transport.local_abspath('inventory') except errors.NotLocalUrl: return try: # If we happen to have a tree, we'll guarantee everything # except for the tree root is the same. with open(local_inventory, 'rb') as inventory_f: self.assertContainsRe( inventory_f.read(), b'<inventory format="5">\n</inventory>\n') except IOError as e: if e.errno != errno.ENOENT: raise
def _update_revisions(self, stop_revision=None, overwrite=False, lossy=False, fetch_non_mainline=False): """Push derivatives of the revisions missing from target from source into target. :param target: Branch to push into :param source: Branch to retrieve revisions from :param stop_revision: If not None, stop at this revision. :return: Map of old revids to new revids. """ if stop_revision is None: stop_revision = ensure_null(self.source.last_revision()) (old_last_revid, revid_map) = self._push(stop_revision, overwrite=overwrite, push_metadata=(not lossy)) self.target._clear_cached_state() new_last_revid = self.target.last_revision() return (old_last_revid, new_last_revid, dict([(k, v[0]) for (k, v) in revid_map.items()]))
def test_update_unbound_works(self): b = self.make_branch('.') b.update() self.assertEqual(_mod_revision.NULL_REVISION, _mod_revision.ensure_null(b.last_revision()))