Exemplo n.º 1
0
 def assertLocations(self, expected_locations):
     br, _ = branch.Branch.open_containing(self.working_dir)
     if not expected_locations:
         self.assertEqual(None, br.get_parent())
     else:
         expected_pull_location = expected_locations[0]
         pull_location = urlutils.relative_url(br.base, br.get_parent())
         self.assertIsSameRealPath(expected_pull_location, pull_location)
Exemplo n.º 2
0
 def test_reference_parent(self):
     tree = self.make_branch_and_tree('tree')
     subtree = self.make_branch_and_tree('tree/subtree')
     subtree.commit('a change')
     try:
         tree.add_reference(subtree)
     except errors.UnsupportedOperation:
         raise tests.TestNotApplicable('Tree cannot hold references.')
     reference_parent = tree.branch.reference_parent(
         urlutils.relative_url(tree.branch.user_url, subtree.branch.user_url))
     self.assertEqual(subtree.branch.user_url, reference_parent.user_url)
Exemplo n.º 3
0
 def test_reference_parent_accepts_possible_transports(self):
     tree = self.make_branch_and_tree('tree')
     subtree = self.make_branch_and_tree('tree/subtree')
     subtree.commit('a change')
     try:
         tree.add_reference(subtree)
     except errors.UnsupportedOperation:
         raise tests.TestNotApplicable('Tree cannot hold references.')
     reference_parent = tree.branch.reference_parent(
         urlutils.relative_url(tree.branch.user_url,
                               subtree.branch.user_url),
         possible_transports=[subtree.controldir.root_transport])
Exemplo n.º 4
0
 def get_parent(self, url):
     # Check if there is an existing connection we can use
     for c in self.connections:
         assert not c.busy, "busy connection in pool"
         assert not c.url.endswith("/"), "%r ends with a /" % c.url
         assert isinstance(url, text_type)
         if url == c.url or url.startswith(c.url+"/"):
             self.connections.remove(c)
             relpath = urlutils.relative_url(c.url+"/", url.rstrip("/")+"/")
             if relpath == ".":
                 relpath = ""
             return c, relpath.rstrip("/")
     return self.new(url), ""
Exemplo n.º 5
0
 def test_bind_clears_cached_master_branch(self):
     """b.bind clears any cached value of b.get_master_branch."""
     master1 = self.make_branch('master1')
     master2 = self.make_branch('master2')
     branch = self.make_branch('branch')
     try:
         branch.bind(master1)
     except errors.UpgradeRequired:
         raise tests.TestNotApplicable('Format does not support binding')
     self.addCleanup(branch.lock_write().unlock)
     self.assertNotEqual(None, branch.get_master_branch())
     branch.bind(master2)
     self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
                                                 branch.get_master_branch().base))