~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-04 14:48:21 UTC
  • mto: (4349.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4350.
  • Revision ID: v.ladeuil+lp@free.fr-20090504144821-39dvqkikmd3zqkdg
Handle servers proposing several authentication schemes.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractAuthHandler.auth_required): Several schemes can be
proposed by the server, try to match each one in turn.
(BasicAuthHandler.auth_match): Delete dead code.

* bzrlib/tests/test_http.py:
(load_tests): Separate proxy and http authentication tests as they
require different server setups.
(TestAuth.create_transport_readonly_server): Simplified by using
parameter provided by load_tests.
(TestAuth.test_changing_nonce): Adapt to new parametrization.
(TestProxyAuth.create_transport_readonly_server): Deleted.

* bzrlib/tests/http_utils.py:
(DigestAndBasicAuthRequestHandler, HTTPBasicAndDigestAuthServer,
ProxyBasicAndDigestAuthServer): Add a test server proposing both
basic and digest auth schemes but accepting only digest as valid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 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
18
18
import errno
19
19
import re
20
20
 
21
 
from bzrlib.lazy_import import lazy_import
22
 
lazy_import(globals(), """
23
21
from bzrlib import (
24
 
    bencode,
25
22
    errors,
26
23
    merge,
27
24
    merge3,
 
25
    osutils,
28
26
    pack,
29
27
    transform,
 
28
    ui,
 
29
    workingtree,
30
30
)
31
 
""")
 
31
from bzrlib.util import bencode
32
32
 
33
33
 
34
34
class ShelfCreator(object):
37
37
    def __init__(self, work_tree, target_tree, file_list=None):
38
38
        """Constructor.
39
39
 
40
 
        :param work_tree: The working tree to apply changes to. This is not
41
 
            required to be locked - a tree_write lock will be taken out.
 
40
        :param work_tree: The working tree to apply changes to
42
41
        :param target_tree: The tree to make the working tree more similar to.
43
 
            This is not required to be locked - a read_lock will be taken out.
44
42
        :param file_list: The files to make more similar to the target.
45
43
        """
46
44
        self.work_tree = work_tree
65
63
        """Iterable of tuples describing shelvable changes.
66
64
 
67
65
        As well as generating the tuples, this updates several members.
68
 
        Tuples may be::
69
 
 
 
66
        Tuples may be:
70
67
           ('add file', file_id, work_kind, work_path)
71
68
           ('delete file', file_id, target_kind, target_path)
72
69
           ('rename', file_id, target_path, work_path)
76
73
        """
77
74
        for (file_id, paths, changed, versioned, parents, names, kind,
78
75
             executable) in self.iter_changes:
79
 
            # don't shelve add of tree root.  Working tree should never
80
 
            # lack roots, and bzr misbehaves when they do.
81
 
            # FIXME ADHB (2009-08-09): should still shelve adds of tree roots
82
 
            # when a tree root was deleted / renamed.
83
 
            if kind[0] is None and names[1] == '':
84
 
                continue
85
76
            if kind[0] is None or versioned[0] == False:
86
77
                self.creation[file_id] = (kind[1], names[1], parents[1],
87
78
                                          versioned)
105
96
                elif changed:
106
97
                    yield ('modify text', file_id)
107
98
 
108
 
    def shelve_change(self, change):
109
 
        """Shelve a change in the iter_shelvable format."""
110
 
        if change[0] == 'rename':
111
 
            self.shelve_rename(change[1])
112
 
        elif change[0] == 'delete file':
113
 
            self.shelve_deletion(change[1])
114
 
        elif change[0] == 'add file':
115
 
            self.shelve_creation(change[1])
116
 
        elif change[0] in ('change kind', 'modify text'):
117
 
            self.shelve_content_change(change[1])
118
 
        elif change[0] == 'modify target':
119
 
            self.shelve_modify_target(change[1])
120
 
        else:
121
 
            raise ValueError('Unknown change kind: "%s"' % change[0])
122
 
 
123
 
    def shelve_all(self):
124
 
        """Shelve all changes."""
125
 
        for change in self.iter_shelvable():
126
 
            self.shelve_change(change)
127
 
 
128
99
    def shelve_rename(self, file_id):
129
100
        """Shelve a file rename.
130
101