From 9a944edfebf60e3a538a5350e4f72c563efcd3fa Mon Sep 17 00:00:00 2001 From: "Dr. Peter Poeml" Date: Tue, 23 Jan 2007 00:32:45 +0000 Subject: [PATCH] - sort output of 'status' (unknown files first, filenames alphabetically) - fix the unit tests for the above change, and for api changes --- osc/commandline.py | 16 ++++++++++++++-- tests.py | 10 +++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index bb33ae86..3a3acc83 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -386,15 +386,27 @@ usage: osc st # no files given as argument? Take all files in current dir if not p.todo: p.todo = p.filenamelist + p.filenamelist_unvers + p.todo.sort() + lines = [] for filename in p.todo: if filename in p.excluded: continue s = p.status(filename) if s == 'F': - print statfrmt('!', pathjoin(p.dir, filename)) + lines.append(statfrmt('!', pathjoin(p.dir, filename))) elif s != ' ': - print statfrmt(s, pathjoin(p.dir, filename)) + lines.append(statfrmt(s, pathjoin(p.dir, filename))) + # for -v (later) + #else: + # lines.append(statfrmt(s, pathjoin(p.dir, filename))) + + # arrange the lines in order: unknown files first + # filenames are already sorted + lines = [line for line in lines if line[0] == '?'] \ + + [line for line in lines if line[0] != '?'] + if lines: + print '\n'.join(lines) def add(args): diff --git a/tests.py b/tests.py index 755e897c..e3b5999b 100755 --- a/tests.py +++ b/tests.py @@ -92,7 +92,7 @@ class TestOsc(unittest.TestCase): def testMetaPac(self): self.out, self.err = runosc('meta Apache apache2') self.assertEqual(self.err, '') - self.assert_('' in self.out) + self.assert_('' in self.out) ##################################################################### @@ -107,7 +107,7 @@ class TestOsc(unittest.TestCase): def testPlatformsPac(self): self.out, self.err = runosc('platforms Apache') self.assertEqual(self.err, '') - self.assert_('SUSE_Linux_Factory' in self.out) + self.assert_('openSUSE_Factory' in self.out) ##################################################################### @@ -181,17 +181,17 @@ Transmitting file data self.out, self.err = runosc('add foo2') self.out, self.err = runosc('st') self.assertEqual(self.err, '') - self.assertEqual(self.out, 'A foo2\n? onlyinwc\n') + self.assertEqual(self.out, '? onlyinwc\nA foo2\n') # status with an absolute directory as argument self.out, self.err = runosc('st %s' % os.getcwd()) self.assertEqual(self.err, '') - self.assertEqual(self.out, 'A %s/foo2\n? %s/onlyinwc\n' % (os.getcwd(), os.getcwd())) + self.assertEqual(self.out, '? %s/onlyinwc\nA %s/foo2\n' % (os.getcwd(), os.getcwd())) # status with an absolute directory as argument self.out, self.err = runosc('st %s' % os.getcwd()) self.assertEqual(self.err, '') - self.assertEqual(self.out, 'A %s/foo2\n? %s/onlyinwc\n' % (os.getcwd(), os.getcwd())) + self.assertEqual(self.out, '? %s/onlyinwc\nA %s/foo2\n' % (os.getcwd(), os.getcwd())) # status with a single file as argument reldir = os.path.basename(os.getcwd())