Exemple #1
0
def convert_project(path, project='', apiurl='', **package_states):
    """Convert working copy to the new format.

    path is the path to the project working copy.

    Keyword arguments:
    project -- the name of the project (default: '')
    apiurl -- the apiurl of the project (default: '')
    **package_states -- a package to state mapping (default: {})

    """
    Project.repair(path,
                   project=project,
                   apiurl=apiurl,
                   no_packages=True,
                   **package_states)
    _write_storefile(path, '_version', str(_VERSION))
    project = wc_read_project(path)
    apiurl = wc_read_apiurl(path)
    packages = wc_read_packages(path)
    for entry in packages:
        package = entry.get('name')
        package_path = os.path.join(path, package)
        storedir = wc_pkg_data_mkdir(path, package)
        convert_package(package_path,
                        project=project,
                        package=package,
                        apiurl=apiurl,
                        ext_storedir=storedir)
Exemple #2
0
 def test3(self):
     """read project"""
     path = self.fixture_file('prj1')
     prj = Project(path)
     self.assertEqual(prj.name, 'prj1')
     self.assertEqual(prj.apiurl, 'http://apiurl')
     self.assertTrue(len(prj.packages()) == 2)
Exemple #3
0
 def test_project1(self):
     """test project convert"""
     path = self.fixture_file('project_1')
     self.assertRaises(WCFormatVersionError, Project, path)
     self.assertRaises(WCInconsistentError,
                       Project,
                       path,
                       verify_format=False)
     self._not_exists(path, 'data', store=True)
     convert_project(path)
     self._exists(path, 'data', store=True)
     self._exists(path, 'foo', data=True)
     self._exists(path, 'added', data=True)
     self._exists(path, 'deleted', data=True)
     os.path.islink(os.path.join(path, 'foo', '.osc'))
     os.path.islink(os.path.join(path, 'added', '.osc'))
     os.path.islink(os.path.join(path, 'deleted', '.osc'))
     prj = Project(path)
     pkg = prj.package('foo')
     self.assertEqual(pkg.files(),
                      ['file', 'deleted', 'modified', 'added', 'added2'])
     pkg = prj.package('added')
     self.assertEqual(pkg.files(), ['add'])
     pkg = prj.package('deleted')
     self.assertEqual(pkg.files(), ['deleted'])
Exemple #4
0
 def test_repair3(self):
     """test repair (invalid _packages xml)"""
     path = self.fixture_file('inv4')
     self.assertRaises(WCInconsistentError, Project, path)
     self.assertRaises(ValueError, Project.repair, path)
     Project.repair(path, added='A', missing=' ')
     self.assertEqual(Project.wc_check(path), ([], '', []))
Exemple #5
0
 def test_repair3(self):
     """test repair (invalid _packages xml)"""
     path = self.fixture_file('inv4')
     self.assertRaises(WCInconsistentError, Project, path)
     self.assertRaises(ValueError, Project.repair, path)
     Project.repair(path, added='A', missing=' ')
     self.assertEqual(Project.wc_check(path), ([], '', []))
Exemple #6
0
 def test3(self):
     """read project"""
     path = self.fixture_file('prj1')
     prj = Project(path)
     self.assertEqual(prj.name, 'prj1')
     self.assertEqual(prj.apiurl, 'http://apiurl')
     self.assertTrue(len(prj.packages()) == 2)
Exemple #7
0
 def test_commit5(self):
     """test commit (finish pending transaction (delete))"""
     path = self.fixture_file('prj2_commit_resume')
     prj = Project(path, finish_pending_transaction=False)
     self.assertEqual(prj._status('abc'), 'D')
     prj.commit('abc')
     self.assertEqual(prj._status('abc'), '?')
Exemple #8
0
 def test_update3(self):
     """test update (delete package; local state '!')"""
     path = self.fixture_file('prj2')
     self._not_exists(path, 'xxx')
     prj = Project(path)
     prj.update('xxx')
     self.assertEqual(prj._status('xxx'), '?')
     self._not_exists(path, '.osc', 'data', 'xxx')
Exemple #9
0
 def test_update1(self):
     """test update"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('foo'), ' ')
     prj.update('foo', foo='bar')
     self.assertEqual(prj._status('foo'), ' ')
     self._not_exists(path, '.osc', '_transaction')
Exemple #10
0
 def test_update3(self):
     """test update (delete package; local state '!')"""
     path = self.fixture_file('prj2')
     self._not_exists(path, 'xxx')
     prj = Project(path)
     prj.update('xxx')
     self.assertEqual(prj._status('xxx'), '?')
     self._not_exists(path, '.osc', 'data', 'xxx')
Exemple #11
0
def _checkout(info):
    path = os.path.join(os.getcwd(), info.project)
    if not os.path.exists(path):
        Project.init(path, info.project, info.apiurl)
    packages = []
    if hasattr(info, 'package'):
        packages.append(info.package)
    prj = Project(path, transaction_listener=[MyTransactionListener()])
    prj.update(*packages)
Exemple #12
0
 def test_update7(self):
     """test update (finish pending add transaction auto)"""
     path = self.fixture_file('prj1_update_resume')
     self._not_exists(path, 'foo')
     prj = Project(path, finish_pending_transaction=True)
     self.assertEqual(prj._status('foo'), ' ')
     self._exists(path, 'foo')
     self._exists(path, 'foo', 'file')
     self._exists(path, '.osc', 'data', 'foo')
Exemple #13
0
 def test18(self):
     """test remove (also check if the files were removed)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('bar'), 'A')
     prj.remove('bar')
     self.assertEqual(prj._status('bar'), '?')
     self._not_exists(path, 'bar')
     self._not_exists(path, 'bar', data=True)
Exemple #14
0
 def test_update7(self):
     """test update (finish pending add transaction auto)"""
     path = self.fixture_file('prj1_update_resume')
     self._not_exists(path, 'foo')
     prj = Project(path, finish_pending_transaction=True)
     self.assertEqual(prj._status('foo'), ' ')
     self._exists(path, 'foo')
     self._exists(path, 'foo', 'file')
     self._exists(path, '.osc', 'data', 'foo')
Exemple #15
0
def _status(info):
    path = os.getcwd()
    if hasattr(info, 'package'):
        pkg = Package(path)
        for filename in sorted(os.listdir(path)):
            print "%s\t%s" % (pkg.status(filename), filename)
    else:
        prj = Project(path)
        for package in sorted(os.listdir(path)):
            print "%s\t%s" % (prj._status(package), package)
Exemple #16
0
 def test_update10(self):
     """test update (rollback commit transaction)"""
     path = self.fixture_file('prj2_update_rollback_commit')
     self._exists(path, '.osc', '_transaction')
     # the rest is identical to test_update1
     prj = Project(path)
     self.assertEqual(prj._status('foo'), ' ')
     prj.update('foo', foo='bar')
     self.assertEqual(prj._status('foo'), ' ')
     self._not_exists(path, '.osc', '_transaction')
Exemple #17
0
def _status(info):
    path = os.getcwd()
    if hasattr(info, 'package'):
        pkg = Package(path)
        for filename in sorted(os.listdir(path)):
            print "%s\t%s" % (pkg.status(filename), filename)
    else:
        prj = Project(path)
        for package in sorted(os.listdir(path)):
            print "%s\t%s" % (prj._status(package), package)
Exemple #18
0
 def test8_1(self):
     """test _calculate_updateinfo 3 (specify packages)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     uinfo = prj._calculate_updateinfo('foo', 'osc', 'del')
     self.assertEqual(uinfo.candidates, ['foo'])
     self.assertEqual(uinfo.added, ['osc'])
     self.assertEqual(uinfo.deleted, ['del'])
     # no conflicts because bar shouldn't be added/updated
     self.assertEqual(uinfo.conflicted, [])
Exemple #19
0
 def test7(self):
     """test _calculate_updateinfo"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     uinfo = prj._calculate_updateinfo()
     self.assertEqual(uinfo.candidates, ['foo', 'abc'])
     self.assertEqual(uinfo.added, ['osc'])
     self.assertEqual(uinfo.deleted, ['del', 'foo_modified'])
     self.assertEqual(uinfo.conflicted, ['xxx'])
     self.assertEqual(uinfo.name, 'prj2')
Exemple #20
0
 def test8(self):
     """test _calculate_updateinfo 2"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     uinfo = prj._calculate_updateinfo()
     self.assertEqual(uinfo.candidates, ['foo', 'foo_modified'])
     self.assertEqual(uinfo.added, ['osc'])
     self.assertEqual(uinfo.deleted, ['abc', 'xxx', 'del'])
     # local state: A
     self.assertEqual(uinfo.conflicted, ['bar'])
Exemple #21
0
 def test8(self):
     """test _calculate_updateinfo 2"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     uinfo = prj._calculate_updateinfo()
     self.assertEqual(uinfo.candidates, ['foo', 'foo_modified'])
     self.assertEqual(uinfo.added, ['osc'])
     self.assertEqual(uinfo.deleted, ['abc', 'xxx', 'del'])
     # local state: A
     self.assertEqual(uinfo.conflicted, ['bar'])
Exemple #22
0
 def test8_1(self):
     """test _calculate_updateinfo 3 (specify packages)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     uinfo = prj._calculate_updateinfo('foo', 'osc', 'del')
     self.assertEqual(uinfo.candidates, ['foo'])
     self.assertEqual(uinfo.added, ['osc'])
     self.assertEqual(uinfo.deleted, ['del'])
     # no conflicts because bar shouldn't be added/updated
     self.assertEqual(uinfo.conflicted, [])
Exemple #23
0
 def test7(self):
     """test _calculate_updateinfo"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     uinfo = prj._calculate_updateinfo()
     self.assertEqual(uinfo.candidates, ['foo', 'abc'])
     self.assertEqual(uinfo.added, ['osc'])
     self.assertEqual(uinfo.deleted, ['del', 'foo_modified'])
     self.assertEqual(uinfo.conflicted, ['xxx'])
     self.assertEqual(uinfo.name, 'prj2')
Exemple #24
0
 def test_revert3(self):
     """revert a missing package"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     self.assertEqual(prj._status('xxx'), '!')
     self._not_exists(path, 'xxx')
     prj.revert('xxx')
     self.assertEqual(prj._status('xxx'), ' ')
     self._exists(path, 'xxx')
     self._exists(path, 'xxx', 'dummy')
Exemple #25
0
 def test_update5(self):
     """test update (add package)"""
     path = self.fixture_file('prj1')
     # it is ok to use the simple TL class because we have no
     # duplicate keys (for instance a package and a file with the same name)
     tl = TL(abort=False)
     tl_abort = TL(abort=True)
     prj = Project(path, transaction_listener=[tl, tl_abort])
     self._not_exists(path, 'foo')
     self.assertEqual(prj._status('foo'), '?')
     prj.update('foo')
     # no abort this time
     tl = TL(abort=False)
     prj = Project(path, transaction_listener=[tl])
     self._not_exists(path, 'foo')
     self.assertEqual(prj._status('foo'), '?')
     prj.update('foo')
     self.assertEqual(prj._status('foo'), ' ')
     self._exists(path, 'foo')
     self._exists(path, 'foo', 'file')
     self._exists(path, '.osc', 'data', 'foo')
     # check transaction listener
     self.assertEqual(tl._begin, ['prj_update', 'update'])
     self.assertEqual(tl._finished, ['update', 'prj_update'])
     self.assertEqual(tl._transfer, [('download', 'file')])
     keys = list(tl._processed.keys())
     keys.sort()
     self.assertEqual(keys, ['file', 'foo'])
     self.assertEqual(tl._processed['file'], (' ', None))
     self.assertEqual(tl._processed['foo'], (' ', None))
Exemple #26
0
 def test14(self):
     """do not add deleted package"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('abc'), 'D')
     pkg_dir = self.fixture_file('prj2', 'abc')
     shutil.rmtree(pkg_dir)
     os.mkdir(pkg_dir)
     self.assertEqual(prj._status('abc'), 'D')
     self.assertRaises(ValueError, prj.add, 'abc')
     self.assertEqual(prj._status('abc'), 'D')
Exemple #27
0
 def test_commit6(self):
     """test commit (package with a conflicted file)"""
     path = self.fixture_file('prj3')
     prj = Project(path)
     pkg = prj.package('conflict')
     self.assertEqual(pkg.status('conflict'), 'C')
     self.assertEqual(prj._status('conflict'), ' ')
     self.assertRaises(FileConflictError, prj.commit, 'conflict')
     self.assertEqual(prj._status('conflict'), ' ')
     pkg = prj.package('conflict')
     self.assertEqual(pkg.status('conflict'), 'C')
Exemple #28
0
 def test_repair1(self):
     """test repair (missing _project and storefile)"""
     path = self.fixture_file('inv1')
     self._not_exists(path, '_project', store=True)
     self.assertRaises(WCInconsistentError, Project, path)
     self.assertRaises(ValueError, Project.repair, path)
     Project.repair(path, project='inv1')
     self.assertEqual(Project.wc_check(path), ([], '', []))
     self._exists(path, '_project', store=True)
     prj = Project(path)
     self.assertEqual(prj.name, 'inv1')
Exemple #29
0
 def _checkout_package(self, apiurl, project, package, info):
     tl = RendererUpdateTransactionListener(self._renderer)
     path = self._path_join(project)
     if wc_is_project(path):
         prj = Project(path, transaction_listener=[tl])
     else:
         prj = Project.init(path,
                            project,
                            apiurl,
                            transaction_listener=[tl])
     self._update_project(prj, info, package)
Exemple #30
0
 def test9(self):
     """test _calculate_updateinfo 3 (empty package list)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('bar'), 'A')
     uinfo = prj._calculate_updateinfo()
     self.assertEqual(uinfo.candidates, [])
     self.assertEqual(uinfo.added, [])
     self.assertEqual(uinfo.deleted, ['foo', 'abc', 'xxx', 'del',
                                      'foo_modified'])
     self.assertEqual(uinfo.conflicted, [])
Exemple #31
0
 def test_repair1(self):
     """test repair (missing _project and storefile)"""
     path = self.fixture_file('inv1')
     self._not_exists(path, '_project', store=True)
     self.assertRaises(WCInconsistentError, Project, path)
     self.assertRaises(ValueError, Project.repair, path)
     Project.repair(path, project='inv1')
     self.assertEqual(Project.wc_check(path), ([], '', []))
     self._exists(path, '_project', store=True)
     prj = Project(path)
     self.assertEqual(prj.name, 'inv1')
Exemple #32
0
 def test9(self):
     """test _calculate_updateinfo 3 (empty package list)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('bar'), 'A')
     uinfo = prj._calculate_updateinfo()
     self.assertEqual(uinfo.candidates, [])
     self.assertEqual(uinfo.added, [])
     self.assertEqual(uinfo.deleted, ['foo', 'abc', 'xxx', 'del',
                                      'foo_modified'])
     self.assertEqual(uinfo.conflicted, [])
Exemple #33
0
 def test14(self):
     """do not add deleted package"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('abc'), 'D')
     pkg_dir = self.fixture_file('prj2', 'abc')
     shutil.rmtree(pkg_dir)
     os.mkdir(pkg_dir)
     self.assertEqual(prj._status('abc'), 'D')
     self.assertRaises(ValueError, prj.add, 'abc')
     self.assertEqual(prj._status('abc'), 'D')
Exemple #34
0
 def test6(self):
     """test _status"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('foo'), ' ')
     self.assertEqual(prj._status('bar'), 'A')
     self.assertEqual(prj._status('abc'), 'D')
     self.assertEqual(prj._status('xxx'), '!')
     # del is not ! because it's also marked for deletion
     self.assertEqual(prj._status('del'), 'D')
     self.assertEqual(prj._status('asdf'), '?')
Exemple #35
0
 def test_commitinfo2(self):
     """test commitinfo (only specified packages)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('foo'), ' ')
     self.assertEqual(prj._status('foo_modified'), ' ')
     cinfo = prj._calculate_commitinfo('foo', 'foo_modified')
     self.assertEqual(cinfo.unchanged, ['foo'])
     self.assertEqual(cinfo.added, [])
     self.assertEqual(cinfo.deleted, [])
     self.assertEqual(cinfo.modified, ['foo_modified'])
     self.assertEqual(cinfo.conflicted, [])
Exemple #36
0
 def test_revert7(self):
     """revert all packages"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     # just check the state of some packages
     self.assertEqual(prj._status('modified'), ' ')
     self.assertEqual(prj._status('deleted'), 'D')
     self.assertEqual(prj._status('xxx'), '!')
     prj.revert()
     self.assertEqual(prj._status('modified'), ' ')
     self.assertEqual(prj._status('deleted'), ' ')
     self.assertEqual(prj._status('xxx'), ' ')
Exemple #37
0
 def test_commitinfo2(self):
     """test commitinfo (only specified packages)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('foo'), ' ')
     self.assertEqual(prj._status('foo_modified'), ' ')
     cinfo = prj._calculate_commitinfo('foo', 'foo_modified')
     self.assertEqual(cinfo.unchanged, ['foo'])
     self.assertEqual(cinfo.added, [])
     self.assertEqual(cinfo.deleted, [])
     self.assertEqual(cinfo.modified, ['foo_modified'])
     self.assertEqual(cinfo.conflicted, [])
Exemple #38
0
 def test_update8(self):
     """test update (package with a conflicted file)"""
     path = self.fixture_file('prj3')
     prj = Project(path)
     pkg = prj.package('conflict')
     self.assertEqual(pkg.status('conflict'), 'C')
     self.assertEqual(prj._status('conflict'), ' ')
     # Note: package conflict would be deleted (if update were possible)
     self.assertRaises(FileConflictError, prj.update, 'conflict')
     self.assertEqual(prj._status('conflict'), ' ')
     pkg = prj.package('conflict')
     self.assertEqual(pkg.status('conflict'), 'C')
Exemple #39
0
 def test_update11(self):
     """test update (go back to state STATE_PREPARE after add)"""
     path = self.fixture_file('prj1_update_state_prepare')
     ustate = ProjectUpdateState.read_state(path)
     self.assertEqual(ustate.state, UpdateStateMixin.STATE_PREPARE)
     # the update itself is similar to test_update5
     prj = Project(path)
     self.assertEqual(prj._status('foo'), '?')
     prj._perform_adds(ustate)
     self._exists(path, '.osc', '_transaction')
     ustate = ProjectUpdateState.read_state(path)
     self.assertEqual(ustate.state, UpdateStateMixin.STATE_PREPARE)
     self.assertEqual(ustate.entrystates['foo'], ' ')
Exemple #40
0
 def test_update11(self):
     """test update (go back to state STATE_PREPARE after add)"""
     path = self.fixture_file('prj1_update_state_prepare')
     ustate = ProjectUpdateState.read_state(path)
     self.assertEqual(ustate.state, UpdateStateMixin.STATE_PREPARE)
     # the update itself is similar to test_update5
     prj = Project(path)
     self.assertEqual(prj._status('foo'), '?')
     prj._perform_adds(ustate)
     self._exists(path, '.osc', '_transaction')
     ustate = ProjectUpdateState.read_state(path)
     self.assertEqual(ustate.state, UpdateStateMixin.STATE_PREPARE)
     self.assertEqual(ustate.entrystates['foo'], ' ')
Exemple #41
0
 def test_revert2(self):
     """revert added package"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     self.assertEqual(prj._status('added'), 'A')
     self._exists(path, 'added')
     self._exists(path, 'added', 'foo')
     self._exists(path, 'added', '.osc')
     prj.revert('added')
     self.assertEqual(prj._status('added'), '?')
     # the directory and its files are kept
     self._exists(path, 'added')
     self._exists(path, 'added', 'foo')
     self._not_exists(path, 'added', '.osc')
Exemple #42
0
 def test10_2(self):
     """test add (all files)"""
     path = self.fixture_file('project')
     pkg_path = os.path.join(path, 'added')
     os.mkdir(pkg_path)
     open(os.path.join(pkg_path, 'foo'), 'w').close()
     open(os.path.join(pkg_path, 'bar'), 'w').close()
     prj = Project(path)
     prj.add('added')
     self.assertEqual(prj._status('added'), 'A')
     self.assertTrue(os.path.islink(os.path.join(pkg_path, '.osc')))
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), 'A')
     self.assertEqual(pkg.status('bar'), 'A')
Exemple #43
0
 def test_commit12(self):
     """test commit (rollback update transaction)"""
     path = self.fixture_file('prj3_commit_rollback_update')
     self._exists(path, '.osc', '_transaction')
     # similar to test_commit6 - except that we rollback an update
     # transaction (behind the scenes)
     prj = Project(path)
     pkg = prj.package('conflict')
     self.assertEqual(pkg.status('conflict'), 'C')
     self.assertEqual(prj._status('conflict'), ' ')
     self.assertRaises(FileConflictError, prj.commit, 'conflict')
     self.assertEqual(prj._status('conflict'), ' ')
     pkg = prj.package('conflict')
     self.assertEqual(pkg.status('conflict'), 'C')
     self._not_exists(path, '.osc', '_transaction')
Exemple #44
0
 def test_revert7(self):
     """revert all packages"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     # just check the state of some packages
     self.assertEqual(prj._status('modified'), ' ')
     self.assertEqual(prj._status('deleted'), 'D')
     self.assertEqual(prj._status('xxx'), '!')
     prj.revert()
     self.assertEqual(prj._status('modified'), ' ')
     self.assertEqual(prj._status('deleted'), ' ')
     self.assertEqual(prj._status('xxx'), ' ')
Exemple #45
0
 def _checkout_project(self, info):
     """Checks out the project project."""
     path = self._path_join(info.project)
     tl = RendererUpdateTransactionListener(self._renderer)
     prj = Project.init(path, info.project, info.apiurl,
                        transaction_listener=[tl])
     self._update_project(prj, info)
Exemple #46
0
 def test_commit11(self):
     """test commit (package in *packages and package_filenames)"""
     path = self.fixture_file('prj2')
     todo = {'bar': ['add']}
     prj = Project(path)
     self.assertRaises(ValueError, prj.commit, 'bar',
                       package_filenames=todo)
Exemple #47
0
 def test_commitinfo1(self):
     """test commitinfo (complete project)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     self.assertEqual(prj._status('foo'), ' ')
     self.assertEqual(prj._status('bar'), 'A')
     self.assertEqual(prj._status('abc'), 'D')
     self.assertEqual(prj._status('xxx'), '!')
     self.assertEqual(prj._status('del'), 'D')
     cinfo = prj._calculate_commitinfo()
     self.assertEqual(cinfo.unchanged, ['foo'])
     self.assertEqual(cinfo.added, ['bar'])
     self.assertEqual(cinfo.deleted, ['abc', 'del'])
     self.assertEqual(cinfo.modified, ['foo_modified'])
     self.assertEqual(cinfo.conflicted, ['xxx'])
     self.assertEqual(cinfo.name, 'prj2')
Exemple #48
0
 def test_commit8(self):
     """test commit delete (local state: 'D' (wc doesn't exist))"""
     path = self.fixture_file('prj1')
     tl = TL(abort=False)
     prj = Project(path, transaction_listener=[tl])
     self._not_exists(path, 'missing')
     self._exists(path, '.osc', 'data', 'missing')
     self.assertEqual(prj._status('missing'), 'D')
     prj.commit('missing')
     self.assertEqual(prj._status('missing'), '?')
     self._not_exists(path, '.osc', 'data', 'missing')
     # check transaction listener
     self.assertEqual(tl._begin, ['prj_commit'])
     self.assertEqual(tl._finished, ['prj_commit'])
     self.assertEqual(tl._transfer, [])
     self.assertEqual(list(tl._processed.keys()), ['missing'])
     self.assertEqual(tl._processed['missing'], (None, 'D'))
Exemple #49
0
 def test10_3(self):
     """test add (all files)"""
     path = self.fixture_file('project')
     pkg_path = os.path.join(path, 'added')
     os.mkdir(pkg_path)
     open(os.path.join(pkg_path, 'foo'), 'w').close()
     open(os.path.join(pkg_path, 'bar'), 'w').close()
     prj = Project(path)
     self.assertRaises(ValueError, prj.add, 'added', 'foo', no_files=True)
Exemple #50
0
 def _checkout_project(self, info):
     """Checks out the project project."""
     path = self._path_join(info.project)
     tl = RendererUpdateTransactionListener(self._renderer)
     prj = Project.init(path,
                        info.project,
                        info.apiurl,
                        transaction_listener=[tl])
     self._update_project(prj, info)
Exemple #51
0
 def test_commit4(self):
     """test commit (same as test_commit4 but remote package exists)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('bar')
     self.assertEqual(pkg.status('add'), 'A')
     self.assertEqual(prj._status('bar'), 'A')
     prj.commit('bar')
     self.assertEqual(prj._status('bar'), ' ')
     pkg = prj.package('bar')
     self.assertEqual(pkg.status('add'), ' ')
     self._exists(path, '.osc', 'data', 'bar')
Exemple #52
0
    def project_obj(self, *args, **kwargs):
        """Returns a Project object if possible.

        *args and **kwargs are optional arguments for Project's
        __init__ method. If no Project can be returned None is
        returned.

        """
        if self.project_path is None:
            return None
        return Project(self.project_path, *args, **kwargs)
Exemple #53
0
 def test_revert1(self):
     """revert modified package"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     self.assertEqual(prj._status('modified'), ' ')
     pkg = prj.package('modified')
     self.assertEqual(pkg.status('add'), 'A')
     self.assertEqual(pkg.status('file'), 'M')
     prj.revert('modified')
     self.assertEqual(prj._status('modified'), ' ')
     pkg = prj.package('modified')
     self.assertEqual(pkg.status('add'), '?')
     self.assertEqual(pkg.status('file'), ' ')
Exemple #54
0
 def test_repair4(self):
     """test repair (wc + pkg data missing)"""
     # remove package from _packages in this case
     path = self.fixture_file('inv5')
     self.assertRaises(WCInconsistentError, Project, path)
     Project.repair(path)
     self.assertEqual(Project.wc_check(path), ([], '', []))
     prj = Project(path)
     self.assertEqual(prj._status('missing'), '?')
     self.assertEqual(prj._status('added'), 'A')
Exemple #55
0
 def test19(self):
     """test remove (all files removed)"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('foo')
     self.assertEqual(pkg.status('file'), ' ')
     self.assertEqual(prj._status('foo'), ' ')
     self._exists(path, 'foo', 'file')
     prj.remove('foo')
     self._exists(path, 'foo')
     self._not_exists(path, 'foo', 'file')
     self.assertEqual(prj._status('foo'), 'D')
     pkg = prj.package('foo')
     self.assertEqual(pkg.status('file'), 'D')
Exemple #56
0
 def test_commit1(self):
     """test commit (local state: ' ')"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('foo_modified')
     self.assertEqual(pkg.status('file'), 'M')
     self.assertEqual(pkg.status('add'), 'A')
     self.assertEqual(prj._status('foo'), ' ')
     prj.commit('foo_modified')
     self.assertEqual(prj._status('foo'), ' ')
     pkg = prj.package('foo_modified')
     self.assertEqual(pkg.status('file'), ' ')
     self.assertEqual(pkg.status('add'), ' ')
     self._not_exists(path, '.osc', '_transaction')
Exemple #57
0
 def test_commit2(self):
     """test commit (local state: 'A')"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('bar')
     self.assertEqual(pkg.status('add'), 'A')
     self.assertEqual(pkg.status('add2'), 'A')
     self.assertEqual(prj._status('bar'), 'A')
     prj.commit('bar')
     self.assertEqual(prj._status('bar'), ' ')
     pkg = prj.package('bar')
     self.assertEqual(pkg.status('add'), ' ')
     self.assertEqual(pkg.status('add2'), ' ')
     self._exists(path, '.osc', 'data', 'bar')
Exemple #58
0
 def test_commit5(self):
     """test commit (finish pending transaction (delete))"""
     path = self.fixture_file('prj2_commit_resume')
     prj = Project(path, finish_pending_transaction=False)
     self.assertEqual(prj._status('abc'), 'D')
     prj.commit('abc')
     self.assertEqual(prj._status('abc'), '?')
Exemple #59
0
 def test_commit9(self):
     """test commit (specify file + comment; local state ' ')"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('foo_modified')
     self.assertEqual(pkg.status('file'), 'M')
     self.assertEqual(pkg.status('add'), 'A')
     self.assertEqual(prj._status('foo'), ' ')
     todo = {'foo_modified': ['file']}
     prj.commit(package_filenames=todo, comment='foo bar')
     self.assertEqual(prj._status('foo'), ' ')
     pkg = prj.package('foo_modified')
     self.assertEqual(pkg.status('file'), ' ')
     self.assertEqual(pkg.status('add'), 'A')
Exemple #60
0
 def test_revert5(self):
     """revert a deleted package (dir does not exist)"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     self.assertEqual(prj._status('del'), 'D')
     self._not_exists(path, 'del')
     prj.revert('del')
     self.assertEqual(prj._status('del'), ' ')
     self._exists(path, 'del')
     pkg = prj.package('del')
     self.assertEqual(pkg.status('file'), ' ')