Пример #1
0
 def createProduct(self, product):
     """Create a product tree."""
     product_url = '%s/products/%s' % (self.svnroot, product)
     logger.info('createProduct %s' % product_url)
     command('svn mkdir -m"create" %s %s/trunk %s/tags %s/branches' % (
         product_url, product_url, product_url, product_url))
     return product_url + '/trunk'
Пример #2
0
 def createProduct(self, product):
     """Create a product tree."""
     product_url = '%s/products/%s' % (self.svnroot, product)
     logger.info('createProduct %s' % product_url)
     command('svn mkdir -m"create" %s %s/trunk %s/tags %s/branches' %
             (product_url, product_url, product_url, product_url))
     return product_url + '/trunk'
Пример #3
0
    def createBundle(self, bundle, products):
        """Create a bundle with products."""
        svnroot = self.svnroot
        bundle_url = '%s/bundles/%s' % (svnroot, bundle)
        logger.info('createBundle %s' % bundle_url)
        command('svn mkdir -m"create" %s %s/trunk %s/tags %s/branches' %
                (bundle_url, bundle_url, bundle_url, bundle_url))
        bundle_url = bundle_url + '/trunk'
        bundle_path = self.coBundle(bundle)

        externals = os.path.join(bundle_path, SVN_EXTERNALS)
        f = open(externals, 'w+')
        products_url = []
        for product in products:
            product_url = self.createProduct(product)
            products_url.append(product_url)
            f.write('%s %s\n' % (product, product_url))
        f.close()
        command('svn ps svn:externals -F %s %s' % (externals, bundle_path))
        command('svn add %s' % externals)
        command('svn commit -m"setup externals" %s' % bundle_path)
        command('svn up %s' % bundle_path)
        return bundle_url, products_url
Пример #4
0
    def createBundle(self, bundle, products):
        """Create a bundle with products."""
        svnroot = self.svnroot
        bundle_url = '%s/bundles/%s' % (svnroot, bundle)
        logger.info('createBundle %s' % bundle_url)
        command('svn mkdir -m"create" %s %s/trunk %s/tags %s/branches' % (
            bundle_url, bundle_url, bundle_url, bundle_url))
        bundle_url = bundle_url + '/trunk'
        bundle_path = self.coBundle(bundle)

        externals = os.path.join(bundle_path, SVN_EXTERNALS)
        f = open(externals, 'w+')
        products_url = []
        for product in products:
            product_url = self.createProduct(product)
            products_url.append(product_url)
            f.write('%s %s\n' % (product, product_url))
        f.close()
        command('svn ps svn:externals -F %s %s' % (externals, bundle_path))
        command('svn add %s' % externals)
        command('svn commit -m"setup externals" %s' % bundle_path)
        command('svn up %s' % bundle_path)
        return bundle_url, products_url
Пример #5
0
 def __init__(self):
     root = mkdtemp(prefix="bm-")
     logger.info('SvnSandBox root: %s' % root)
     self.root = root
     self.coroot = os.path.join(root, 'co')
     os.mkdir(self.coroot)
     os.mkdir(os.path.join(root, 'tmp'))
     svnroot = os.path.join(root, 'svn')
     command('svnadmin create %s' % svnroot)
     svnroot = 'file://' + svnroot
     self.svnroot = svnroot
     command('svn mkdir -m"create" %s/bundles' % svnroot)
     command('svn mkdir -m"create"  %s/products' % svnroot)
Пример #6
0
 def __init__(self):
     root = mkdtemp(prefix="bm-")
     logger.info('SvnSandBox root: %s' % root)
     self.root = root
     self.coroot = os.path.join(root, 'co')
     os.mkdir(self.coroot)
     os.mkdir(os.path.join(root, 'tmp'))
     svnroot = os.path.join(root, 'svn')
     command('svnadmin create %s' % svnroot)
     svnroot = 'file://' + svnroot
     self.svnroot = svnroot
     command('svn mkdir -m"create" %s/bundles' % svnroot)
     command('svn mkdir -m"create"  %s/products' % svnroot)
Пример #7
0
    def test_productman(self):
        name = 'foo'
        svn = SvnSandBox()
        url = svn.createProduct(name)
        path = svn.coProduct(name)
        pman = ProductMan(path, force=True)
        pman.analyze()
        self.assert_(pman.url, url)

        # init product version 0.0.0
        pman.init()

        pman.analyze()
        self.assert_(os.path.exists(os.path.join(path, 'VERSION')))
        self.assert_(os.path.exists(os.path.join(path, 'HISTORY')))
        self.assert_(os.path.exists(os.path.join(path, 'CHANGES')))
        self.assertEquals(pman.status, 'new_version')

        # package product the first package is 0.1.0
        pman.doAction()

        pman.analyze()
        self.assertEquals(pman.status, 'use_tag')
        self.assertEquals(pman.version, [name, '0.1.0', '1'])

        rev_0_1_0 = pman.revision

        # changes something
        file_name = os.path.join(path, 'foo')
        f = open(file_name, 'w+')
        f.write('touch\n')
        f.close()

        # non svn versioned file doesn't change status whatever force mode is
        pman.analyze(force=True)
        self.assertEquals(pman.status, 'use_tag')
        force_bak = pman.force
        pman.force = False
        self.assertEquals(pman.getStatus(), 'use_tag')
        pman.force = force_bak

        command('svn add %s' % file_name)
        command('svn commit -m"add file" %s' % file_name)

        pman.analyze(force=True)
        self.assertEquals(pman.status, 'svn_not_uptodate')

        command('svn up %s' % path)
        pman.analyze(force=True)
        self.assertEquals(pman.status, 'missing_changes')

        # in force mode, local modifications of svn versioned files are ok
        # in non force mode, user has to check in before packaging
        f = open(file_name, 'w+')
        f.write('new touch\n')
        f.close()
        pman.analyze(force=True)
        self.assertEquals(pman.status, 'missing_changes')
        force_bak = pman.force
        pman.force = False
        self.assertEquals(pman.getStatus(), 'svn_not_uptodate')
        pman.force = force_bak
        # reverting local modifications
        command('svn revert %s' % file_name)

        # jump in the past back to rev_0_1_0
        command('svn up -r%s %s' % (rev_0_1_0, path))
        # the wc is not up to date with the svn repo
        pman.analyze(force=True)
        self.assertEquals(pman.revision, rev_0_1_0)
        self.assertEquals(pman.status, 'svn_not_uptodate')
        # back to the present
        command('svn up %s' % path)

        changes = os.path.join(path, 'CHANGES')
        f = open(changes, 'w+')
        f.write(pman.tpl_changes % 'something change')
        f.close()
        command('svn commit -m"update" %s' % changes)
        command('svn up %s' % path)

        pman.analyze(force=True)
        self.assertEquals(pman.status, 'new_version')
        self.assertEquals(pman.version_new[1], '0.2.0')

        # package
        pman.doAction()
        self.assertEquals(pman.status, 'use_tag')
        self.assertEquals(pman.version[1], '0.2.0')

        # package twice should not do anything
        pman.analyze(force=True)
        pman.doAction()
        self.assertEquals(pman.version[1], '0.2.0')

        # create a branch
        branch_name = 'user-refactor'
        branch_url = url.replace('/trunk', '/branches/' + branch_name)
        branch_path = path + '-' + branch_name
        command('svn cp -m"create a branch" %s %s' % (url, branch_url))
        command('svn co %s %s' % (branch_url, branch_path))

        pman = ProductMan(branch_path)
        pman.analyze()

        self.assert_(pman.url, branch_url)
        self.assertEquals(pman.status, 'use_tag')

        # change something
        changes = os.path.join(branch_path, 'CHANGES')
        f = open(changes, 'w+')
        f.write(pman.tpl_changes % 'branch changes')
        f.close()
        command('svn commit -m"change" %s' % changes)
        command('svn up %s' % branch_path)

        # package
        pman.analyze(force=True)
        pman.doAction()
        self.assertEquals(pman.status, 'use_tag')
        self.assertEquals(pman.version[1], '0.3.0-user-refactor')
Пример #8
0
 def upProduct(self, product_path):
     """Svn up a product path."""
     command('svn up %s' % product_path)
Пример #9
0
 def coProduct(self, product, tag='trunk'):
     """Check out a product."""
     product_path = '%s/%s' % (self.coroot, product)
     command('svn co %s/products/%s/%s %s' %
             (self.svnroot, product, tag, product_path))
     return product_path
Пример #10
0
 def coBundle(self, bundle, tag='trunk'):
     """Check out a bundle."""
     bundle_path = '%s/%s' % (self.coroot, bundle)
     command('svn co %s/bundles/%s/%s %s' %
             (self.svnroot, bundle, tag, bundle_path))
     return bundle_path
Пример #11
0
    def test_bundleman(self):
        name = 'app'
        products = ('foo', 'bar')
        svn = SvnSandBox()
        url, products_url = svn.createBundle(name, products)

        path = svn.coBundle(name)
        # init products
        for product in products:
            pman = ProductMan(os.path.join(path, product), force=True)
            pman.init()

        # release 1
        release_tag1 = name.upper()+'rc1'
        release_tag2 = name.upper()+'rc2'
        release_tag3 = name.upper()

        bman = BundleMan(path, release_tag1)
        bman.doAction()
        bman.buildArchive(svn.coroot)

        # branch to patch release 1
        bman.analyze(force=True)
        branch_url = bman.branch()

        # co
        branch_path = os.path.join(svn.coroot, release_tag1+'-branch')
        command('svn co %s %s' % (branch_url, branch_path))

        # change something
        prod_branch_path = os.path.join(branch_path, products[0])
        changes = os.path.join(prod_branch_path, 'CHANGES')
        f = open(changes, 'w+')
        f.write(pman.tpl_changes % 'branch changes')
        f.close()
        command('svn commit -m"change" %s' % changes)
        command('svn up %s' % branch_path)

        # release 2
        bman = BundleMan(branch_path, release_tag2)
        bman.doAction()


        # branch to patch release 2
        bman.analyze(force=True)
        branch_url = bman.branch()

        # co
        branch_path = os.path.join(svn.coroot, release_tag2+'-branch')
        command('svn co %s %s' % (branch_url, branch_path))

        # change something
        prod_branch_path = os.path.join(branch_path, products[0])
        changes = os.path.join(prod_branch_path, 'CHANGES')
        f = open(changes, 'w+')
        f.write(pman.tpl_changes % 'branch changes')
        f.close()
        command('svn commit -m"change" %s' % changes)
        command('svn up %s' % branch_path)

        # release 3
        bman = BundleMan(branch_path, release_tag3)
        bman.doAction()
        bman.addChangelog(release_tag1, release_tag3)
        bman.buildArchive(svn.coroot)
Пример #12
0
    def test_productman(self):
        name = 'foo'
        svn = SvnSandBox()
        url = svn.createProduct(name)
        path = svn.coProduct(name)
        pman = ProductMan(path, force=True)
        pman.analyze()
        self.assert_(pman.url, url)

        # init product version 0.0.0
        pman.init()

        pman.analyze()
        self.assert_(os.path.exists(os.path.join(path, 'VERSION')))
        self.assert_(os.path.exists(os.path.join(path, 'HISTORY')))
        self.assert_(os.path.exists(os.path.join(path, 'CHANGES')))
        self.assertEquals(pman.status, 'new_version')

        # package product the first package is 0.1.0
        pman.doAction()

        pman.analyze()
        self.assertEquals(pman.status, 'use_tag')
        self.assertEquals(pman.version, [name, '0.1.0', '1'])

        rev_0_1_0 = pman.revision

        # changes something
        file_name = os.path.join(path, 'foo')
        f = open(file_name, 'w+')
        f.write('touch\n')
        f.close()

        # non svn versioned file doesn't change status whatever force mode is
        pman.analyze(force=True)
        self.assertEquals(pman.status, 'use_tag')
        force_bak = pman.force
        pman.force = False
        self.assertEquals(pman.getStatus(), 'use_tag')
        pman.force = force_bak

        command('svn add %s' % file_name)
        command('svn commit -m"add file" %s' % file_name)

        pman.analyze(force=True)
        self.assertEquals(pman.status, 'svn_not_uptodate')

        command('svn up %s' % path)
        pman.analyze(force=True)
        self.assertEquals(pman.status, 'missing_changes')

        # in force mode, local modifications of svn versioned files are ok
        # in non force mode, user has to check in before packaging
        f = open(file_name, 'w+')
        f.write('new touch\n')
        f.close()
        pman.analyze(force=True)
        self.assertEquals(pman.status, 'missing_changes')
        force_bak = pman.force
        pman.force = False
        self.assertEquals(pman.getStatus(), 'svn_not_uptodate')
        pman.force = force_bak
        # reverting local modifications
        command('svn revert %s' % file_name)


        # jump in the past back to rev_0_1_0
        command('svn up -r%s %s' % (rev_0_1_0, path))
        # the wc is not up to date with the svn repo
        pman.analyze(force=True)
        self.assertEquals(pman.revision, rev_0_1_0)
        self.assertEquals(pman.status, 'svn_not_uptodate')
        # back to the present
        command('svn up %s' % path)


        changes = os.path.join(path, 'CHANGES')
        f = open(changes, 'w+')
        f.write(pman.tpl_changes % 'something change')
        f.close()
        command('svn commit -m"update" %s' % changes)
        command('svn up %s' % path)

        pman.analyze(force=True)
        self.assertEquals(pman.status, 'new_version')
        self.assertEquals(pman.version_new[1], '0.2.0')

        # package
        pman.doAction()
        self.assertEquals(pman.status, 'use_tag')
        self.assertEquals(pman.version[1], '0.2.0')

        # package twice should not do anything
        pman.analyze(force=True)
        pman.doAction()
        self.assertEquals(pman.version[1], '0.2.0')

        # create a branch
        branch_name = 'user-refactor'
        branch_url = url.replace('/trunk', '/branches/' + branch_name)
        branch_path = path + '-' + branch_name
        command('svn cp -m"create a branch" %s %s' % (url, branch_url))
        command('svn co %s %s' % (branch_url, branch_path))

        pman = ProductMan(branch_path)
        pman.analyze()

        self.assert_(pman.url, branch_url)
        self.assertEquals(pman.status, 'use_tag')

        # change something
        changes = os.path.join(branch_path, 'CHANGES')
        f = open(changes, 'w+')
        f.write(pman.tpl_changes % 'branch changes')
        f.close()
        command('svn commit -m"change" %s' % changes)
        command('svn up %s' % branch_path)

        # package
        pman.analyze(force=True)
        pman.doAction()
        self.assertEquals(pman.status, 'use_tag')
        self.assertEquals(pman.version[1], '0.3.0-user-refactor')
Пример #13
0
 def upProduct(self, product_path):
     """Svn up a product path."""
     command('svn up %s' % product_path)
Пример #14
0
 def coProduct(self, product, tag='trunk'):
     """Check out a product."""
     product_path = '%s/%s' % (self.coroot, product)
     command('svn co %s/products/%s/%s %s' % (self.svnroot, product, tag,
                                              product_path))
     return product_path
Пример #15
0
 def coBundle(self, bundle, tag='trunk'):
     """Check out a bundle."""
     bundle_path = '%s/%s' % (self.coroot, bundle)
     command('svn co %s/bundles/%s/%s %s' % (self.svnroot, bundle, tag,
                                             bundle_path))
     return bundle_path