1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-12 23:56:13 +01:00

- small fixes for do_status and get_diff

- get_diff:
  * more helpful error message if a file was added and the local
    file was removed again
  * unify self.filenamelist and self.to_be_added if self.todo is empty
  * extended testcases
- do_status: be able to run "osc st <nonexistentfile>"
This commit is contained in:
Marcus Huewe 2010-09-02 13:41:20 +02:00
parent e5016d0f64
commit 94eb143d8c
13 changed files with 37 additions and 3 deletions

View File

@ -2819,7 +2819,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
pacpaths += [arg + '/' + n for n in prj.pacs_have]
elif is_package_dir(arg):
pacpaths.append(arg)
elif os.path.isfile(arg):
elif os.path.isfile(arg) or is_package_dir(os.path.dirname(arg)):
pacpaths.append(arg)
else:
msg = '\'%s\' is neither a project or a package directory' % arg

View File

@ -1389,7 +1389,7 @@ class Package:
return diff
if revision is None:
todo = self.todo or self.filenamelist+self.to_be_added
todo = self.todo or [i for i in self.filenamelist if not i in self.to_be_added]+self.to_be_added
for fname in todo:
if fname in self.to_be_added and self.status(fname) == 'A':
added.append(fname)
@ -1397,6 +1397,9 @@ class Package:
deleted.append(fname)
elif fname in self.filenamelist:
kept.append(self.findfilebyname(fname))
elif fname in self.to_be_added and self.status(fname) == '!':
raise oscerr.OscIOError(None, 'file \'%s\' is marked as \'A\' but does not exist\n'\
'(either add the missing file or revert it)' % fname)
elif not ignoreUnversioned:
raise oscerr.OscIOError(None, 'file \'%s\' is not under version control' % fname)
else:

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1,3 @@
<directory name="replaced" rev="2" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="2">
<entry md5="81be947db54c2e225dc8eacce64d8a4a" mtime="1282731457" name="replaced" size="17" />
</directory>

View File

@ -0,0 +1 @@
foo

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
replaced

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1 @@
replaced

View File

@ -0,0 +1 @@
yet another file

View File

@ -0,0 +1 @@
foo replaced

View File

@ -1,4 +1,4 @@
<directory name="conflict" rev="2" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="2">
<directory name="simple" rev="2" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="2">
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />

View File

@ -115,6 +115,13 @@ class TestDiffFiles(OscTestCase):
p.todo = ['toadd2']
self.assertRaises(osc.oscerr.OscIOError, self.__check_diff, p, '', None)
def testDiffAddedMissing(self):
"""diff a file which has satus 'A' but the local file does not exist"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
p.todo = ['addedmissing']
self.assertRaises(osc.oscerr.OscIOError, self.__check_diff, p, '', None)
def testDiffMultipleFiles(self):
"""diff multiple files"""
self._change_to_pkg('simple')
@ -135,6 +142,19 @@ class TestDiffFiles(OscTestCase):
""" % (TestDiffFiles.diff_hdr % 'nochange', TestDiffFiles.diff_hdr % 'somefile')
self.__check_diff(p, exp, None)
def testDiffReplacedEmptyTodo(self):
"""diff a complete package"""
self._change_to_pkg('replaced')
p = osc.core.Package('.')
exp = """%s
--- replaced\t(revision 2)
+++ replaced\t(working copy)
@@ -1,1 +1,1 @@
-yet another file
+foo replaced
""" % (TestDiffFiles.diff_hdr % 'replaced')
self.__check_diff(p, exp, None)
def testDiffBinaryAdded(self):
"""diff an added binary file"""
self._change_to_pkg('binary')