Beispiel #1
0
    def test_find_branches_between_no_later(self):
        repos_url = self.make_svn_repository("a")

        repos = Repository.open(repos_url)
        repos.set_layout(RootLayout())

        self.assertEqual([("", 0, True)],
                         list(
                             find_branches_between(repos._log,
                                                   repos.transport,
                                                   RootLayout(),
                                                   to_revnum=0,
                                                   from_revnum=0)))
Beispiel #2
0
    def test_simplemove(self):
        repos_url = self.make_svn_repository('d')

        dc = self.get_commit_editor(repos_url)
        dc.add_file("foo").modify(b"data")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        dc.add_file("bar", "foo", 1)
        dc.delete("foo")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        dc.open_file("bar").modify(b"data2")
        dc.close()

        repository = Repository.open(repos_url)
        repository.set_layout(RootLayout())
        mapping = repository.get_mapping()

        tree1 = repository.revision_tree(
            repository.generate_revision_id(1, u"", mapping))
        tree2 = repository.revision_tree(
            repository.generate_revision_id(2, u"", mapping))
        self.assertNotEqual(None, tree1.path2id("foo"))
        self.assertIs(None, tree2.path2id("foo"))
        self.assertNotEqual(None, tree2.path2id("bar"))
        self.assertNotEqual(tree1.path2id("foo"), tree2.path2id("blie"))
        self.assertNotEqual(tree2.path2id("bar"), tree2.path2id("blie"))
Beispiel #3
0
 def test_follow_history_empty(self):
     repos_url = self.make_svn_repository("a")
     repos = Repository.open(repos_url)
     repos.set_layout(RootLayout())
     self.assertEqual(
         set([repos.generate_revision_id(0, '', repos.get_mapping())]),
         set(repos.all_revision_ids(repos.get_layout())))
Beispiel #4
0
    def test_dumpfile_open_empty(self):
        dumpfile = os.path.join(self.test_dir, "dumpfile")
        open(dumpfile, '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
""")
        branch_path = os.path.join(self.test_dir, "f")
        repos = self.load_dumpfile(dumpfile, 'g')
        convert_repository(repos,
                           branch_path,
                           RootLayout(),
                           remember_parent=False)
        branch = Repository.open(branch_path)
        self.assertEqual(len(branch.all_revision_ids()), 1)
        b = Branch.open(branch_path)
        self.assertEquals(1, b.revno())
        self.assertEquals(None, b.get_parent())
Beispiel #5
0
    def test_get_revision_delta(self):
        repos_url = self.make_svn_repository('d')

        dc = self.get_commit_editor(repos_url)
        dc.add_file("foo").modify(b"data")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        dc.open_file("foo").modify(b"data2")
        dc.close()

        r = Repository.open(repos_url)
        r.set_layout(RootLayout())
        d1 = r.get_revision_delta(
            r.generate_revision_id(1, "", r.get_mapping()))
        self.assertEquals(None, d1.unchanged)
        self.assertEquals(1, len(d1.added))
        self.assertEquals("foo", d1.added[0][0])
        self.assertEquals(0, len(d1.modified))
        self.assertEquals(0, len(d1.removed))

        d2 = r.get_revision_delta(
            r.generate_revision_id(2, "", r.get_mapping()))
        self.assertEquals(None, d2.unchanged)
        self.assertEquals(0, len(d2.added))
        self.assertEquals("foo", d2.modified[0][0])
        self.assertEquals(0, len(d2.removed))
Beispiel #6
0
    def test_copy_contents_into(self):
        repos_url = self.make_client('d', 'dc')
        self.build_tree({'dc/foo/bla': b"data"})
        self.client_add("dc/foo")
        self.client_commit("dc", "My Message")
        self.build_tree({
            'dc/foo/blo': b"data2",
            "dc/bar/foo": b"data3",
            'dc/foo/bla': b"data"
        })
        self.client_add("dc/foo/blo")
        self.client_add("dc/bar")
        self.client_commit("dc", "Second Message")
        repository = Repository.open(repos_url)
        repository.set_layout(RootLayout())
        mapping = repository.get_mapping()

        to_controldir = ControlDir.create("e")
        to_repos = to_controldir.create_repository()

        repository.copy_content_into(
            to_repos, repository.generate_revision_id(2, "", mapping))

        self.assertTrue(
            repository.has_revision(
                repository.generate_revision_id(2, "", mapping)))
        self.assertTrue(
            repository.has_revision(
                repository.generate_revision_id(1, "", mapping)))
Beispiel #7
0
 def test_get_branch_invalid_revision(self):
     repos_url = self.make_svn_repository("a")
     repos = Repository.open(repos_url)
     repos.set_layout(RootLayout())
     self.assertRaises(
         NoSuchRevision, list,
         repos._revmeta_provider.iter_reverse_branch_changes("/", 20, 0))
Beispiel #8
0
 def testlhs_revision_parent_none(self):
     repos_url = self.make_svn_repository('d')
     repos = Repository.open(repos_url)
     repos.set_layout(RootLayout())
     revmeta0 = repos._revmeta_provider.get_revision("", 0)
     self.assertEquals(
         NULL_REVISION,
         revmeta0.get_lhs_parent_revid(repos.get_mapping(), None))
Beispiel #9
0
    def test_shared_import_rootlayout_empty(self):
        dir = ControlDir.create("e")
        dir.create_repository(shared=True)

        convert_repository(Repository.open(self.repos_url),
                           "e",
                           RootLayout(),
                           create_shared_repo=True)
Beispiel #10
0
 def test_empty(self):
     self.repos.set_layout(RootLayout())
     self.mapping = self.repos.get_mapping()
     self.assertEqual(
         {
             u"":
             (self.mapping.generate_file_id((self.repos.uuid, u"", 0), u""),
              self.repos.generate_revision_id(0, u"", self.mapping), None)
         }, self.get_map(u"", 0, self.mapping))
 def test_root_layout_simple(self):
     browser = self.get_browser(None, 1, 0, RootLayout(),
             { 1: { u"bla": ('A', None, -1, NODE_DIR)}})
     rev1 = next(browser)
     self.assertEquals(('revision', FakeRevision(u'', 1)), rev1)
     rev2 = next(browser)
     self.assertEquals(('revision', FakeRevision(u'', 0)), rev2)
     self.assertTrue(rev1[1]._lhs_parent_known)
     self.assertTrue(rev2[1]._lhs_parent_known)
     self.assertRaises(StopIteration, next, browser)
Beispiel #12
0
 def testlhs_revision_parent_first(self):
     repos_url = self.make_client('d', 'dc')
     repos = Repository.open(repos_url)
     repos.set_layout(RootLayout())
     self.build_tree({'dc/adir/afile': b"data"})
     self.client_add("dc/adir")
     self.client_commit("dc", "Initial commit")
     mapping = repos.get_mapping()
     revmeta0 = repos._revmeta_provider.get_revision("", 0)
     revmeta1 = repos._revmeta_provider.get_revision("", 1)
     self.assertEquals(repos.generate_revision_id(0, "", mapping),
                       revmeta1.get_lhs_parent_revid(mapping, revmeta0))
Beispiel #13
0
    def test_revision_fileidmap(self):
        dc = self.get_commit_editor(self.repos_url)
        dc.add_file("foo").modify("data")
        dc.change_prop("bzr:revision-info", "")
        dc.change_prop("bzr:file-ids", "foo\tsomeid\n")
        dc.close()

        repository = Repository.open(self.repos_url)
        repository.set_layout(RootLayout())
        tree = repository.revision_tree(Branch.open(self.repos_url).last_revision())
        self.assertEqual("someid", tree.path2id("foo"))
        self.assertFalse(tree.has_id("1@%s::foo" % repository.uuid))
Beispiel #14
0
    def test_push_lossy(self):
        repos_url = self.make_repository('d')
        Repository.open(repos_url).store_layout(RootLayout())

        dc = self.get_commit_editor(repos_url)
        dc.add_file("foo").modify()
        dc.close()

        self.run_bzr("branch %s dc" % repos_url)
        self.build_tree({"dc/foo": "blaaaa"})
        self.run_bzr("commit -m msg dc")
        self.run_bzr("push --lossy -d dc %s" % repos_url)
        self.assertEquals("", self.run_bzr("status dc")[0])
Beispiel #15
0
    def test_get_branch_log(self):
        repos_url = self.make_svn_repository("a")
        cb = self.get_commit_editor(repos_url)
        cb.add_file("foo").modify()
        cb.close()

        repos = Repository.open(repos_url)
        repos.set_layout(RootLayout())

        self.assertRevmetaLogEquals([('', {
            'foo': ('A', None, -1, NODE_FILE)
        }, 1), ('', {
            '': ('A', None, -1, NODE_DIR)
        }, 0)], repos._revmeta_provider.iter_reverse_branch_changes("", 1, 0))
 def test_pointless_root_commit(self):
     rev1 = { u"foo": ('A', None, -1, NODE_DIR) }
     rev2 = {}
     rev3 = { u"bar": ('A', None, -1, NODE_DIR) }
     browser = self.get_browser([u""], 3, 0, RootLayout(),
             { 1: rev1, 2: rev2, 3: rev3 })
     rev1 = next(browser)
     self.assertEquals(("revision", FakeRevision(u"", 3)), rev1)
     rev2 = next(browser)
     self.assertEquals(("revision", FakeRevision(u"", 2)), rev2)
     rev3 = next(browser)
     self.assertEquals(("revision", FakeRevision(u"", 1)), rev3)
     rev4 = next(browser)
     self.assertEquals(("revision", FakeRevision(u"", 0)), rev4)
Beispiel #17
0
class RootLayoutTests(TestCase, LayoutTests):
    def setUp(self):
        TestCase.setUp(self)
        self.layout = RootLayout()

    def test_get_branch_path_default(self):
        self.assertEquals("", self.layout.get_branch_path(""))
        self.assertRaises(NoCustomBranchPaths, self.layout.get_branch_path,
                          None, "proh")

    def test_get_branch_path_custom(self):
        self.assertRaises(NoCustomBranchPaths, self.layout.get_branch_path,
                          "la")
        self.assertRaises(NoCustomBranchPaths, self.layout.get_branch_path,
                          "la", "proh")
Beispiel #18
0
    def test_fetch_ghosts(self):
        dc = self.get_commit_editor(self.repos_url)
        dc.add_file("bla").modify("data")
        dc.change_prop("bzr:ancestry:v3-none", "aghost\n")
        dc.close()

        oldrepos = Repository.open(self.repos_url)
        oldrepos.set_layout(RootLayout())
        dir = ControlDir.create("f")
        newrepos = dir.create_repository()
        oldrepos.copy_content_into(newrepos)
        mapping = oldrepos.get_mapping()

        rev = newrepos.get_revision(oldrepos.generate_revision_id(1, u"", mapping))
        self.assertTrue("aghost" in rev.parent_ids)
Beispiel #19
0
 def test_create_branch_top(self):
     repos_url = self.make_svn_repository("d")
     x = ControlDir.open(repos_url)
     x.open_repository().store_layout(RootLayout())
     b = x.create_branch()
     self.assertEquals(repos_url, b.base)
Beispiel #20
0
 def setUp(self):
     TestCase.setUp(self)
     self.layout = RootLayout()
Beispiel #21
0
    def test_dumpfile(self):
        filename = os.path.join(self.test_dir, "dumpfile")
        uuid = "606c7b1f-987c-4826-b37d-eb456ceb87e1"
        open(filename, 'w').write("""SVN-fs-dump-format-version: 2

UUID: 606c7b1f-987c-4826-b37d-eb456ceb87e1

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

K 8
svn:date
V 27
2006-12-26T00:04:55.850520Z
PROPS-END

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

K 7
svn:log
V 3
add
K 10
svn:author
V 6
jelmer
K 8
svn:date
V 27
2006-12-26T00:05:15.504335Z
PROPS-END

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

PROPS-END


Revision-number: 2
Prop-content-length: 102
Content-length: 102

K 7
svn:log
V 2
rm
K 10
svn:author
V 6
jelmer
K 8
svn:date
V 27
2006-12-26T00:05:30.775369Z
PROPS-END

Node-path: x
Node-action: delete


Revision-number: 3
Prop-content-length: 105
Content-length: 105

K 7
svn:log
V 5
readd
K 10
svn:author
V 6
jelmer
K 8
svn:date
V 27
2006-12-26T00:05:43.584249Z
PROPS-END

Node-path: y
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 1
Node-copyfrom-path: x
Prop-content-length: 10
Content-length: 10

PROPS-END


Revision-number: 4
Prop-content-length: 108
Content-length: 108

K 7
svn:log
V 8
Replace

K 10
svn:author
V 6
jelmer
K 8
svn:date
V 27
2006-12-25T04:30:06.383777Z
PROPS-END

Node-path: y
Node-action: delete


Revision-number: 5
Prop-content-length: 108
Content-length: 108

K 7
svn:log
V 8
Replace

K 10
svn:author
V 6
jelmer
K 8
svn:date
V 27
2006-12-25T04:30:06.383777Z
PROPS-END


Node-path: y
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 1
Node-copyfrom-path: x


""")
        self.record_directory_isolation()
        try:
            self.assertEquals(
                "",
                self.run_bzr('svn-import --layout=none %s dc' % filename)[0])
        finally:
            self.enable_directory_isolation()
        load_dumpfile(filename, "realrepo")
        svnrepo = Repository.open("realrepo")
        self.assertEquals(uuid, svnrepo.uuid)
        svnrepo.set_layout(RootLayout())
        mapping = svnrepo.get_mapping()
        newrepos = Repository.open("dc")
        self.assertTrue(
            newrepos.has_revision(
                mapping.revision_id_foreign_to_bzr((uuid, "", 5))))
        self.assertTrue(
            newrepos.has_revision(
                mapping.revision_id_foreign_to_bzr((uuid, "", 1))))
        tree1 = newrepos.revision_tree(
            mapping.revision_id_foreign_to_bzr((uuid, "", 1)))
        tree2 = newrepos.revision_tree(
            mapping.revision_id_foreign_to_bzr((uuid, "", 5)))
        self.assertNotEqual(tree1.path2id("y"), tree2.path2id("y"))
Beispiel #22
0
 def test_set_layout(self):
     repos_url = self.make_svn_repository('d')
     repos = Repository.open(repos_url)
     repos.set_layout(RootLayout())
Beispiel #23
0
 def test_push_lossy_empty(self):
     repos_url = self.make_repository('dp')
     Repository.open(repos_url).store_layout(RootLayout())
     self.run_bzr("init dc")
     os.chdir("dc")
     self.run_bzr("push --lossy %s" % repos_url)