1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- changed delete logic: only remove the localfile and keep the store file. The storefile is kept unless the wc is committed - this is useful for something like "osc revert".

- added delete_file() method to the Package class which takes care about the "file deletion logic"
This commit is contained in:
Marcus Hüwe 2009-07-15 21:10:38 +00:00
parent b30611885d
commit 17a8ae894a
2 changed files with 21 additions and 7 deletions

View File

@ -1838,12 +1838,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else:
pathn = getTransActPath(p.dir)
for filename in p.todo:
if filename not in p.filenamelist:
ret, state = p.delete_file(filename, opts.force)
if ret:
print statfrmt('D', os.path.join(pathn, filename))
continue
if state == '?':
sys.exit('\'%s\' is not under version control' % filename)
p.put_on_deletelist(filename)
p.write_deletelist()
p.delete_source_file(filename)
print statfrmt('D', os.path.join(pathn, filename))
elif state in ['A', 'M'] and not opts.force:
sys.exit('\'%s\' has local modifications (use --force to remove this file)' % filename)
def do_resolved(self, subcmd, opts, *args):

View File

@ -647,7 +647,20 @@ class Package:
self.filenamelist.append(n)
self.filenamelist_unvers.remove(n)
shutil.copy2(os.path.join(self.dir, n), os.path.join(self.storedir, n))
def delete_file(self, n, force=False):
"""deletes a file if possible and marks the file as deleted"""
state = self.status(n)
if state in ['?', 'A', 'M'] and not force:
return (False, state)
self.delete_localfile(n)
if state != 'A':
self.put_on_deletelist(n)
self.write_deletelist()
else:
self.delete_storefile(n)
return (True, state)
def delete_storefile(self, n):
try: os.unlink(os.path.join(self.storedir, n))
except: pass
@ -1195,7 +1208,6 @@ rev: %s
if oldp.status(filename) == ' ':
self.delete_localfile(filename)
self.delete_storefile(filename)
continue
for filename in self.filenamelist: