[Pkg-bazaar-commits] ./bzr/unstable r915: - add simple test case for bzr status
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:21:26 UTC 2009
------------------------------------------------------------
revno: 915
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-07-12 11:44:23 +1000
message:
- add simple test case for bzr status
- show_status takes to_file argument
added:
bzrlib/selftest/teststatus.py
modified:
bzrlib/selftest/__init__.py
bzrlib/status.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py 2005-07-11 07:25:42 +0000
+++ b/bzrlib/selftest/__init__.py 2005-07-12 01:44:23 +0000
@@ -33,6 +33,7 @@
import bzrlib.selftest.testhashcache
import bzrlib.selftest.testrevisionnamespaces
import bzrlib.selftest.testbranch
+ import bzrlib.selftest.teststatus
import bzrlib.merge_core
from doctest import DocTestSuite
import os
@@ -50,6 +51,7 @@
bzrlib.selftest.versioning,
bzrlib.selftest.testmerge3,
bzrlib.selftest.testhashcache,
+ bzrlib.selftest.teststatus,
bzrlib.selftest.blackbox,
bzrlib.selftest.testhashcache,
bzrlib.selftest.testrevisionnamespaces,
=== added file 'bzrlib/selftest/teststatus.py'
--- a/bzrlib/selftest/teststatus.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/selftest/teststatus.py 2005-07-12 01:44:23 +0000
@@ -0,0 +1,49 @@
+# Copyright (C) 2005 by Canonical Ltd
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+"""Tests of status command.
+
+Most of these depend on the particular formatting used.
+"""
+
+
+from bzrlib.selftest import InTempDir
+
+class BranchStatus(InTempDir):
+ def runTest(self):
+ """Basic 'bzr mkdir' operation"""
+ from cStringIO import StringIO
+ from bzrlib.status import show_status
+ from bzrlib.branch import Branch
+
+ b = Branch('.', init=True)
+
+ # status with nothing
+ tof = StringIO()
+ show_status(b, to_file=tof)
+ self.assertEquals(tof.getvalue(), "")
+
+ tof = StringIO()
+ self.build_tree(['hello.c', 'bye.c'])
+ show_status(b, to_file=tof)
+ tof.seek(0)
+ self.assertEquals(tof.readlines(),
+ ['unknown:\n',
+ ' bye.c\n',
+ ' hello.c\n',
+ ])
+
=== modified file 'bzrlib/status.py'
--- a/bzrlib/status.py 2005-05-31 08:10:44 +0000
+++ b/bzrlib/status.py 2005-07-12 01:44:23 +0000
@@ -18,7 +18,8 @@
def show_status(branch, show_unchanged=False,
specific_files=None,
- show_ids=False):
+ show_ids=False,
+ to_file=None):
"""Display single-line status for non-ignored working files.
show_all
@@ -26,9 +27,15 @@
specific_files
If set, only show the status of files in this list.
+
+ to_file
+ If set, write to this file (default stdout.)
"""
import sys
from bzrlib.diff import compare_trees
+
+ if to_file == None:
+ to_file = sys.stdout
branch.lock_read()
try:
@@ -39,7 +46,8 @@
delta = compare_trees(old, new, want_unchanged=show_unchanged,
specific_files=specific_files)
- delta.show(sys.stdout, show_ids=show_ids,
+ delta.show(to_file,
+ show_ids=show_ids,
show_unchanged=show_unchanged)
unknowns = new.unknowns()
@@ -51,9 +59,9 @@
if path not in specific_files:
continue
if not done_header:
- print 'unknown:'
+ print >>to_file, 'unknown:'
done_header = True
- print ' ', path
+ print >>to_file, ' ', path
finally:
branch.unlock()
More information about the Pkg-bazaar-commits
mailing list