Exemplo n.º 1
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))
Exemplo n.º 2
0
 def test_commit7(self):
     """test commit (local state: 'A')"""
     path = self.fixture_file('prj1')
     tl = TL(abort=False)
     tl_abort = TL(abort=True)
     prj = Project(path, transaction_listener=[tl, tl_abort])
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), 'A')
     self.assertEqual(prj._status('added'), 'A')
     prj.commit('added')
     # this time no abort
     tl = TL(abort=False)
     prj = Project(path, transaction_listener=[tl])
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), 'A')
     self.assertEqual(prj._status('added'), 'A')
     prj.commit('added')
     self.assertEqual(prj._status('added'), ' ')
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), ' ')
     self._exists(path, '.osc', 'data', 'added')
     # check transaction listener
     self.assertEqual(tl._begin, ['prj_commit', 'commit'])
     self.assertEqual(tl._finished, ['commit', 'prj_commit'])
     self.assertEqual(tl._transfer, [('upload', 'foo')])
     self.assertEqual(set(tl._processed.keys()),
                      set(['foo', 'added']))
     self.assertEqual(tl._processed['foo'], (' ', 'A'))
     self.assertEqual(tl._processed['added'], (' ', 'A'))
Exemplo n.º 3
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 = tl._processed.keys()
     keys.sort()
     self.assertEqual(keys, ['file', 'foo'])
     self.assertEqual(tl._processed['file'], (' ', None))
     self.assertEqual(tl._processed['foo'], (' ', None))
Exemplo n.º 4
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'), '?')
Exemplo n.º 5
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'), '?')
Exemplo n.º 6
0
 def test_commit7(self):
     """test commit (local state: 'A')"""
     path = self.fixture_file('prj1')
     tl = TL(abort=False)
     tl_abort = TL(abort=True)
     prj = Project(path, transaction_listener=[tl, tl_abort])
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), 'A')
     self.assertEqual(prj._status('added'), 'A')
     prj.commit('added')
     # this time no abort
     tl = TL(abort=False)
     prj = Project(path, transaction_listener=[tl])
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), 'A')
     self.assertEqual(prj._status('added'), 'A')
     prj.commit('added')
     self.assertEqual(prj._status('added'), ' ')
     pkg = prj.package('added')
     self.assertEqual(pkg.status('foo'), ' ')
     self._exists(path, '.osc', 'data', 'added')
     # check transaction listener
     self.assertEqual(tl._begin, ['prj_commit', 'commit'])
     self.assertEqual(tl._finished, ['commit', 'prj_commit'])
     self.assertEqual(tl._transfer, [('upload', 'foo')])
     self.assertEqual(set(tl._processed.keys()),
                      set(['foo', 'added']))
     self.assertEqual(tl._processed['foo'], (' ', 'A'))
     self.assertEqual(tl._processed['added'], (' ', 'A'))
Exemplo n.º 7
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')
Exemplo n.º 8
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')
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
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')
Exemplo n.º 12
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')
Exemplo n.º 13
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')
Exemplo n.º 14
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')
Exemplo n.º 15
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')
Exemplo n.º 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')
Exemplo n.º 17
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'), '?')
Exemplo n.º 18
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')
Exemplo n.º 19
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'), '?')
Exemplo n.º 20
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')
Exemplo n.º 21
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')
Exemplo n.º 22
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')
Exemplo n.º 23
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'), ' ')
Exemplo n.º 24
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'), ' ')
Exemplo n.º 25
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')
Exemplo n.º 26
0
 def test_revert6(self):
     """revert a package whose storedir was deleted"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     self.assertEqual(prj._status('modified_no_storedir'), ' ')
     self._not_exists(path, 'modified_no_storedir', '.osc')
     prj.revert('modified_no_storedir')
     self._exists(path, 'modified_no_storedir', '.osc')
     self.assertEqual(prj._status('modified_no_storedir'), ' ')
     pkg = prj.package('modified_no_storedir')
     self.assertEqual(pkg.status('add'), '?')
     self.assertEqual(pkg.status('file'), ' ')
Exemplo n.º 27
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')
Exemplo n.º 28
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')
Exemplo n.º 29
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, [])
Exemplo n.º 30
0
 def test_revert6(self):
     """revert a package whose storedir was deleted"""
     path = self.fixture_file('prj_revert')
     prj = Project(path)
     self.assertEqual(prj._status('modified_no_storedir'), ' ')
     self._not_exists(path, 'modified_no_storedir', '.osc')
     prj.revert('modified_no_storedir')
     self._exists(path, 'modified_no_storedir', '.osc')
     self.assertEqual(prj._status('modified_no_storedir'), ' ')
     pkg = prj.package('modified_no_storedir')
     self.assertEqual(pkg.status('add'), '?')
     self.assertEqual(pkg.status('file'), ' ')
Exemplo n.º 31
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, [])
Exemplo n.º 32
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')
Exemplo n.º 33
0
 def test_update6(self):
     """test update (finish pending add transaction)"""
     path = self.fixture_file('prj1_update_resume')
     self._exists(path, '.osc', '_transaction')
     prj = Project(path, finish_pending_transaction=False)
     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')
     self._not_exists(path, '.osc', '_transaction')
Exemplo n.º 34
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'), ' ')
Exemplo n.º 35
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'), ' ')
Exemplo n.º 36
0
 def test_update6(self):
     """test update (finish pending add transaction)"""
     path = self.fixture_file('prj1_update_resume')
     self._exists(path, '.osc', '_transaction')
     prj = Project(path, finish_pending_transaction=False)
     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')
     self._not_exists(path, '.osc', '_transaction')
Exemplo n.º 37
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')
Exemplo n.º 38
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')
Exemplo n.º 39
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')
Exemplo n.º 40
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')
Exemplo n.º 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')
Exemplo n.º 42
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')
Exemplo n.º 43
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')
Exemplo n.º 44
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')
Exemplo n.º 45
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')
Exemplo n.º 46
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')
Exemplo n.º 47
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')
Exemplo n.º 48
0
 def test_commit3(self):
     """test commit (local state: 'D')"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('abc')
     self.assertEqual(pkg.status('modified'), 'D')
     self.assertEqual(pkg.status('untracked'), '?')
     self.assertEqual(prj._status('abc'), 'D')
     prj.commit('abc')
     self.assertEqual(prj._status('abc'), '?')
     self._exists(path, 'abc')
     self._exists(path, 'abc', 'modified')
     self._exists(path, 'abc', 'untracked')
     self._not_exists(path, 'abc', '.osc')
     self._not_exists(path, '.osc', 'data', 'abc')
Exemplo n.º 49
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')
Exemplo n.º 50
0
 def test_commit3(self):
     """test commit (local state: 'D')"""
     path = self.fixture_file('prj2')
     prj = Project(path)
     pkg = prj.package('abc')
     self.assertEqual(pkg.status('modified'), 'D')
     self.assertEqual(pkg.status('untracked'), '?')
     self.assertEqual(prj._status('abc'), 'D')
     prj.commit('abc')
     self.assertEqual(prj._status('abc'), '?')
     self._exists(path, 'abc')
     self._exists(path, 'abc', 'modified')
     self._exists(path, 'abc', 'untracked')
     self._not_exists(path, 'abc', '.osc')
     self._not_exists(path, '.osc', 'data', 'abc')
Exemplo n.º 51
0
 def test_commit10(self):
     """test commit (specify file + comment; 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')
     todo = {'bar': ['add']}
     prj.commit(package_filenames=todo, comment='foo')
     self.assertEqual(prj._status('bar'), ' ')
     pkg = prj.package('bar')
     self.assertEqual(pkg.status('add'), ' ')
     self.assertEqual(pkg.status('add2'), 'A')
     self._exists(path, '.osc', 'data', 'bar')
Exemplo n.º 52
0
 def test_commit10(self):
     """test commit (specify file + comment; 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')
     todo = {'bar': ['add']}
     prj.commit(package_filenames=todo, comment='foo')
     self.assertEqual(prj._status('bar'), ' ')
     pkg = prj.package('bar')
     self.assertEqual(pkg.status('add'), ' ')
     self.assertEqual(pkg.status('add2'), 'A')
     self._exists(path, '.osc', 'data', 'bar')
Exemplo n.º 53
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')
Exemplo n.º 54
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')
Exemplo n.º 55
0
 def test_update2(self):
     """test update (delete package; local state 'D')"""
     path = self.fixture_file('prj2')
     self._exists(path, 'abc')
     self._exists(path, 'abc', 'modified')
     self._exists(path, 'abc', 'untracked')
     self._exists(path, 'abc', '.osc')
     self._exists(path, '.osc', 'data', 'abc')
     prj = Project(path)
     self.assertEqual(prj._status('abc'), 'D')
     prj.update('abc')
     self.assertEqual(prj._status('abc'), '?')
     self._exists(path, 'abc')
     self._exists(path, 'abc', 'modified')
     self._exists(path, 'abc', 'untracked')
     self._not_exists(path, 'abc', '.osc')
     self._not_exists(path, '.osc', 'data', 'abc')
Exemplo n.º 56
0
 def test_update2(self):
     """test update (delete package; local state 'D')"""
     path = self.fixture_file('prj2')
     self._exists(path, 'abc')
     self._exists(path, 'abc', 'modified')
     self._exists(path, 'abc', 'untracked')
     self._exists(path, 'abc', '.osc')
     self._exists(path, '.osc', 'data', 'abc')
     prj = Project(path)
     self.assertEqual(prj._status('abc'), 'D')
     prj.update('abc')
     self.assertEqual(prj._status('abc'), '?')
     self._exists(path, 'abc')
     self._exists(path, 'abc', 'modified')
     self._exists(path, 'abc', 'untracked')
     self._not_exists(path, 'abc', '.osc')
     self._not_exists(path, '.osc', 'data', 'abc')
Exemplo n.º 57
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')
Exemplo n.º 58
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'))
Exemplo n.º 59
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')
Exemplo n.º 60
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(tl._processed.keys(), ['missing'])
     self.assertEqual(tl._processed['missing'], (None, 'D'))