mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-06 15:43:39 +02:00
- when updating, don't delete files with local modifications
- add testcase
This commit is contained in:
3
TODO
3
TODO
@@ -18,9 +18,6 @@
|
||||
- look at Susannes extensions
|
||||
|
||||
|
||||
> osc up should not delete removed files, when they have been modified
|
||||
> locally.
|
||||
|
||||
checkin:
|
||||
- handle error if PUT fails, so the change is not committed to
|
||||
localmeta
|
||||
|
@@ -568,7 +568,10 @@ usage: osc up
|
||||
for filename in saved_filenames:
|
||||
if filename in disappeared:
|
||||
print statfrmt('D', filename)
|
||||
p.delete_localfile(filename)
|
||||
# keep file if it has local modifications
|
||||
if oldp.status(filename) == ' ':
|
||||
p.delete_localfile(filename)
|
||||
p.delete_storefile(filename)
|
||||
continue
|
||||
|
||||
for filename in p.filenamelist:
|
||||
|
@@ -232,11 +232,13 @@ class Package:
|
||||
self.filenamelist_unvers.remove(n)
|
||||
shutil.copy2(os.path.join(self.dir, n), os.path.join(self.storedir, n))
|
||||
|
||||
def delete_storefile(self, n):
|
||||
try: os.unlink(os.path.join(self.storedir, n))
|
||||
except: pass
|
||||
|
||||
def delete_localfile(self, n):
|
||||
try: os.unlink(os.path.join(self.dir, n))
|
||||
except: pass
|
||||
try: os.unlink(os.path.join(self.storedir, n))
|
||||
except: pass
|
||||
|
||||
def put_on_deletelist(self, n):
|
||||
if n not in self.to_be_deleted:
|
||||
@@ -287,6 +289,7 @@ class Package:
|
||||
othermethods.delfile(u, n, conf.config['user'], conf.config['pass'])
|
||||
|
||||
self.delete_localfile(n)
|
||||
self.delete_storefile(n)
|
||||
|
||||
def put_source_file(self, n):
|
||||
import othermethods
|
||||
|
41
tests.py
41
tests.py
@@ -201,6 +201,47 @@ class TestOsc(unittest.TestCase):
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
||||
def testUpdateLocalMod(self):
|
||||
|
||||
wc1 = os.path.join(BASEDIR, TESTPACDIR)
|
||||
wc2 = os.path.join(BASEDIR, 'otherwc')
|
||||
|
||||
checkout_and_clean(self)
|
||||
|
||||
# in wc1, create and check in two files
|
||||
touch('f1')
|
||||
touch('f2')
|
||||
runosc('add f1 f2')
|
||||
runosc('ci')
|
||||
|
||||
|
||||
# create second working copy, and do a local modification
|
||||
mkdir(wc2)
|
||||
chdir(wc2)
|
||||
runosc('init %s %s' % (PRJ, PAC))
|
||||
runosc('up')
|
||||
open('f2', 'w').write('foo')
|
||||
|
||||
# from wc1, delete the files
|
||||
chdir(wc1)
|
||||
runosc('rm f1 f2')
|
||||
runosc('ci')
|
||||
|
||||
# in wc2, update
|
||||
# f1 should be deleted
|
||||
# f2 should be kept
|
||||
chdir(wc2)
|
||||
self.out, self.err = runosc('up')
|
||||
self.assertEqual(self.err, '')
|
||||
self.assertEqual(remove_revid(self.out), 'D f1\nD f2\nAt revision XX.\n')
|
||||
|
||||
self.out, self.err = runosc('st')
|
||||
self.assertEqual(self.err, '')
|
||||
self.assertEqual(self.out, '? f2\n')
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
||||
def testCoPrj(self):
|
||||
|
Reference in New Issue
Block a user