mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- support a revert of a missing file which was added to the wc
This commit is contained in:
parent
1d7c674d80
commit
d90228a7e3
@ -1303,13 +1303,15 @@ class Package:
|
||||
state = 'S'
|
||||
elif n in self.to_be_added and exists_in_store:
|
||||
state = 'R'
|
||||
elif n in self.to_be_added:
|
||||
elif n in self.to_be_added and exists:
|
||||
state = 'A'
|
||||
elif exists and exists_in_store and known_by_meta:
|
||||
if dgst(os.path.join(self.absdir, n)) != self.findfilebyname(n).md5:
|
||||
state = 'M'
|
||||
else:
|
||||
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:
|
||||
state = '!'
|
||||
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)):
|
||||
raise oscerr.PackageInternalError('file \'%s\' is listed in filenamelist but no storefile exists' % 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))
|
||||
if state == 'D':
|
||||
self.to_be_deleted.remove(filename)
|
||||
self.write_deletelist()
|
||||
elif state == 'C':
|
||||
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.write_addlist()
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
toadd1
|
||||
replaced
|
||||
addedmissing
|
||||
|
@ -35,7 +35,7 @@ class TestRevertFiles(OscTestCase):
|
||||
p = osc.core.Package('.')
|
||||
p.revert('toadd1')
|
||||
self.assertTrue(os.path.exists('toadd1'))
|
||||
self._check_addlist('replaced\n')
|
||||
self._check_addlist('replaced\naddedmissing\n')
|
||||
self._check_status(p, 'toadd1', '?')
|
||||
|
||||
def testRevertDeleted(self):
|
||||
@ -55,13 +55,21 @@ class TestRevertFiles(OscTestCase):
|
||||
self.__check_file('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):
|
||||
"""revert a replaced (state == 'R') file"""
|
||||
self._change_to_pkg('simple')
|
||||
p = osc.core.Package('.')
|
||||
p.revert('replaced')
|
||||
self.__check_file('replaced')
|
||||
self._check_addlist('toadd1\n')
|
||||
self._check_addlist('toadd1\naddedmissing\n')
|
||||
self._check_status(p, 'replaced', ' ')
|
||||
|
||||
def testRevertConflict(self):
|
||||
|
Loading…
Reference in New Issue
Block a user