~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-22 16:28:47 UTC
  • mto: This revision was merged to the branch mainline in revision 4922.
  • Revision ID: john@arbash-meinel.com-20091222162847-tvnsc69to4l4uf5r
Implement a permute_for_extension helper.

Use it for all of the 'simple' extension permutations.
It basically permutes all tests in the current module, by setting TestCase.module.
Which works well for most of our extension tests. Some had more advanced
handling of permutations (extra permutations, custom vars, etc.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
from cStringIO import StringIO
23
23
import struct
24
24
import sys
25
 
import thread
26
25
import threading
27
26
import time
28
27
 
62
61
 
63
62
def _encode_tuple(args):
64
63
    """Encode the tuple args to a bytestream."""
65
 
    joined = '\x01'.join(args) + '\n'
66
 
    if type(joined) is unicode:
67
 
        # XXX: We should fix things so this never happens!  -AJB, 20100304
68
 
        mutter('response args contain unicode, should be only bytes: %r',
69
 
               joined)
70
 
        joined = joined.encode('ascii')
71
 
    return joined
 
64
    return '\x01'.join(args) + '\n'
72
65
 
73
66
 
74
67
class Requester(object):
1154
1147
        self.response_sent = False
1155
1148
        self._headers = {'Software version': bzrlib.__version__}
1156
1149
        if 'hpss' in debug.debug_flags:
1157
 
            self._thread_id = thread.get_ident()
 
1150
            # python 2.6 introduced 'ident' as a nice small integer to
 
1151
            # represent a thread. But it doesn't exist in 2.4/2.5
 
1152
            cur_thread = threading.currentThread()
 
1153
            self._thread_id = getattr(cur_thread, 'ident', None)
 
1154
            if self._thread_id is None:
 
1155
                self._thread_id = cur_thread.getName()
1158
1156
            self._response_start_time = None
1159
1157
 
1160
1158
    def _trace(self, action, message, extra_bytes=None, include_time=False):