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


Python CachedRepository.sync_changeset方法代码示例

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


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

示例1: test_sync_changeset

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import sync_changeset [as 别名]
    def test_sync_changeset(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/README', 'F', 'A', None, None)]),
            )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)],
                               youngest_rev=1)
        changes1 = [('trunk', Node.DIRECTORY, Changeset.ADD, None, None),
                    ('trunk/README', Node.FILE, Changeset.ADD, None, None)]
        changesets = [
            Mock(Changeset, repos, 0, '**empty**', 'joe', t1,
                 get_changes=lambda: []),
            Mock(Changeset, repos, 1, 'Initial Import', 'joe', t2,
                 get_changes=lambda: iter(changes1)),
            ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync_changeset(0)

        cursor = self.db.cursor()
        cursor.execute("SELECT time,author,message FROM revision ORDER BY rev")
        self.assertEquals((to_utimestamp(t1), 'joe', '**empty**'),
                          cursor.fetchone())
        self.assertEquals((to_utimestamp(t2), 'joe', 'Import'),
                          cursor.fetchone())
        self.assertEquals(None, cursor.fetchone())
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:31,代码来源:cache.py

示例2: test_sync_changeset

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import sync_changeset [as 别名]
    def test_sync_changeset(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/README", "F", "A", None, None)],
            ),
        )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)], youngest_rev=1)
        changes1 = [
            ("trunk", Node.DIRECTORY, Changeset.ADD, None, None),
            ("trunk/README", Node.FILE, Changeset.ADD, None, None),
        ]
        changesets = [
            Mock(Changeset, repos, 0, "**empty**", "joe", t1, get_changes=lambda: []),
            Mock(Changeset, repos, 1, "Initial Import", "joe", t2, get_changes=lambda: iter(changes1)),
        ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync_changeset(0)

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

示例3: test_sync_changeset_if_not_exists

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import sync_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_sync_changeset_if_not_exists

# 需要导入模块: from trac.versioncontrol.cache import CachedRepository [as 别名]
# 或者: from trac.versioncontrol.cache.CachedRepository import sync_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.sync_changeset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。