Exemplo n.º 1
0
 def test_show_error(self):
     show_error('error1')
     show_error(u'error2 \xb5 blah')
     show_error('arg: %s', 'blah')
     show_error('arg2: %(key)s', {'key':'stuff'})
     try:
         raise Exception("oops")
     except:
         show_error('kwarg', exc_info=True)
     log = self.get_log()
     self.assertContainsRe(log, 'error1')
     self.assertContainsRe(log, u'error2 \xb5 blah')
     self.assertContainsRe(log, 'arg: blah')
     self.assertContainsRe(log, 'arg2: stuff')
     self.assertContainsRe(log, 'kwarg')
     self.assertContainsRe(log, 'Traceback \\(most recent call last\\):')
     self.assertContainsRe(log, 'File ".*test_trace.py", line .*, in test_show_error')
     self.assertContainsRe(log, 'raise Exception\\("oops"\\)')
     self.assertContainsRe(log, 'Exception: oops')
Exemplo n.º 2
0
 def test_show_error(self):
     show_error('error1')
     show_error(u'error2 \xb5 blah')
     show_error('arg: %s', 'blah')
     show_error('arg2: %(key)s', {'key': 'stuff'})
     try:
         raise Exception("oops")
     except:
         show_error('kwarg', exc_info=True)
     log = self.get_log()
     self.assertContainsRe(log, 'error1')
     self.assertContainsRe(log, u'error2 \xb5 blah')
     self.assertContainsRe(log, 'arg: blah')
     self.assertContainsRe(log, 'arg2: stuff')
     self.assertContainsRe(log, 'kwarg')
     self.assertContainsRe(log, 'Traceback \\(most recent call last\\):')
     self.assertContainsRe(
         log, 'File ".*test_trace.py", line .*, in test_show_error')
     self.assertContainsRe(log, 'raise Exception\\("oops"\\)')
     self.assertContainsRe(log, 'Exception: oops')
Exemplo n.º 3
0
    def _get_matching_branches(self):
        """Get the Bazaar branches.

        :return: branch_tips, lost_heads where
          branch_tips = a list of (branch,tip) tuples for branches. The
            first tip is the 'trunk'.
          lost_heads = a list of (bazaar-name,revision) for branches that
            would have been created had the repository been shared and
            everything succeeded
        """
        branch_tips = []
        lost_heads = []
        ref_names = self.heads_by_ref.keys()
        if self.branch is not None:
            trunk = self.select_trunk(ref_names)
            default_tip = self.heads_by_ref[trunk][0]
            branch_tips.append((self.branch, default_tip))
            ref_names.remove(trunk)

        # Convert the reference names into Bazaar speak. If we haven't
        # already put the 'trunk' first, do it now.
        git_to_bzr_map = {}
        for ref_name in ref_names:
            git_to_bzr_map[ref_name] = self.cache_mgr.branch_mapper.git_to_bzr(ref_name)
        if ref_names and self.branch is None:
            trunk = self.select_trunk(ref_names)
            git_bzr_items = [(trunk, git_to_bzr_map[trunk])]
            del git_to_bzr_map[trunk]
        else:
            git_bzr_items = []
        git_bzr_items.extend(sorted(git_to_bzr_map.items(), key=itemgetter(1)))

        # Policy for locating branches
        def dir_under_current(name, ref_name):
            # Using the Bazaar name, get a directory under the current one
            repo_base = self.repo.bzrdir.transport.base
            return osutils.pathjoin(repo_base, "..", name)
        def dir_sister_branch(name, ref_name):
            # Using the Bazaar name, get a sister directory to the branch
            return osutils.pathjoin(self.branch.base, "..", name)
        if self.branch is not None:
            dir_policy = dir_sister_branch
        else:
            dir_policy = dir_under_current

        # Create/track missing branches
        shared_repo = self.repo.is_shared()
        for ref_name, name in git_bzr_items:
            tip = self.heads_by_ref[ref_name][0]
            if shared_repo:
                location = dir_policy(name, ref_name)
                try:
                    br = self.make_branch(location)
                    branch_tips.append((br,tip))
                    continue
                except errors.BzrError, ex:
                    show_error("ERROR: failed to create branch %s: %s",
                        location, ex)
            lost_head = self.cache_mgr.lookup_committish(tip)
            lost_info = (name, lost_head)
            lost_heads.append(lost_info)