/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 breezy/plugins/git/transportgit.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-25 18:15:53 UTC
  • mfrom: (7045.4.7 python3-s)
  • Revision ID: breezy.the.bot@gmail.com-20180725181553-mz6zhncntlovb8ii
Fix another couple of hundred tests on Python 3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-s/+merge/350749

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    REFSDIR,
60
60
    SYMREF,
61
61
    check_ref_format,
62
 
    read_gitfile,
63
62
    read_packed_refs_with_peeled,
64
63
    read_packed_refs,
65
64
    write_packed_refs,
136
135
        try:
137
136
            iter_files = list(self.transport.clone("refs").iter_files_recursive())
138
137
            for filename in iter_files:
139
 
                unquoted_filename = urlutils.unquote(filename)
140
 
                if PY3:
141
 
                    # JRV: Work around unquote returning a text_type string on
142
 
                    # PY3.
143
 
                    unquoted_filename = unquoted_filename.encode('utf-8')
 
138
                unquoted_filename = urlutils.unquote_to_bytes(filename)
144
139
                refname = osutils.pathjoin(b"refs", unquoted_filename)
145
140
                if check_ref_format(refname):
146
141
                    keys.add(refname)
387
382
                return LogicalLockResult(unlock)
388
383
 
389
384
 
 
385
# TODO(jelmer): Use upstream read_gitfile; unfortunately that expects strings
 
386
# rather than bytes..
 
387
def read_gitfile(f):
 
388
    """Read a ``.git`` file.
 
389
 
 
390
    The first line of the file should start with "gitdir: "
 
391
 
 
392
    :param f: File-like object to read from
 
393
    :return: A path
 
394
    """
 
395
    cs = f.read()
 
396
    if not cs.startswith(b"gitdir: "):
 
397
        raise ValueError("Expected file to start with 'gitdir: '")
 
398
    return cs[len(b"gitdir: "):].rstrip(b"\n")
 
399
 
 
400
 
390
401
class TransportRepo(BaseRepo):
391
402
 
392
403
    def __init__(self, transport, bare, refs_text=None):
401
412
            else:
402
413
                self._controltransport = self.transport.clone('.git')
403
414
        else:
404
 
            self._controltransport = self.transport.clone(path)
 
415
            self._controltransport = self.transport.clone(urlutils.quote_from_bytes(path))
405
416
        commondir = self.get_named_file(COMMONDIR)
406
417
        if commondir is not None:
407
418
            with commondir: