1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-03 10:06:17 +01:00

- fixed "osc addremove": use delete_file(), initialize pac.todo correctly

- added new testcase
This commit is contained in:
Marcus Huewe 2010-09-06 15:28:23 +02:00
parent 814a383ed0
commit 5e72fa1284
4 changed files with 19 additions and 10 deletions

View File

@ -2919,8 +2919,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
pacs = findpacs(args)
for p in pacs:
p.todo = p.filenamelist + p.filenamelist_unvers
p.todo = list(set(p.filenamelist + p.filenamelist_unvers + p.to_be_added))
for filename in p.todo:
if os.path.isdir(filename):
continue
@ -2928,18 +2927,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if os.path.splitext(filename)[0] in p.in_conflict:
continue
state = p.status(filename)
if state == '?':
# TODO: should ignore typical backup files suffix ~ or .orig
p.addfile(filename)
print statfrmt('A', getTransActPath(os.path.join(p.dir, filename)))
elif state == '!':
p.put_on_deletelist(filename)
p.write_deletelist()
p.delete_file(filename)
print statfrmt('D', getTransActPath(os.path.join(p.dir, filename)))
@cmdln.alias('ci')
@cmdln.alias('checkin')
@cmdln.option('-m', '--message', metavar='TEXT',

View File

@ -828,7 +828,8 @@ class Package:
if state in ['?', 'A', 'M', 'R', 'C'] and not force:
return (False, state)
self.delete_localfile(n)
if state in ('A', 'R'):
was_added = n in self.to_be_added
if state in ('A', 'R') or state == '!' and was_added:
self.to_be_added.remove(n)
self.write_addlist()
elif state == 'C':
@ -836,7 +837,7 @@ class Package:
# that's why we don't use clear_from_conflictlist
self.in_conflict.remove(n)
self.write_conflictlist()
if not state in ('A', '?'):
if not state in ('A', '?') and not (state == '!' and was_added):
self.put_on_deletelist(n)
self.write_deletelist()
return (True, state)

View File

@ -162,6 +162,20 @@ class TestDeleteFiles(OscTestCase):
self._check_deletelist('foo\n')
self._check_status(p, 'foo', 'D')
def testDeleteAddedMissing(self):
"""
delete a file which was added to the wc and is removed again
(via a non osc command). It's current state is '!'
"""
self._change_to_pkg('delete')
p = osc.core.Package('.')
ret = p.delete_file('toadd1')
self.__check_ret(ret, True, '!')
self.assertFalse(os.path.exists('toadd1'))
self.assertFalse(os.path.exists(os.path.join('.osc', 'toadd1')))
self._check_deletelist('foo\n')
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
def __check_ret(self, ret, exp1, exp2):
self.assertTrue(len(ret) == 2)
self.assertTrue(ret[0] == exp1)