Ejemplo n.º 1
0
 def test_id_native(self):
     rev = Revision("somerevid")
     rev.timestamp = 43842423
     rev.committer = "Joe <*****@*****.**>"
     self.assertEquals(
         "somepath somerevid 1971-05-23T10:27:03.000000Z Joe <*****@*****.**>",
         keywords['Id']("somerevid", rev, "somedir/somepath", None))
Ejemplo n.º 2
0
 def test_date_revmeta_native(self):
     rev = Revision("somerevid")
     revmeta = MockRevmeta({"svn:date": "somedateblabla"}, 42, "/trunk",
                           "http://foo.host")
     self.assertEquals(
         'somedateblabla', keywords['Date']("somerevid", rev, "somepath",
                                            revmeta))
Ejemplo n.º 3
0
    def check_fileprops(self, changed_fileprops, checkresult):
        # bzr:revision-id:*
        text = changed_fileprops.get(SVN_PROP_BZR_REVISION_ID + self.name,
                                     ("", ""))
        try:
            new_lines = find_new_lines(*text)
        except ValueError:
            checkresult.invalid_fileprop_cnt += 1
        else:
            if len(new_lines) > 1:
                checkresult.invalid_fileprop_cnt += 1

        if new_lines == []:
            return
        try:
            revid = parse_revid_property(new_lines[0])
        except errors.InvalidPropertyValue:
            self.invalid_fileprop_cnt += 1
            return

        text = changed_fileprops.get(SVN_PROP_BZR_REVISION_INFO, ("", ""))
        try:
            parse_revision_metadata(text[1], Revision(revid))
        except errors.InvalidPropertyValue:
            checkresult.invalid_fileprop_cnt += 1
Ejemplo n.º 4
0
 def test_author_native(self):
     revmeta = MockRevmeta({"svn:author": "someauthor"}, 42, "/trunk",
                           "http://foo.host")
     rev = Revision("somerevid")
     self.assertEquals(
         'someauthor', keywords['Author']("somerevid", rev, "somepath",
                                          revmeta))
Ejemplo n.º 5
0
 def test_parse_revision_metadata_properties_newline(self):
     rev = Revision('someid')
     parse_revision_metadata("properties: \n" +
                             "\tfoo: bar\n" +
                             "\tfoo: bar2\n" +
                             "\tha: ha\n", rev)
     self.assertEquals({"foo": "bar\nbar2", "ha": "ha"}, rev.properties)
Ejemplo n.º 6
0
    def test_fetch_inconsistent_last_changed_entries(self):
        """If an inventory has odd data we should still get what it references.

        This test tests that we do fetch a file text created in a revision not
        being fetched, but referenced from the revision we are fetching when the
        adjacent revisions to the one being fetched do not reference that text.
        """
        if not self.repository_format.supports_full_versioned_files:
            raise TestNotApplicable('Need full versioned files')
        tree = self.make_branch_and_tree('source')
        revid = tree.commit('old')
        to_repo = self.make_to_repository('to_repo')
        try:
            to_repo.fetch(tree.branch.repository, revid)
        except errors.NoRoundtrippingSupport:
            raise TestNotApplicable('roundtripping not supported')
        # Make a broken revision and fetch it.
        source = tree.branch.repository
        source.lock_write()
        self.addCleanup(source.unlock)
        source.start_write_group()
        try:
            # We need two revisions: OLD and NEW. NEW will claim to need a file
            # 'FOO' changed in 'OLD'. OLD will not have that file at all.
            source.texts.insert_record_stream([
                versionedfile.FulltextContentFactory((b'foo', revid), (), None,
                                                     b'contents')])
            basis = source.revision_tree(revid)
            parent_id = basis.path2id('')
            entry = inventory.make_entry('file', 'foo-path', parent_id, b'foo')
            entry.revision = revid
            entry.text_size = len('contents')
            entry.text_sha1 = osutils.sha_string(b'contents')
            inv_sha1, _ = source.add_inventory_by_delta(revid, [
                (None, 'foo-path', b'foo', entry)], b'new', [revid])
            rev = Revision(timestamp=0,
                           timezone=None,
                           committer="Foo Bar <*****@*****.**>",
                           message="Message",
                           inventory_sha1=inv_sha1,
                           revision_id=b'new',
                           parent_ids=[revid])
            source.add_revision(rev.revision_id, rev)
        except:
            source.abort_write_group()
            raise
        else:
            source.commit_write_group()
        to_repo.fetch(source, b'new')
        to_repo.lock_read()
        self.addCleanup(to_repo.unlock)
        self.assertEqual(b'contents',
                         next(to_repo.texts.get_record_stream([(b'foo', revid)],
                                                              'unordered', True)).get_bytes_as('fulltext'))
Ejemplo n.º 7
0
 def test_import_revision_svnprops(self):
     rev = Revision(None)
     revprops = {"svn:log": "A log msg", "svn:author": "Somebody",
             "svn:date": "2008-11-03T09:33:00.716938Z"}
     mapping.parse_svn_revprops(revprops, rev)
     self.assertEquals("Somebody", rev.committer)
     self.assertEquals("A log msg", rev.message)
     self.assertEquals({}, rev.properties)
     self.assertEquals(0.0, rev.timezone)
     self.assertEquals(1225704780.716938, rev.timestamp,
             "parsing %s" % revprops["svn:date"])
Ejemplo n.º 8
0
    def test_fetch_missing_text_other_location_fails(self):
        if not self.repository_format.supports_full_versioned_files:
            raise TestNotApplicable('Need full versioned files')

        source_tree = self.make_branch_and_tree('source')
        source = source_tree.branch.repository
        target = self.make_to_repository('target')

        # start by adding a file so the data knit for the file exists in
        # repositories that have specific files for each fileid.
        self.build_tree(['source/id'])
        source_tree.add(['id'], [b'id'])
        source_tree.commit('a', rev_id=b'a')
        # now we manually insert a revision with an inventory referencing
        # file 'id' at revision 'b', but we do not insert revision b.
        # this should ensure that the new versions of files are being checked
        # for during pull operations
        inv = source.get_inventory(b'a')
        source.lock_write()
        self.addCleanup(source.unlock)
        source.start_write_group()
        inv.get_entry(b'id').revision = b'b'
        inv.revision_id = b'b'
        sha1 = source.add_inventory(b'b', inv, [b'a'])
        rev = Revision(timestamp=0,
                       timezone=None,
                       committer="Foo Bar <*****@*****.**>",
                       message="Message",
                       inventory_sha1=sha1,
                       revision_id=b'b')
        rev.parent_ids = [b'a']
        source.add_revision(b'b', rev)
        self.disable_commit_write_group_paranoia(source)
        source.commit_write_group()
        try:
            self.assertRaises(errors.RevisionNotPresent, target.fetch, source)
        except errors.NoRoundtrippingSupport:
            raise TestNotApplicable('roundtripping not supported')
        self.assertFalse(target.has_revision(b'b'))
Ejemplo n.º 9
0
 def test_export(self):
     rev = Revision("myrevid")
     rev.committer = u"Jelmer <foo>"
     rev.message = u"ürk"
     rev.timestamp = 432432
     rev.timezone = 0
     rev.properties = {
             "something": u"else",
             "hg:extra:foo": base64.b64encode("bar")}
     (manifest, user, (time, timezone), desc, extra) = \
         self.mapping.export_revision(rev)
     self.assertEquals("Jelmer <foo>", user)
     self.assertEquals(None, manifest)
     self.assertEquals(u"ürk", desc)
     self.assertEquals({"bzr-revprop-something": "else", "foo": "bar"}, 
                       extra)
Ejemplo n.º 10
0
    def add_revision(self, repo, revision_id, inv, parent_ids):
        """Add a revision with a given inventory and parents to a repository.

        :param repo: a repository.
        :param revision_id: the revision ID for the new revision.
        :param inv: an inventory (such as created by
            `make_one_file_inventory`).
        :param parent_ids: the parents for the new revision.
        """
        inv.revision_id = revision_id
        inv.root.revision = revision_id
        if repo.supports_rich_root():
            root_id = inv.root.file_id
            repo.texts.add_lines((root_id, revision_id), [], [])
        repo.add_inventory(revision_id, inv, parent_ids)
        revision = Revision(revision_id, committer='*****@*****.**',
                            timestamp=0, inventory_sha1='', timezone=0, message='foo',
                            parent_ids=parent_ids)
        repo.add_revision(revision_id, revision, inv)
Ejemplo n.º 11
0
 def test_message_fileprops(self):
     if not self.mapping.roundtripping:
         raise TestNotApplicable
     fileprops = {}
     self.mapping.export_revision_fileprops(fileprops,
                                            432432432.0,
                                            0,
                                            "somebody", {"arevprop": "val"},
                                            "arevid",
                                            4, ["merge1"],
                                            testament=None)
     try:
         self.mapping.export_message_fileprops("My Commit message",
                                               fileprops)
     except NotImplementedError:
         raise TestNotApplicable
     targetrev = Revision(None)
     self.mapping.import_revision_fileprops(changed_props(fileprops),
                                            targetrev)
     self.assertEquals("My Commit message", targetrev.message)
Ejemplo n.º 12
0
 def test_revision_fileprops(self):
     if not self.mapping.roundtripping:
         raise TestNotApplicable
     if not self.mapping.can_use_fileprops:
         raise TestNotApplicable
     revprops = {}
     fileprops = {}
     self.mapping.export_revision_fileprops(fileprops,
                                            432432432.0,
                                            0,
                                            "somebody", {"arevprop": "val"},
                                            "arevid",
                                            4, ["parent", "merge1"],
                                            testament=None)
     targetrev = Revision(None)
     self.mapping.import_revision_fileprops(changed_props(fileprops),
                                            targetrev)
     self.assertEquals(targetrev.committer, "somebody")
     self.assertEquals(targetrev.properties, {"arevprop": "val"})
     self.assertEquals(targetrev.timestamp, 432432432.0)
     self.assertEquals(targetrev.timezone, 0)
Ejemplo n.º 13
0
 def test_message_revprops(self):
     if not self.mapping.roundtripping:
         raise TestNotApplicable
     if not self.mapping.can_use_revprops:
         raise TestNotApplicable
     revprops = {}
     self.mapping.export_revision_revprops(revprops,
                                           "someuuid",
                                           "branchp",
                                           432432432.0,
                                           0,
                                           "somebody", {"arevprop": "val"},
                                           "arevid",
                                           4, ["merge1"],
                                           testament=None)
     revprops["svn:date"] = "2008-11-03T09:33:00.716938Z"
     try:
         self.mapping.export_message_revprops("My Commit message", revprops)
     except NotImplementedError:
         raise TestNotApplicable
     targetrev = Revision(None)
     self.mapping.import_revision_revprops(revprops, targetrev)
     self.assertEquals("My Commit message", targetrev.message)
Ejemplo n.º 14
0
 def test_revision_revprops_unicode(self):
     if not self.mapping.roundtripping:
         raise TestNotApplicable
     if not self.mapping.can_use_revprops:
         raise TestNotApplicable
     revprops = {}
     self.mapping.export_revision_revprops(revprops,
                                           "someuuid",
                                           "branchp",
                                           432432432.0,
                                           0,
                                           "somebody", {"arevprop": u"vól"},
                                           "arevid",
                                           4, ["parent", "merge1"],
                                           testament=None)
     targetrev = Revision(None)
     revprops["svn:date"] = "2008-11-03T09:33:00.716938Z"
     parse_svn_revprops(revprops, targetrev)
     self.mapping.import_revision_revprops(revprops, targetrev)
     self.assertEquals(targetrev.committer, "somebody")
     self.assertEquals(targetrev.properties, {"arevprop": u"vól"})
     self.assertEquals(targetrev.timestamp, 432432432.0)
     self.assertEquals(targetrev.timezone, 0)
Ejemplo n.º 15
0
 def test_parse_revision_metadata_with_colon(self):
     rev = Revision('someid')
     parse_revision_metadata("committer: some: body\n", rev)
     self.assertEquals(u"some: body", rev.committer)
Ejemplo n.º 16
0
    def setUp(self):
        self.reduceLockdirTimeout()
        super(TestReconcileWithIncorrectRevisionCache, self).setUp()

        t = self.get_transport()
        # we need a revision with two parents in the wrong order
        # which should trigger reinsertion.
        # and another with the first one correct but the other two not
        # which should not trigger reinsertion.
        # these need to be in different repositories so that we don't
        # trigger a reconcile based on the other case.
        # there is no api to construct a broken knit repository at
        # this point. if we ever encounter a bad graph in a knit repo
        # we should add a lower level api to allow constructing such cases.

        # first off the common logic:
        self.first_tree = self.make_branch_and_tree('wrong-first-parent')
        self.second_tree = self.make_branch_and_tree(
            'reversed-secondary-parents')
        for t in [self.first_tree, self.second_tree]:
            t.commit('1', rev_id=b'1')
            uncommit(t.branch, tree=t)
            t.commit('2', rev_id=b'2')
            uncommit(t.branch, tree=t)
            t.commit('3', rev_id=b'3')
            uncommit(t.branch, tree=t)
        #second_tree = self.make_branch_and_tree('reversed-secondary-parents')
        # second_tree.pull(tree) # XXX won't copy the repo?
        repo_secondary = self.second_tree.branch.repository

        # now setup the wrong-first parent case
        repo = self.first_tree.branch.repository
        repo.lock_write()
        repo.start_write_group()
        inv = Inventory(revision_id=b'wrong-first-parent')
        inv.root.revision = b'wrong-first-parent'
        if repo.supports_rich_root():
            root_id = inv.root.file_id
            repo.texts.add_lines((root_id, b'wrong-first-parent'), [], [])
        sha1 = repo.add_inventory(b'wrong-first-parent', inv, [b'2', b'1'])
        rev = Revision(timestamp=0,
                       timezone=None,
                       committer="Foo Bar <*****@*****.**>",
                       message="Message",
                       inventory_sha1=sha1,
                       revision_id=b'wrong-first-parent')
        rev.parent_ids = [b'1', b'2']
        repo.add_revision(b'wrong-first-parent', rev)
        repo.commit_write_group()
        repo.unlock()

        # now setup the wrong-secondary parent case
        repo = repo_secondary
        repo.lock_write()
        repo.start_write_group()
        inv = Inventory(revision_id=b'wrong-secondary-parent')
        inv.root.revision = b'wrong-secondary-parent'
        if repo.supports_rich_root():
            root_id = inv.root.file_id
            repo.texts.add_lines((root_id, b'wrong-secondary-parent'), [], [])
        sha1 = repo.add_inventory(
            b'wrong-secondary-parent', inv, [b'1', b'3', b'2'])
        rev = Revision(timestamp=0,
                       timezone=None,
                       committer="Foo Bar <*****@*****.**>",
                       message="Message",
                       inventory_sha1=sha1,
                       revision_id=b'wrong-secondary-parent')
        rev.parent_ids = [b'1', b'2', b'3']
        repo.add_revision(b'wrong-secondary-parent', rev)
        repo.commit_write_group()
        repo.unlock()
Ejemplo n.º 17
0
 def test_parse_revision_metadata_invalid_name(self):
     rev = Revision('someid')
     self.assertRaises(InvalidPropertyValue,
             lambda: parse_revision_metadata("bla: b", rev))
Ejemplo n.º 18
0
 def test_url_native(self):
     rev = Revision("somerevid")
     revmeta = MockRevmeta({}, 42, "/trunk", "http://some.host")
     self.assertEquals(
         "http://some.host/trunk/somepath",
         keywords['URL']("somerevid", rev, "somepath", revmeta))
Ejemplo n.º 19
0
 def test_author_non_native(self):
     rev = Revision("somerevid")
     rev.committer = "Some Committer <*****@*****.**>"
     self.assertEquals(
         "Some Committer <*****@*****.**>",
         keywords['Author']("somerevid", rev, "somepath", None))
Ejemplo n.º 20
0
 def test_rev_native(self):
     revmeta = MockRevmeta({}, 42, "/trunk", "http://foo.host")
     rev = Revision("somerevid")
     self.assertEquals(
         '42', keywords['Rev']("somerevid", rev, "somepath", revmeta))
Ejemplo n.º 21
0
 def test_rev_not_native_svn(self):
     revid = "svn-v4:612f8ebc-c883-4be0-9ee0-a4e9ef946e3a:trunk:36984"
     rev = Revision(revid)
     self.assertEquals('36984', keywords['Rev'](revid, rev, "somepath",
                                                None))
Ejemplo n.º 22
0
 def test_parse_revision_metadata_specialchar(self):
     rev = Revision('someid')
     parse_revision_metadata("committer: Adeodato Simó <*****@*****.**>", rev)
     self.assertEquals(u"Adeodato Simó <*****@*****.**>", rev.committer)
Ejemplo n.º 23
0
 def test_url_non_native(self):
     rev = Revision("somerevid")
     self.assertEquals("somepath", keywords['URL']("somerevid", rev,
                                                   "somepath", None))
Ejemplo n.º 24
0
 def test_date_revmeta_not_native(self):
     rev = Revision("somerevid")
     rev.timestamp = 43842423
     self.assertEquals('1971-05-23T10:27:03.000000Z',
                       keywords['Date']("somerevid", rev, "somepath", None))
Ejemplo n.º 25
0
 def test_rev_not_native_not_svn(self):
     rev = Revision("somerevid")
     self.assertEquals('somerevid', keywords['Rev']("somerevid", rev,
                                                    "somepath", None))
Ejemplo n.º 26
0
 def test_parse_revision_metadata_timestamp_day(self):
     rev = Revision('someid')
     parse_revision_metadata("timestamp: Thu 2005-06-30 12:38:52.350850105 -0500\n", rev)
     self.assertEquals(1120153132.3508501, rev.timestamp)
     self.assertEquals(-18000, rev.timezone)