/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to remote.py

Clean up trailing whitespace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
import bzrlib
17
18
from bzrlib import (
18
19
    config,
19
 
    debug,
20
20
    tag,
21
21
    trace,
22
22
    ui,
29
29
    NoSuchRevision,
30
30
    NotLocalUrl,
31
31
    )
 
32
from bzrlib.trace import (
 
33
    info,
 
34
    )
32
35
from bzrlib.transport import (
33
36
    Transport,
34
37
    )
68
71
import tempfile
69
72
import urllib
70
73
import urlparse
71
 
urlparse.uses_netloc.extend(['git', 'git+ssh'])
72
74
 
73
75
from dulwich.pack import load_pack_index
74
76
 
79
81
    return []
80
82
 
81
83
 
82
 
def split_git_url(url):
83
 
    """Split a Git URL.
84
 
 
85
 
    :param url: Git URL
86
 
    :return: Tuple with host, port, username, path.
87
 
    """
88
 
    (scheme, netloc, loc, _, _) = urlparse.urlsplit(url)
89
 
    path = urllib.unquote(loc)
90
 
    if path.startswith("/~"):
91
 
        path = path[1:]
92
 
    (username, hostport) = urllib.splituser(netloc)
93
 
    (host, port) = urllib.splitnport(hostport, None)
94
 
    return (host, port, username, path)
95
 
 
96
 
 
97
84
class GitSmartTransport(Transport):
98
85
 
99
86
    def __init__(self, url, _client=None):
100
87
        Transport.__init__(self, url)
101
 
        (self._host, self._port, self._username, self._path) = \
102
 
            split_git_url(url)
103
 
        if 'transport' in debug.debug_flags:
104
 
            trace.mutter('host: %r, user: %r, port: %r, path: %r',
105
 
                         self._host, self._username, self._port, self._path)
 
88
        (scheme, _, loc, _, _) = urlparse.urlsplit(url)
 
89
        hostport, escaped_path = urllib.splithost(loc)
 
90
        self._path = urllib.unquote(escaped_path)
 
91
        (self._username, hostport) = urllib.splituser(hostport)
 
92
        (self._host, self._port) = urllib.splitnport(hostport, None)
106
93
        self._client = _client
107
94
 
108
95
    def external_url(self):
120
107
    def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None):
121
108
        if progress is None:
122
109
            def progress(text):
123
 
                trace.info("git: %s" % text)
 
110
                info("git: %s" % text)
124
111
        client = self._get_client(thin_packs=False)
125
112
        try:
126
113
            return client.fetch_pack(self._get_path(), determine_wants,
192
179
        self._lockfiles = lockfiles
193
180
        self._mode_check_done = None
194
181
 
195
 
    def _branch_name_to_ref(self, name):
196
 
        from bzrlib.plugins.git.branch import branch_name_to_ref
197
 
        return branch_name_to_ref(name, default="refs/heads/master")
198
 
 
199
182
    def open_repository(self):
200
183
        return RemoteGitRepository(self, self._lockfiles)
201
184
 
202
 
    def _open_branch(self, name=None, ignore_fallbacks=False, 
203
 
                    unsupported=False):
 
185
    def open_branch(self, ignore_fallbacks=False):
204
186
        repo = self.open_repository()
205
 
        refname = self._branch_name_to_ref(name)
206
 
        return RemoteGitBranch(self, repo, refname, self._lockfiles)
 
187
        # TODO: Support for multiple branches in one bzrdir in bzrlib!
 
188
        return RemoteGitBranch(self, repo, "HEAD", self._lockfiles)
207
189
 
208
190
    def open_workingtree(self, recommend_upgrade=False):
209
191
        raise NotLocalUrl(self.transport.base)
345
327
        if self._ref is not None:
346
328
            return self._ref
347
329
        heads = self.repository.get_refs()
348
 
        if self.name in heads:
349
 
            self._ref = heads[self.name]
350
 
        elif ("refs/heads/" + self.name) in heads:
351
 
            self._ref = heads["refs/heads/" + self.name]
352
 
        else:
 
330
        if not self.name in heads:
353
331
            raise NoSuchRef(self.name)
 
332
        self._ref = heads[self.name]
354
333
        return self._ref
355
334
 
356
335
    def _synchronize_history(self, destination, revision_id):