コード例 #1
0
ファイル: config.py プロジェクト: yut148/tailor
    def testBasicConfig(self):
        """Verify the basic configuration mechanism"""

        from os import getcwd
        from os.path import expanduser

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})

        self.assertEqual(config.projects(), ['project2'])
        self.assertRaises(ConfigurationError, Project, 'project2', config)

        project1 = Project('project1', config)
        self.assertEqual(project1.rootdir, self.TESTDIR)
        self.assertEqual(project1.source.name, 'svn:project1repo')
        self.assertEqual(project1.target.name, 'darcs:project1')
        self.assertEqual(project1.target.repository,
                         expanduser('~/darcs/project1'))

        project4 = Project('project4', config)
        self.assertEqual(project4.rootdir, getcwd())

        self.assert_(config.namespace.has_key('maybe_skip'))
        self.assert_(config.namespace['refill'] in project1.before_commit)
        self.assertEqual(len(project1.after_commit), 1)
コード例 #2
0
ファイル: config.py プロジェクト: yut148/tailor
    def testStateFileName(self):
        """Verify that the state file is computed the way it should"""

        from os.path import expanduser, join

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})

        project1 = Project('project1', config)
        self.assertEqual(project1.state_file.filename,
                         join(self.TESTDIR, 'project1.state'))
        project3 = Project('project3', config)
        self.assertEqual(project3.state_file.filename,
                         join(self.TESTDIR, '_darcs', 'tailor.state'))
        project4 = Project('project4', config)
        self.assertEqual(project4.state_file.filename,
                         expanduser('~/tailorize/project4.state'))
        project6 = Project('project6', config)
        self.assertEqual(project6.state_file.filename,
                         expanduser('~/tailorizedp/project6/.hg/tailor.state'))

        config = Config(self.getTestConfiguration("config-sf_test"), {})
        sbcl = Project('sbcl', config)
        self.assertEqual(sbcl.state_file.filename,
                         expanduser('~/tmp/test-tailor/sbcl/.hg/tailor.state'))
コード例 #3
0
    def setUp(self):
        from os import mkdir, getcwd
        from os.path import exists, split, join
        from tempfile import gettempdir
        from atexit import register
        from shutil import rmtree
        from vcpx.tests import DEBUG

        self.TESTDIR = join(gettempdir(), 'tailor-tests')

        tailor_repo = getcwd()
        while tailor_repo != split(tailor_repo)[0] and not exists(
                join(tailor_repo, '_darcs')):
            tailor_repo = split(tailor_repo)[0]
        assert exists(join(tailor_repo,
                           '_darcs')), "Tailor Darcs repository not found!"
        self.tailor_repo = tailor_repo
        self.config = Config(StringIO(__doc__), {
            'tailor_repo': tailor_repo,
            'testdir': self.TESTDIR,
            'verbose': DEBUG
        })

        if not exists(self.TESTDIR):
            mkdir(self.TESTDIR)
            register(rmtree, self.TESTDIR)
コード例 #4
0
ファイル: config.py プロジェクト: yut148/tailor
    def testWithLogging(self):
        """Verify a configuration containing also a [[logging]] section"""

        from logging import getLogger

        config = Config(self.getTestConfiguration("config-with_logging"), {})

        logger = getLogger()
        self.assertEqual(logger.handlers[0].formatter._fmt, 'DUMMY')
コード例 #5
0
ファイル: config.py プロジェクト: yut148/tailor
    def testBadChars(self):
        """Test how the config parser loads the badchar mapping"""

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})
        project4 = Project('project4', config)
        self.assert_(project4.target.replace_badchars.has_key('\xc1'))
        project6 = Project('project6', config)
        self.assertEqual(project6.source.replace_badchars['a'], 'b')
コード例 #6
0
ファイル: config.py プロジェクト: yut148/tailor
    def testTagEntries(self):
        """Verify the darcs Repository knows when force CVS tag on entries"""

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})

        project5 = Project('project5', config)
        self.assertEqual(project5.source.tag_entries, True)
        self.assertEqual(project5.target.tag_entries, False)
コード例 #7
0
ファイル: config.py プロジェクト: yut148/tailor
    def testLookForAdds(self):
        """Verify the darcs Repository knows about --look-for-adds"""

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})

        project3 = Project('project3', config)
        self.assertEqual(project3.target.command('record', '-a'),
                         ['darcs', 'record', '-a'])
        project4 = Project('project4', config)
        self.assertEqual(project4.target.command('record', '-a'),
                         ['darcs', 'record', '-a', '--look-for-adds'])
コード例 #8
0
ファイル: fixed_bugs.py プロジェクト: yut148/tailor
    def run_tailor(self, assert_function=None):
        test_name = self.test_name

        for vcs in self.target_vcs:
            subdir = self.shared_basedirs and '#' or 'subdir = %s' % vcs
            test_dir = join(self.test_dir, vcs)
            config = Config(StringIO(self.CONFIG % vars()), {})
            project = Tailorizer(test_name, config)
            project.workingDir().source.changesets = self.source_changesets
            project()

            if assert_function is not None:
                assert_function(project, vcs)
コード例 #9
0
ファイル: config.py プロジェクト: lelit/tailor
    def testBasicConfig(self):
        """Verify the basic configuration mechanism"""

        from os import getcwd
        from os.path import expanduser

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})

        self.assertEqual(config.projects(), ['project2'])
        self.assertRaises(ConfigurationError, Project, 'project2', config)

        project1 = Project('project1', config)
        self.assertEqual(project1.rootdir, self.TESTDIR)
        self.assertEqual(project1.source.name, 'svn:project1repo')
        self.assertEqual(project1.target.name, 'darcs:project1')
        self.assertEqual(project1.target.repository, expanduser('~/darcs/project1'))

        project4 = Project('project4', config)
        self.assertEqual(project4.rootdir, getcwd())

        self.assert_(config.namespace.has_key('maybe_skip'))
        self.assert_(config.namespace['refill'] in project1.before_commit)
        self.assertEqual(len(project1.after_commit), 1)
コード例 #10
0
ファイル: config.py プロジェクト: yut148/tailor
    def testSharedDirs(self):
        """Verify the shared-dir switch"""

        config = Config(self.getTestConfiguration("config-basic_test"),
                        {'tailor_repo': self.tailor_repo})

        project1 = Project('project1', config)
        wd = project1.workingDir()
        self.assert_(wd.shared_basedirs)

        project3 = Project('project3', config)
        wd = project3.workingDir()
        self.assert_(wd.shared_basedirs)

        project4 = Project('project4', config)
        wd = project4.workingDir()
        self.assert_(not wd.shared_basedirs)
コード例 #11
0
ファイル: tailor.py プロジェクト: c0ns0le/cygwin
def main():
    """
    Script entry point.

    Parse the command line options and arguments, and for each
    specified working copy directory (the current working directory by
    default) execute the tailorization steps.
    """

    import sys
    from os import getcwd

    parser = OptionParser(usage='%prog [options] [project ...]',
                          version=__version__,
                          option_list=GENERAL_OPTIONS)

    bsoptions = OptionGroup(parser, "Bootstrap options")
    bsoptions.add_options(BOOTSTRAP_OPTIONS)

    upoptions = OptionGroup(parser, "Update options")
    upoptions.add_options(UPDATE_OPTIONS)

    vcoptions = OptionGroup(parser, "VC specific options")
    vcoptions.add_options(VC_SPECIFIC_OPTIONS)

    parser.add_option_group(bsoptions)
    parser.add_option_group(upoptions)
    parser.add_option_group(vcoptions)

    options, args = parser.parse_args()

    defaults = {}
    for k,v in options.__dict__.items():
        if k.startswith('__'):
            continue
        if k <> 'configfile' and hasattr(options, '__seen_' + k):
            defaults[k.replace('_', '-')] = str(v)

    if options.configfile or (len(sys.argv)==2 and len(args)==1):
        # Either we have a --configfile, or there are no options
        # and a single argument (to support shebang style scripts)

        if not options.configfile:
            options.configfile = sys.argv[1]
            args = None

        config = Config(open(options.configfile), defaults)

        if not args:
            args = config.projects()

        for projname in args:
            tailorizer = Tailorizer(projname, config)
            try:
                tailorizer()
            except GetUpstreamChangesetsFailure:
                # Do not stop on this kind of error, but keep going
                pass
    else:
        for omit in ['source-kind', 'target-kind',
                     'source-module', 'target-module',
                     'source-repository', 'target-repository',
                     'start-revision', 'subdir']:
            if omit in defaults:
                del defaults[omit]

        config = Config(None, defaults)

        config.add_section('project')
        source = options.source_kind + ':source'
        config.set('project', 'source', source)
        target = options.target_kind + ':target'
        config.set('project', 'target', target)
        config.set('project', 'root-directory', getcwd())
        config.set('project', 'subdir', options.subdir or '.')
        config.set('project', 'state-file', 'tailor.state')
        config.set('project', 'start-revision', options.start_revision)

        config.add_section(source)
        if options.source_repository:
            config.set(source, 'repository', options.source_repository)
        else:
            logger = getLogger('tailor')
            logger.warning("By any chance you forgot either the --source-repository or the --configfile option...")

        if options.source_module:
            config.set(source, 'module', options.source_module)

        config.add_section(target)
        if options.target_repository:
            config.set(target, 'repository', options.target_repository)
        if options.target_module:
            config.set(target, 'module', options.target_module)

        if options.verbose:
            sys.stderr.write("You should put the following configuration "
                             "in some file, adjust it as needed\n"
                             "and use --configfile option with that "
                             "file as argument:\n")
            config.write(sys.stdout)

        if options.debug:
            tailorizer = Tailorizer('project', config)
            tailorizer()
        elif not options.verbose:
            sys.stderr.write("Operation not performed, try --verbose\n")
コード例 #12
0
ファイル: tailor.py プロジェクト: saminigod/cygwin
def main():
    """
    Script entry point.

    Parse the command line options and arguments, and for each
    specified working copy directory (the current working directory by
    default) execute the tailorization steps.
    """

    import sys
    from os import getcwd

    parser = OptionParser(usage='%prog [options] [project ...]',
                          version=__version__,
                          option_list=GENERAL_OPTIONS)

    bsoptions = OptionGroup(parser, "Bootstrap options")
    bsoptions.add_options(BOOTSTRAP_OPTIONS)

    upoptions = OptionGroup(parser, "Update options")
    upoptions.add_options(UPDATE_OPTIONS)

    vcoptions = OptionGroup(parser, "VC specific options")
    vcoptions.add_options(VC_SPECIFIC_OPTIONS)

    parser.add_option_group(bsoptions)
    parser.add_option_group(upoptions)
    parser.add_option_group(vcoptions)

    options, args = parser.parse_args()

    defaults = {}
    for k, v in options.__dict__.items():
        if k.startswith('__'):
            continue
        if k <> 'configfile' and hasattr(options, '__seen_' + k):
            defaults[k.replace('_', '-')] = str(v)

    if options.configfile or (len(sys.argv) == 2 and len(args) == 1):
        # Either we have a --configfile, or there are no options
        # and a single argument (to support shebang style scripts)

        if not options.configfile:
            options.configfile = sys.argv[1]
            args = None

        config = Config(open(options.configfile), defaults)

        if not args:
            args = config.projects()

        for projname in args:
            tailorizer = Tailorizer(projname, config)
            try:
                tailorizer()
            except GetUpstreamChangesetsFailure:
                # Do not stop on this kind of error, but keep going
                pass
    else:
        for omit in [
                'source-kind', 'target-kind', 'source-module', 'target-module',
                'source-repository', 'target-repository', 'start-revision',
                'subdir'
        ]:
            if omit in defaults:
                del defaults[omit]

        config = Config(None, defaults)

        config.add_section('project')
        source = options.source_kind + ':source'
        config.set('project', 'source', source)
        target = options.target_kind + ':target'
        config.set('project', 'target', target)
        config.set('project', 'root-directory', getcwd())
        config.set('project', 'subdir', options.subdir or '.')
        config.set('project', 'state-file', 'tailor.state')
        config.set('project', 'start-revision', options.start_revision)

        config.add_section(source)
        if options.source_repository:
            config.set(source, 'repository', options.source_repository)
        else:
            logger = getLogger('tailor')
            logger.warning(
                "By any chance you forgot either the --source-repository or the --configfile option..."
            )

        if options.source_module:
            config.set(source, 'module', options.source_module)

        config.add_section(target)
        if options.target_repository:
            config.set(target, 'repository', options.target_repository)
        if options.target_module:
            config.set(target, 'module', options.target_module)

        if options.verbose:
            sys.stderr.write("You should put the following configuration "
                             "in some file, adjust it as needed\n"
                             "and use --configfile option with that "
                             "file as argument:\n")
            config.write(sys.stdout)

        if options.debug:
            tailorizer = Tailorizer('project', config)
            tailorizer()
        elif not options.verbose:
            sys.stderr.write("Operation not performed, try --verbose\n")