Ejemplo n.º 1
0
    def test_pull(self):
        # Make sure we can pull from paths that can't be encoded
        dirname1 = self.info['directory']
        dirname2 = self.info['directory'] + '2'
        url1 = urlutils.local_path_to_url(dirname1)
        url2 = urlutils.local_path_to_url(dirname2)
        out_bzrdir = self.wt.controldir.sprout(url1)
        out_bzrdir.sprout(url2)

        self.build_tree_contents([(osutils.pathjoin(dirname1, "a"),
                                   b'different text\n')])
        self.wt.commit('mod a')

        txt = self.run_bzr_decode('pull', working_dir=dirname2)

        expected = osutils.pathjoin(osutils.getcwd(), dirname1)
        self.assertEqual(
            u'Using saved parent location: %s/\n'
            'No revisions or tags to pull.\n' % (expected, ), txt)

        self.build_tree_contents([(osutils.pathjoin(dirname1,
                                                    'a'), b'and yet more\n')])
        self.wt.commit(u'modifying a by ' + self.info['committer'])

        # We should be able to pull, even if our encoding is bad
        self.run_bzr_decode('pull --verbose',
                            encoding='ascii',
                            working_dir=dirname2)
Ejemplo n.º 2
0
 def test_branch_standalone(self):
     shared_repo = self.make_repository('repo', shared=True)
     self.example_branch('source')
     self.run_bzr('branch --standalone source repo/target')
     b = branch.Branch.open('repo/target')
     expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
     self.assertEqual(strip_trailing_slash(b.repository.base),
                      strip_trailing_slash(local_path_to_url(expected_repo_path)))
Ejemplo n.º 3
0
 def test_pull_dash_d(self):
     self.example_branch('a')
     self.make_branch_and_tree('b')
     self.make_branch_and_tree('c')
     # pull into that branch
     self.run_bzr('pull -d b a')
     # pull into a branch specified by a url
     c_url = urlutils.local_path_to_url('c')
     self.assertStartsWith(c_url, 'file://')
     self.run_bzr(['pull', '-d', c_url, 'a'])
Ejemplo n.º 4
0
 def test_from_colocated(self):
     """Branch from a colocated branch into a regular branch."""
     os.mkdir('b')
     tree = self.example_branch('b/a', format='development-colo')
     tree.controldir.create_branch(name='somecolo')
     out, err = self.run_bzr('branch %s,branch=somecolo' %
                             local_path_to_url('b/a'))
     self.assertEqual('', out)
     self.assertEqual('Branched 0 revisions.\n', err)
     self.assertPathExists('a')
Ejemplo n.º 5
0
 def test_from_colocated(self):
     """Branch from a colocated branch into a regular branch."""
     os.mkdir('b')
     tree = self.example_dir('b/a')
     tree.controldir.create_branch(name='somecolo')
     out, err = self.run_bzr('clone %s' % local_path_to_url('b/a'))
     self.assertEqual('', out)
     self.assertEqual('Created new control directory.\n', err)
     self.assertPathExists('a')
     target = controldir.ControlDir.open('a')
     self.assertEqual(['', 'somecolo'], target.branch_names())
Ejemplo n.º 6
0
    def test_root(self):
        dirname = self.info['directory']
        url = urlutils.local_path_to_url(dirname)
        self.run_bzr_decode('root')

        self.wt.controldir.sprout(url)

        txt = self.run_bzr_decode('root', working_dir=dirname)
        self.assertTrue(txt.endswith(dirname + '\n'))

        txt = self.run_bzr_decode('root', encoding='ascii', fail=True,
                                  working_dir=dirname)
Ejemplo n.º 7
0
    def test_uncommittedchanges_display_url(self):
        """The display_url of UncommittedChanges errors should be serialised"""
        self.requireFeature(features.UnicodeFilenameFeature)
        path = "\u1234"

        class FakeTree(object):
            def __init__(self, url):
                self.user_url = url

        attrs = self.check_exception_instance(
            errors.UncommittedChanges(
                FakeTree(urlutils.local_path_to_url(path))))
        self.assertIsSameRealPath(
            path, urlutils.local_path_from_url(attrs["display_url"]))
Ejemplo n.º 8
0
 def test_clone_preserves_signatures(self):
     wt = self.make_branch_and_tree('source')
     a = wt.commit('A', allow_pointless=True)
     repo = wt.branch.repository
     repo.lock_write()
     repo.start_write_group()
     repo.sign_revision(a, gpg.LoopbackGPGStrategy(None))
     repo.commit_write_group()
     repo.unlock()
     # FIXME: clone should work to urls,
     # wt.clone should work to disks.
     self.build_tree(['target/'])
     d2 = repo.controldir.clone(urlutils.local_path_to_url('target'))
     self.assertEqual(repo.get_signature_text(a),
                      d2.open_repository().get_signature_text(a))
Ejemplo n.º 9
0
    def test_open_internal(self):
        filename = os.path.join(self.test_dir, "dumpfile")
        open(filename, 'w').write("""SVN-fs-dump-format-version: 2

UUID: 6987ef2d-cd6b-461f-9991-6f1abef3bd59

Revision-number: 0
Prop-content-length: 56
Content-length: 56

K 8
svn:date
V 27
2006-07-02T13:14:51.972532Z
PROPS-END

Revision-number: 1
Prop-content-length: 109
Content-length: 109

K 7
svn:log
V 9
Add trunk
K 10
svn:author
V 6
jelmer
K 8
svn:date
V 27
2006-07-02T13:58:02.528258Z
PROPS-END

Node-path: trunk
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Node-path: trunk/bla
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 5
Text-content-md5: 6137cde4893c59f76f005a8123d8e8e6
Content-length: 15

PROPS-END
data


""")
        repos = self.load_dumpfile(filename, 'g')
        convert_repository(repos, os.path.join(self.test_dir, "e"),
                           TrunkLayout(0))
        mapping = repos.get_mapping()
        abspath = self.test_dir
        if sys.platform == 'win32':
            abspath = '/' + abspath
        branch = Branch.open(os.path.join(self.test_dir, "e", "trunk"))
        self.assertEqual(
            local_path_to_url(os.path.join(self.test_dir, "e", "trunk")),
            branch.base.rstrip("/"))
        self.assertEqual(
            mapping.revision_id_foreign_to_bzr(
                ("6987ef2d-cd6b-461f-9991-6f1abef3bd59", 'trunk', 1)),
            branch.last_revision())
Ejemplo n.º 10
0
 def assertParent(self, expected_parent, branch):
     """Verify that the parent is not None and is set correctly."""
     actual_parent = branch.get_parent()
     self.assertIsSameRealPath(urlutils.local_path_to_url(expected_parent),
                               branch.get_parent())
Ejemplo n.º 11
0
 def get_url(self):
     """See Transport.Server.get_url."""
     return urlutils.local_path_to_url('')
Ejemplo n.º 12
0
 def get_base(branch, tree):
     if tree and isinstance(tree, WorkingTree):
         return urlutils.local_path_to_url(tree.basedir)
     return branch.base