~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2011-09-12 18:40:02 UTC
  • mfrom: (6132 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6133.
  • Revision ID: john@arbash-meinel.com-20110912184002-o23eu21fdgp35h2q
Merge bzr.dev, resolve release-notes (aka NEWS) conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    chk_map,
62
62
    commands as _mod_commands,
63
63
    config,
 
64
    i18n,
64
65
    debug,
65
66
    errors,
66
67
    hooks,
1005
1006
        self._counters = {}
1006
1007
        if 'config_stats' in selftest_debug_flags:
1007
1008
            self._install_config_stats_hooks()
 
1009
        # Do not use i18n for tests (unless the test reverses this)
 
1010
        self.overrideAttr(i18n, 'installed', lambda: True)
1008
1011
 
1009
1012
    def debug(self):
1010
1013
        # debug a frame up.
2561
2564
        real branch.
2562
2565
        """
2563
2566
        root = TestCaseWithMemoryTransport.TEST_ROOT
2564
 
        wt = bzrdir.BzrDir.create_standalone_workingtree(root)
 
2567
        try:
 
2568
            # Make sure we get a readable and accessible home for .bzr.log
 
2569
            # and/or config files, and not fallback to weird defaults (see
 
2570
            # http://pad.lv/825027).
 
2571
            self.assertIs(None, os.environ.get('BZR_HOME', None))
 
2572
            os.environ['BZR_HOME'] = root
 
2573
            wt = bzrdir.BzrDir.create_standalone_workingtree(root)
 
2574
            del os.environ['BZR_HOME']
 
2575
        except Exception, e:
 
2576
            self.fail("Fail to initialize the safety net: %r\nExiting\n" % (e,))
2565
2577
        # Hack for speed: remember the raw bytes of the dirstate file so that
2566
2578
        # we don't need to re-open the wt to check it hasn't changed.
2567
2579
        TestCaseWithMemoryTransport._SAFETY_NET_PRISTINE_DIRSTATE = (
2618
2630
    def make_branch(self, relpath, format=None):
2619
2631
        """Create a branch on the transport at relpath."""
2620
2632
        repo = self.make_repository(relpath, format=format)
2621
 
        return repo.bzrdir.create_branch()
 
2633
        return repo.bzrdir.create_branch(append_revisions_only=False)
 
2634
 
 
2635
    def resolve_format(self, format):
 
2636
        """Resolve an object to a ControlDir format object.
 
2637
 
 
2638
        The initial format object can either already be
 
2639
        a ControlDirFormat, None (for the default format),
 
2640
        or a string with the name of the control dir format.
 
2641
 
 
2642
        :param format: Object to resolve
 
2643
        :return A ControlDirFormat instance
 
2644
        """
 
2645
        if format is None:
 
2646
            format = 'default'
 
2647
        if isinstance(format, basestring):
 
2648
            format = bzrdir.format_registry.make_bzrdir(format)
 
2649
        return format
 
2650
 
 
2651
    def resolve_format(self, format):
 
2652
        """Resolve an object to a ControlDir format object.
 
2653
 
 
2654
        The initial format object can either already be
 
2655
        a ControlDirFormat, None (for the default format),
 
2656
        or a string with the name of the control dir format.
 
2657
 
 
2658
        :param format: Object to resolve
 
2659
        :return A ControlDirFormat instance
 
2660
        """
 
2661
        if format is None:
 
2662
            format = 'default'
 
2663
        if isinstance(format, basestring):
 
2664
            format = bzrdir.format_registry.make_bzrdir(format)
 
2665
        return format
2622
2666
 
2623
2667
    def make_bzrdir(self, relpath, format=None):
2624
2668
        try:
2628
2672
            t = _mod_transport.get_transport(maybe_a_url)
2629
2673
            if len(segments) > 1 and segments[-1] not in ('', '.'):
2630
2674
                t.ensure_base()
2631
 
            if format is None:
2632
 
                format = 'default'
2633
 
            if isinstance(format, basestring):
2634
 
                format = bzrdir.format_registry.make_bzrdir(format)
 
2675
            format = self.resolve_format(format)
2635
2676
            return format.initialize_on_transport(t)
2636
2677
        except errors.UninitializableFormat:
2637
2678
            raise TestSkipped("Format %s is not initializable." % format)