/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-15 19:05:51 UTC
  • mfrom: (6968 work)
  • mto: (6973.5.1 python3-c)
  • mto: This revision was merged to the branch mainline in revision 6984.
  • Revision ID: jelmer@jelmer.uk-20180515190551-epr5abd0mtxmrehr
merge trunk

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:
557
561
 
558
562
def mode_is_executable(mode):
559
563
    """Check if mode should be considered executable."""
560
 
    return bool(mode & 0111)
 
564
    return bool(mode & 0o111)
561
565
 
562
566
 
563
567
def mode_kind(mode):
564
568
    """Determine the Bazaar inventory kind based on Unix file mode."""
565
569
    if mode is None:
566
570
        return None
567
 
    entry_kind = (mode & 0700000) / 0100000
 
571
    entry_kind = (mode & 0o700000) / 0o100000
568
572
    if entry_kind == 0:
569
573
        return 'directory'
570
574
    elif entry_kind == 1:
571
 
        file_kind = (mode & 070000) / 010000
 
575
        file_kind = (mode & 0o70000) / 0o10000
572
576
        if file_kind == 0:
573
577
            return 'file'
574
578
        elif file_kind == 2:
589
593
    elif kind == 'symlink':
590
594
        mode = stat.S_IFLNK
591
595
        if executable:
592
 
            mode |= 0111
 
596
            mode |= 0o111
593
597
        return mode
594
598
    elif kind == 'file':
595
 
        mode = stat.S_IFREG | 0644
 
599
        mode = stat.S_IFREG | 0o644
596
600
        if executable:
597
 
            mode |= 0111
 
601
            mode |= 0o111
598
602
        return mode
599
603
    elif kind == 'tree-reference':
600
604
        from dulwich.objects import S_IFGITLINK