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:
parent
814a383ed0
commit
5e72fa1284
@ -2919,8 +2919,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
pacs = findpacs(args)
|
pacs = findpacs(args)
|
||||||
for p in pacs:
|
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:
|
for filename in p.todo:
|
||||||
if os.path.isdir(filename):
|
if os.path.isdir(filename):
|
||||||
continue
|
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:
|
if os.path.splitext(filename)[0] in p.in_conflict:
|
||||||
continue
|
continue
|
||||||
state = p.status(filename)
|
state = p.status(filename)
|
||||||
|
|
||||||
if state == '?':
|
if state == '?':
|
||||||
# TODO: should ignore typical backup files suffix ~ or .orig
|
# TODO: should ignore typical backup files suffix ~ or .orig
|
||||||
p.addfile(filename)
|
p.addfile(filename)
|
||||||
print statfrmt('A', getTransActPath(os.path.join(p.dir, filename)))
|
|
||||||
elif state == '!':
|
elif state == '!':
|
||||||
p.put_on_deletelist(filename)
|
p.delete_file(filename)
|
||||||
p.write_deletelist()
|
|
||||||
print statfrmt('D', getTransActPath(os.path.join(p.dir, filename)))
|
print statfrmt('D', getTransActPath(os.path.join(p.dir, filename)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cmdln.alias('ci')
|
@cmdln.alias('ci')
|
||||||
@cmdln.alias('checkin')
|
@cmdln.alias('checkin')
|
||||||
@cmdln.option('-m', '--message', metavar='TEXT',
|
@cmdln.option('-m', '--message', metavar='TEXT',
|
||||||
|
@ -828,7 +828,8 @@ class Package:
|
|||||||
if state in ['?', 'A', 'M', 'R', 'C'] and not force:
|
if state in ['?', 'A', 'M', 'R', 'C'] and not force:
|
||||||
return (False, state)
|
return (False, state)
|
||||||
self.delete_localfile(n)
|
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.to_be_added.remove(n)
|
||||||
self.write_addlist()
|
self.write_addlist()
|
||||||
elif state == 'C':
|
elif state == 'C':
|
||||||
@ -836,7 +837,7 @@ class Package:
|
|||||||
# that's why we don't use clear_from_conflictlist
|
# that's why we don't use clear_from_conflictlist
|
||||||
self.in_conflict.remove(n)
|
self.in_conflict.remove(n)
|
||||||
self.write_conflictlist()
|
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.put_on_deletelist(n)
|
||||||
self.write_deletelist()
|
self.write_deletelist()
|
||||||
return (True, state)
|
return (True, state)
|
||||||
|
@ -162,6 +162,20 @@ class TestDeleteFiles(OscTestCase):
|
|||||||
self._check_deletelist('foo\n')
|
self._check_deletelist('foo\n')
|
||||||
self._check_status(p, 'foo', 'D')
|
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):
|
def __check_ret(self, ret, exp1, exp2):
|
||||||
self.assertTrue(len(ret) == 2)
|
self.assertTrue(len(ret) == 2)
|
||||||
self.assertTrue(ret[0] == exp1)
|
self.assertTrue(ret[0] == exp1)
|
||||||
|
Loading…
Reference in New Issue
Block a user