当前位置: 首页>>代码示例>>Python>>正文


Python CachedRepository.get_changeset方法代码示例

本文整理汇总了Python中trac.versioncontrol.cache.CachedRepository.get_changeset方法的典型用法代码示例。如果您正苦于以下问题:Python CachedRepository.get_changeset方法的具体用法?Python CachedRepository.get_changeset怎么用?Python CachedRepository.get_changeset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.versioncontrol.cache.CachedRepository的用法示例。


在下文中一共展示了CachedRepository.get_changeset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_changes

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import get_changeset [as 别名]
    def test_get_changes(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        cursor = self.db.cursor()
        cursor.execute("INSERT INTO revision (rev,time,author,message) "
                       "VALUES (0,%s,'','')", (to_timestamp(t1),))
        cursor.execute("INSERT INTO revision (rev,time,author,message) "
                       "VALUES (1,%s,'joe','Import')", (to_timestamp(t2),))
        cursor.executemany("INSERT INTO node_change (rev,path,node_type,"
                           "change_type,base_path,base_rev) "
                           "VALUES ('1',%s,%s,%s,%s,%s)",
                           [('trunk', 'D', 'A', None, None),
                            ('trunk/README', 'F', 'A', None, None)])
        cursor.execute("UPDATE system SET value='1' WHERE name='youngest_rev'")

        repos = Mock(Repository, 'test-repos', None, self.log,
                     get_changeset=lambda x: None,
                     get_youngest_rev=lambda: 1,
                     get_oldest_rev=lambda: 0,
                     next_rev=lambda x: None,
                     normalize_rev=lambda rev: rev)
        cache = CachedRepository(self.db, repos, None, self.log)
        self.assertEqual('1', cache.youngest_rev)
        changeset = cache.get_changeset(1)
        self.assertEqual('joe', changeset.author)
        self.assertEqual('Import', changeset.message)
        self.assertEqual(t2, changeset.date)
        changes = changeset.get_changes()
        self.assertEqual(('trunk', Node.DIRECTORY, Changeset.ADD, None, None),
                         changes.next())
        self.assertEqual(('trunk/README', Node.FILE, Changeset.ADD, None, None),
                         changes.next())
        self.assertRaises(StopIteration, changes.next)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:35,代码来源:cache.py

示例2: test_get_changes

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import get_changeset [as 别名]
    def test_get_changes(self):
        cursor = self.db.cursor()
        cursor.execute("INSERT INTO revision (rev,time,author,message) "
                       "VALUES (0,41000,'','')")
        cursor.execute("INSERT INTO revision (rev,time,author,message) "
                       "VALUES (1,42000,'joe','Import')")
        cursor.executemany("INSERT INTO node_change (rev,path,node_type,"
                           "change_type,base_path,base_rev) "
                           "VALUES ('1',%s,%s,%s,%s,%s)",
                           [('trunk', 'D', 'A', None, None),
                            ('trunk/README', 'F', 'A', None, None)])

        repos = Mock(Repository, 'test-repos', None, self.log,
                     get_changeset=lambda x: None,
                     get_youngest_rev=lambda: 1,
                     next_rev=lambda x: None, normalize_rev=lambda rev: rev)
        cache = CachedRepository(self.db, repos, None, self.log)
        self.assertEqual('1', cache.youngest_rev)
        changeset = cache.get_changeset(1)
        self.assertEqual('joe', changeset.author)
        self.assertEqual('Import', changeset.message)
        self.assertEqual(42000, changeset.date)
        changes = changeset.get_changes()
        self.assertEqual(('trunk', Node.DIRECTORY, Changeset.ADD, None, None),
                         changes.next())
        self.assertEqual(('trunk/README', Node.FILE, Changeset.ADD, None, None),
                         changes.next())
        self.assertRaises(StopIteration, changes.next)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:cache.py

示例3: test_sync_changeset_if_not_exists

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import get_changeset [as 别名]
    def test_sync_changeset_if_not_exists(self):
        t = [
            datetime(2001, 1, 1, 1, 1, 1, 0, utc),  # r0
            datetime(2002, 1, 1, 1, 1, 1, 0, utc),  # r1
            datetime(2003, 1, 1, 1, 1, 1, 0, utc),  # r2
            datetime(2004, 1, 1, 1, 1, 1, 0, utc),  # r3
        ]
        self.preset_cache(
            (("0", to_utimestamp(t[0]), "joe", "**empty**"), []),
            (
                ("1", to_utimestamp(t[1]), "joe", "Import"),
                [("trunk", "D", "A", None, None), ("trunk/README", "F", "A", None, None)],
            ),
            # not exists r2
            (("3", to_utimestamp(t[3]), "joe", "Add COPYING"), [("trunk/COPYING", "F", "A", None, None)]),
        )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)], youngest_rev=3)
        changes = [
            None,  # r0
            [
                ("trunk", Node.DIRECTORY, Changeset.ADD, None, None),  # r1
                ("trunk/README", Node.FILE, Changeset.ADD, None, None),
            ],
            [
                ("branches", Node.DIRECTORY, Changeset.ADD, None, None),  # r2
                ("tags", Node.DIRECTORY, Changeset.ADD, None, None),
            ],
            [("trunk/COPYING", Node.FILE, Changeset.ADD, None, None)],  # r3
        ]
        changesets = [
            Mock(Changeset, repos, 0, "**empty**", "joe", t[0], get_changes=lambda: []),
            Mock(Changeset, repos, 1, "Initial Import", "joe", t[1], get_changes=lambda: iter(changes[1])),
            Mock(Changeset, repos, 2, "Created directories", "john", t[2], get_changes=lambda: iter(changes[2])),
            Mock(Changeset, repos, 3, "Add COPYING", "joe", t[3], get_changes=lambda: iter(changes[3])),
        ]
        cache = CachedRepository(self.env, repos, self.log)
        self.assertRaises(NoSuchChangeset, cache.get_changeset, 2)
        cache.sync()
        self.assertRaises(NoSuchChangeset, cache.get_changeset, 2)

        self.assertEqual(None, cache.sync_changeset(2))
        cset = cache.get_changeset(2)
        self.assertEqual("john", cset.author)
        self.assertEqual("Created directories", cset.message)
        self.assertEqual(t[2], cset.date)
        cset_changes = cset.get_changes()
        self.assertEqual(("branches", Node.DIRECTORY, Changeset.ADD, None, None), cset_changes.next())
        self.assertEqual(("tags", Node.DIRECTORY, Changeset.ADD, None, None), cset_changes.next())
        self.assertRaises(StopIteration, cset_changes.next)

        rows = self.env.db_query("SELECT time,author,message FROM revision ORDER BY rev")
        self.assertEquals(4, len(rows))
        self.assertEquals((to_utimestamp(t[0]), "joe", "**empty**"), rows[0])
        self.assertEquals((to_utimestamp(t[1]), "joe", "Import"), rows[1])
        self.assertEquals((to_utimestamp(t[2]), "john", "Created directories"), rows[2])
        self.assertEquals((to_utimestamp(t[3]), "joe", "Add COPYING"), rows[3])
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:58,代码来源:cache.py

示例4: test_get_changes

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import get_changeset [as 别名]
 def test_get_changes(self):
     t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
     t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
     self.preset_cache(
         (("0", to_utimestamp(t1), "", ""), []),
         (
             ("1", to_utimestamp(t2), "joe", "Import"),
             [("trunk", "D", "A", None, None), ("trunk/RDME", "F", "A", None, None)],
         ),
     )
     repos = self.get_repos()
     cache = CachedRepository(self.env, repos, self.log)
     self.assertEqual("1", cache.youngest_rev)
     changeset = cache.get_changeset(1)
     self.assertEqual("joe", changeset.author)
     self.assertEqual("Import", changeset.message)
     self.assertEqual(t2, changeset.date)
     changes = changeset.get_changes()
     self.assertEqual(("trunk", Node.DIRECTORY, Changeset.ADD, None, None), changes.next())
     self.assertEqual(("trunk/RDME", Node.FILE, Changeset.ADD, None, None), changes.next())
     self.assertRaises(StopIteration, changes.next)
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:23,代码来源:cache.py

示例5: test_get_changes

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import get_changeset [as 别名]
 def test_get_changes(self):
     t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
     t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
     self.preset_cache(
         (('0', to_utimestamp(t1), '', ''), []),
         (('1', to_utimestamp(t2), 'joe', 'Import'),
          [('trunk', 'D', 'A', None, None),
           ('trunk/RDME', 'F', 'A', None, None)]),
         )
     repos = self.get_repos()
     cache = CachedRepository(self.env, repos, self.log)
     self.assertEqual('1', cache.youngest_rev)
     changeset = cache.get_changeset(1)
     self.assertEqual('joe', changeset.author)
     self.assertEqual('Import', changeset.message)
     self.assertEqual(t2, changeset.date)
     changes = changeset.get_changes()
     self.assertEqual(('trunk', Node.DIRECTORY, Changeset.ADD, None, None),
                      changes.next())
     self.assertEqual(('trunk/RDME', Node.FILE, Changeset.ADD, None, None),
                      changes.next())
     self.assertRaises(StopIteration, changes.next)
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:24,代码来源:cache.py

示例6: test_sync_changeset_if_not_exists

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import get_changeset [as 别名]
    def test_sync_changeset_if_not_exists(self):
        t = [
            datetime(2001, 1, 1, 1, 1, 1, 0, utc), # r0
            datetime(2002, 1, 1, 1, 1, 1, 0, utc), # r1
            datetime(2003, 1, 1, 1, 1, 1, 0, utc), # r2
            datetime(2004, 1, 1, 1, 1, 1, 0, utc), # r3
        ]
        self.preset_cache(
            (('0', to_utimestamp(t[0]), 'joe', '**empty**'), []),
            (('1', to_utimestamp(t[1]), 'joe', 'Import'),
             [('trunk', 'D', 'A', None, None),
              ('trunk/README', 'F', 'A', None, None)]),
            # not exists r2
            (('3', to_utimestamp(t[3]), 'joe', 'Add COPYING'),
             [('trunk/COPYING', 'F', 'A', None, None)]),
            )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)],
                               youngest_rev=3)
        changes = [
            None,                                                       # r0
            [('trunk', Node.DIRECTORY, Changeset.ADD, None, None),      # r1
             ('trunk/README', Node.FILE, Changeset.ADD, None, None)],
            [('branches', Node.DIRECTORY, Changeset.ADD, None, None),   # r2
             ('tags', Node.DIRECTORY, Changeset.ADD, None, None)],
            [('trunk/COPYING', Node.FILE, Changeset.ADD, None, None)],  # r3
        ]
        changesets = [
            Mock(Changeset, repos, 0, '**empty**', 'joe', t[0],
                 get_changes=lambda: []),
            Mock(Changeset, repos, 1, 'Initial Import', 'joe', t[1],
                 get_changes=lambda: iter(changes[1])),
            Mock(Changeset, repos, 2, 'Created directories', 'john', t[2],
                 get_changes=lambda: iter(changes[2])),
            Mock(Changeset, repos, 3, 'Add COPYING', 'joe', t[3],
                 get_changes=lambda: iter(changes[3])),
            ]
        cache = CachedRepository(self.env, repos, self.log)
        self.assertRaises(NoSuchChangeset, cache.get_changeset, 2)
        cache.sync()
        self.assertRaises(NoSuchChangeset, cache.get_changeset, 2)

        self.assertEqual(None, cache.sync_changeset(2))
        cset = cache.get_changeset(2)
        self.assertEqual('john', cset.author)
        self.assertEqual('Created directories', cset.message)
        self.assertEqual(t[2], cset.date)
        cset_changes = cset.get_changes()
        self.assertEqual(('branches', Node.DIRECTORY, Changeset.ADD, None,
                          None),
                         cset_changes.next())
        self.assertEqual(('tags', Node.DIRECTORY, Changeset.ADD, None, None),
                         cset_changes.next())
        self.assertRaises(StopIteration, cset_changes.next)

        rows = self.env.db_query(
                "SELECT time,author,message FROM revision ORDER BY rev")
        self.assertEquals(4, len(rows))
        self.assertEquals((to_utimestamp(t[0]), 'joe', '**empty**'), rows[0])
        self.assertEquals((to_utimestamp(t[1]), 'joe', 'Import'), rows[1])
        self.assertEquals((to_utimestamp(t[2]), 'john', 'Created directories'),
                          rows[2])
        self.assertEquals((to_utimestamp(t[3]), 'joe', 'Add COPYING'), rows[3])
开发者ID:thimalk,项目名称:bloodhound,代码行数:64,代码来源:cache.py


注:本文中的trac.versioncontrol.cache.CachedRepository.get_changeset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。