/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/mapping.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-13 22:54:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6968.
  • Revision ID: jelmer@jelmer.uk-20180513225428-5ysu0bs9rtk7045h
Initial work to support brz-git on python3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    serialize_fileid_map,
58
58
    )
59
59
 
60
 
DEFAULT_FILE_MODE = stat.S_IFREG | 0644
 
60
try:
 
61
    from urllib.parse import quote
 
62
except ImportError:
 
63
    from urllib import quote
 
64
 
 
65
DEFAULT_FILE_MODE = stat.S_IFREG | 0o644
61
66
HG_RENAME_SOURCE = "HG:rename-source"
62
67
HG_EXTRA = "HG:extra"
63
68
 
166
171
        return unescape_file_id(file_id[len(FILE_ID_PREFIX):])
167
172
 
168
173
    def revid_as_refname(self, revid):
169
 
        import urllib
170
 
        return "refs/bzr/%s" % urllib.quote(revid)
 
174
        return "refs/bzr/%s" % quote(revid)
171
175
 
172
176
    def import_unusual_file_modes(self, rev, unusual_file_modes):
173
177
        if unusual_file_modes:
551
555
 
552
556
def mode_is_executable(mode):
553
557
    """Check if mode should be considered executable."""
554
 
    return bool(mode & 0111)
 
558
    return bool(mode & 0o111)
555
559
 
556
560
 
557
561
def mode_kind(mode):
558
562
    """Determine the Bazaar inventory kind based on Unix file mode."""
559
563
    if mode is None:
560
564
        return None
561
 
    entry_kind = (mode & 0700000) / 0100000
 
565
    entry_kind = (mode & 0o700000) / 0o100000
562
566
    if entry_kind == 0:
563
567
        return 'directory'
564
568
    elif entry_kind == 1:
565
 
        file_kind = (mode & 070000) / 010000
 
569
        file_kind = (mode & 0o70000) / 0o10000
566
570
        if file_kind == 0:
567
571
            return 'file'
568
572
        elif file_kind == 2:
583
587
    elif kind == 'symlink':
584
588
        mode = stat.S_IFLNK
585
589
        if executable:
586
 
            mode |= 0111
 
590
            mode |= 0o111
587
591
        return mode
588
592
    elif kind == 'file':
589
 
        mode = stat.S_IFREG | 0644
 
593
        mode = stat.S_IFREG | 0o644
590
594
        if executable:
591
 
            mode |= 0111
 
595
            mode |= 0o111
592
596
        return mode
593
597
    elif kind == 'tree-reference':
594
598
        from dulwich.objects import S_IFGITLINK