view svnwrap/tests/test_svnwrap.py @ 131:4d42dbbb5127

hg_delta_editor: fix parent revision detection on branch copy Project items copyfrom revisions are irrelevant to parent revision detection, only the project one or those of its ancestors matter. Items copyfrom is useful when retrieving items content. Former code resulted in incorrect converted graph for pyglet repository, especially on the following revision: ------------------------------------------------------------------------ r274 | r1chardj0n3s | 2006-12-21 02:02:14 +0100 (Jeu, 21 Dec 2006) | 2 lines Changed paths: A /branches/richard-glx-version (from /trunk:269) M /branches/richard-glx-version/pyglet/window/xlib/__init__.py R /branches/richard-glx-version/tests/test.py (from /trunk/tests/test.py:270) R /branches/richard-glx-version/tools/info.py (from /trunk/tools/info.py:272) R /branches/richard-glx-version/website/get_involved.php (from /trunk/website/get_involved.php:273) Branching to horribly mangle GLX
author Patrick Mezard <pmezard@gmail.com>
date Wed, 10 Dec 2008 11:03:22 -0600
parents bfbce70a9a57
children 9ad5cf45e30c
line wrap: on
line source

import os
import popen2
import shutil
import tempfile
import unittest

from nose import tools

import svnwrap

class TestBasicRepoLayout(unittest.TestCase):
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp('svnwrap_test')
        self.repo_path = '%s/testrepo' % self.tmpdir
        os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', 
                                           self.repo_path,])
        proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,])
        inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', 
                                'project_root_at_repo_root.svndump'))
        proc.tochild.write(inp.read())
        proc.tochild.close()
        proc.wait()
        self.repo = svnwrap.SubversionRepo('file://%s' % self.repo_path)

    def tearDown(self):
        shutil.rmtree(self.tmpdir)


    def test_num_revs(self):
        revs = list(self.repo.revisions())
        tools.eq_(len(revs), 7)
        r = revs[1]
        tools.eq_(r.revnum, 2)
        tools.eq_(sorted(r.paths.keys()),
                  ['trunk/alpha', 'trunk/beta', 'trunk/delta'])
        for r in revs:
            for p in r.paths:
                # make sure these paths are always non-absolute for sanity
                if p:
                    assert p[0] != '/'
        revs = list(self.repo.revisions(start=3))
        tools.eq_(len(revs), 4)


    def test_branches(self):
        tools.eq_(self.repo.branches.keys(), ['crazy', 'more_crazy'])
        tools.eq_(self.repo.branches['crazy'], ('trunk', 2, 4))
        tools.eq_(self.repo.branches['more_crazy'], ('trunk', 5, 7))


    def test_tags(self):
        tags = self.repo.tags
        tools.eq_(tags.keys(), ['rev1'])
        tools.eq_(tags['rev1'], ('trunk', 2))

class TestRootAsSubdirOfRepo(TestBasicRepoLayout):
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp('svnwrap_test')
        self.repo_path = '%s/testrepo' % self.tmpdir
        os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', 
                                           self.repo_path,])
        proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,])
        inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', 
                                'project_root_not_repo_root.svndump'))
        proc.tochild.write(inp.read())
        proc.tochild.close()
        proc.wait()
        self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' % 
                                           self.repo_path)