1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-26 22:56:15 +01:00

- support a revert of a missing file which was added to the wc

This commit is contained in:
Marcus Huewe 2010-08-26 13:46:10 +02:00
parent 1d7c674d80
commit d90228a7e3
3 changed files with 16 additions and 5 deletions

View File

@ -1303,13 +1303,15 @@ class Package:
state = 'S' state = 'S'
elif n in self.to_be_added and exists_in_store: elif n in self.to_be_added and exists_in_store:
state = 'R' state = 'R'
elif n in self.to_be_added: elif n in self.to_be_added and exists:
state = 'A' state = 'A'
elif exists and exists_in_store and known_by_meta: elif exists and exists_in_store and known_by_meta:
if dgst(os.path.join(self.absdir, n)) != self.findfilebyname(n).md5: if dgst(os.path.join(self.absdir, n)) != self.findfilebyname(n).md5:
state = 'M' state = 'M'
else: else:
state = ' ' state = ' '
elif n in self.to_be_added and not exists:
state = '!'
elif not exists and exists_in_store and known_by_meta and not n in self.to_be_deleted: elif not exists and exists_in_store and known_by_meta and not n in self.to_be_deleted:
state = '!' state = '!'
elif exists and not exists_in_store and not known_by_meta: elif exists and not exists_in_store and not known_by_meta:
@ -1790,14 +1792,14 @@ rev: %s
if filename in self.filenamelist and not os.path.exists(os.path.join(self.storedir, filename)): if filename in self.filenamelist and not os.path.exists(os.path.join(self.storedir, filename)):
raise oscerr.PackageInternalError('file \'%s\' is listed in filenamelist but no storefile exists' % filename) raise oscerr.PackageInternalError('file \'%s\' is listed in filenamelist but no storefile exists' % filename)
state = self.status(filename) state = self.status(filename)
if state != 'A': if not (state == 'A' or state == '!' and filename in self.to_be_added):
shutil.copyfile(os.path.join(self.storedir, filename), os.path.join(self.absdir, filename)) shutil.copyfile(os.path.join(self.storedir, filename), os.path.join(self.absdir, filename))
if state == 'D': if state == 'D':
self.to_be_deleted.remove(filename) self.to_be_deleted.remove(filename)
self.write_deletelist() self.write_deletelist()
elif state == 'C': elif state == 'C':
self.clear_from_conflictlist(filename) self.clear_from_conflictlist(filename)
elif state in ('A', 'R'): elif state in ('A', 'R') or state == '!' and filename in self.to_be_added:
self.to_be_added.remove(filename) self.to_be_added.remove(filename)
self.write_addlist() self.write_addlist()

View File

@ -1,2 +1,3 @@
toadd1 toadd1
replaced replaced
addedmissing

View File

@ -35,7 +35,7 @@ class TestRevertFiles(OscTestCase):
p = osc.core.Package('.') p = osc.core.Package('.')
p.revert('toadd1') p.revert('toadd1')
self.assertTrue(os.path.exists('toadd1')) self.assertTrue(os.path.exists('toadd1'))
self._check_addlist('replaced\n') self._check_addlist('replaced\naddedmissing\n')
self._check_status(p, 'toadd1', '?') self._check_status(p, 'toadd1', '?')
def testRevertDeleted(self): def testRevertDeleted(self):
@ -55,13 +55,21 @@ class TestRevertFiles(OscTestCase):
self.__check_file('missing') self.__check_file('missing')
self._check_status(p, 'missing', ' ') self._check_status(p, 'missing', ' ')
def testRevertMissingAdded(self):
"""revert a missing file which was added to the wc"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
p.revert('addedmissing')
self._check_addlist('toadd1\nreplaced\n')
self.assertRaises(IOError, p.status, 'addedmissing')
def testRevertReplaced(self): def testRevertReplaced(self):
"""revert a replaced (state == 'R') file""" """revert a replaced (state == 'R') file"""
self._change_to_pkg('simple') self._change_to_pkg('simple')
p = osc.core.Package('.') p = osc.core.Package('.')
p.revert('replaced') p.revert('replaced')
self.__check_file('replaced') self.__check_file('replaced')
self._check_addlist('toadd1\n') self._check_addlist('toadd1\naddedmissing\n')
self._check_status(p, 'replaced', ' ') self._check_status(p, 'replaced', ' ')
def testRevertConflict(self): def testRevertConflict(self):