def make_pickle(self, *changes, **kwargs):
     recode_fn = kwargs.pop('recode_fn', None)
     cm = OldChangeMaster()
     cm.changes = changes
     if recode_fn:
         recode_fn(cm)
     cPickle.dump(cm, open(self.changes_pickle, "wb"))
Beispiel #2
0
 def make_pickle(self, *changes, **kwargs):
     recode_fn = kwargs.pop('recode_fn', None)
     cm = OldChangeMaster()
     cm.changes = changes
     if recode_fn:
         recode_fn(cm)
     cPickle.dump(cm, open(self.changes_pickle, "wb"))
Beispiel #3
0
    def testUTF16Change(self):
        # Create changes.pck
        cm = OldChangeMaster()
        cm.changes = [
            Change(who=u"Frosty the \N{SNOWMAN}".encode("utf16"),
                   files=["foo"],
                   comments=u"Frosty the \N{SNOWMAN}".encode("utf16"),
                   branch="b1",
                   revision=12345)
        ]

        # instead of running contrib/fix_changes_pickle_encoding.py, we just call
        # the changemanager's recode_changes directly - it's the function at the
        # heart of the script anyway.
        cm.recode_changes('utf16', quiet=True)

        # and dump the recoded changemanager to changes.pck before trying a schema upgrade
        cPickle.dump(cm, open(os.path.join(self.basedir, "changes.pck"), "w"))

        sm = manager.DBSchemaManager(self.spec, self.basedir)
        sm.upgrade(quiet=True)

        c = self.db.getChangeNumberedNow(1)

        self.assertEquals(c.who, u"Frosty the \N{SNOWMAN}")
        self.assertEquals(c.comments, u"Frosty the \N{SNOWMAN}")
    def testUTF16Change(self):
        # Create changes.pck
        cm = OldChangeMaster()
        cm.changes = [
            Change(
                who=u"Frosty the \N{SNOWMAN}".encode("utf16"),
                files=["foo"],
                comments=u"Frosty the \N{SNOWMAN}".encode("utf16"),
                branch="b1",
                revision=12345,
            )
        ]

        # instead of running contrib/fix_changes_pickle_encoding.py, we just call
        # the changemanager's recode_changes directly - it's the function at the
        # heart of the script anyway.
        cm.recode_changes("utf16", quiet=True)

        # and dump the recoded changemanager to changes.pck before trying a schema upgrade
        cPickle.dump(cm, open(os.path.join(self.basedir, "changes.pck"), "w"))

        sm = manager.DBSchemaManager(self.spec, self.basedir)
        sm.upgrade(quiet=True)

        c = self.db.getChangeNumberedNow(1)

        self.assertEquals(c.who, u"Frosty the \N{SNOWMAN}")
        self.assertEquals(c.comments, u"Frosty the \N{SNOWMAN}")
Beispiel #5
0
 def create_pickle(self):
     # ugh, what was I thinking? pickles? with class instances? ick.
     cm = OldChangeMaster()
     cm.basedir = "db/migrate"
     os.makedirs(cm.basedir)
     c1 = Change(who="brian", files=["foo.c", "subdir/bar.c"],
                 comments="first change",
                 revision="1234")
     del c1.revlink
     c2 = Change(who="brian", files=["foo.c"],
                 comments="second change",
                 revision="1235", branch="release",
                 links=["url1", "url2"], revlink="url3",
                 properties={"who": "what"},
                 category="nifty")
     cm.addChange(c1)
     cm.addChange(c2)
     cm.saveYourself() # db/migrate/changes.pck
     return os.path.join(cm.basedir, "changes.pck")