~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_diff.py

  • Committer: Vincent Ladeuil
  • Date: 2010-02-10 15:46:03 UTC
  • mfrom: (4985.3.21 update)
  • mto: This revision was merged to the branch mainline in revision 5021.
  • Revision ID: v.ladeuil+lp@free.fr-20100210154603-k4no1gvfuqpzrw7p
Update performs two merges in a more logical order but stop on conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Black-box tests for bzr diff.
21
21
import os
22
22
import re
23
23
 
24
 
import bzrlib
25
 
from bzrlib import workingtree
26
 
from bzrlib.branch import Branch
27
 
from bzrlib.tests import TestSkipped
28
 
from bzrlib.tests.blackbox import ExternalBase
 
24
from bzrlib import (
 
25
    tests,
 
26
    workingtree,
 
27
    )
29
28
 
30
29
 
31
30
def subst_dates(string):
34
33
                  'YYYY-MM-DD HH:MM:SS +ZZZZ', string)
35
34
 
36
35
 
37
 
class DiffBase(ExternalBase):
 
36
class DiffBase(tests.TestCaseWithTransport):
38
37
    """Base class with common setup method"""
39
38
 
40
39
    def make_example_branch(self):
202
201
 
203
202
    def test_diff_branches(self):
204
203
        self.example_branches()
205
 
        # should open branch1 and diff against branch2, 
 
204
        # should open branch1 and diff against branch2,
206
205
        self.check_b2_vs_b1('diff -r branch:branch2 branch1')
207
206
        # Compare two working trees using various syntax forms
208
207
        self.check_b2_vs_b1('diff --old branch2 --new branch1')
355
354
 
356
355
    def test_external_diff(self):
357
356
        """Test that we can spawn an external diff process"""
 
357
        self.disable_missing_extensions_warning()
358
358
        # We have to use run_bzr_subprocess, because we need to
359
359
        # test writing directly to stdout, (there was a bug in
360
360
        # subprocess.py that we had to workaround).
361
361
        # However, if 'diff' may not be available
362
362
        self.make_example_branch()
363
 
        orig_progress = os.environ.get('BZR_PROGRESS_BAR')
364
 
        try:
365
 
            os.environ['BZR_PROGRESS_BAR'] = 'none'
366
 
            out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
367
 
                                               universal_newlines=True,
368
 
                                               retcode=None)
369
 
        finally:
370
 
            if orig_progress is None:
371
 
                del os.environ['BZR_PROGRESS_BAR']
372
 
            else:
373
 
                os.environ['BZR_PROGRESS_BAR'] = orig_progress
374
 
            
 
363
        # this will be automatically restored by the base bzr test class
 
364
        os.environ['BZR_PROGRESS_BAR'] = 'none'
 
365
        out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
 
366
                                           universal_newlines=True,
 
367
                                           retcode=None)
375
368
        if 'Diff is not installed on this machine' in err:
376
 
            raise TestSkipped("No external 'diff' is available")
 
369
            raise tests.TestSkipped("No external 'diff' is available")
377
370
        self.assertEqual('', err)
378
371
        # We have to skip the stuff in the middle, because it depends
379
372
        # on time.time()