/breezy-hg/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-hg/trunk

« back to all changes in this revision

Viewing changes to mapping.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-19 21:21:33 UTC
  • Revision ID: jelmer@jelmer.uk-20181119212133-l9vwjrub3sd8tia8
Fix tests against current brz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    revision as _mod_revision,
36
36
    trace,
37
37
    )
 
38
from breezy.sixish import text_type
38
39
 
39
40
import urllib
40
41
 
41
42
 
42
43
def mode_kind(mode):
43
44
    """Determine the Bazaar inventory kind based on Unix file mode."""
44
 
    entry_kind = (mode & 0700000) / 0100000
 
45
    entry_kind = (mode & 0o700000) / 0o100000
45
46
    if entry_kind == 0:
46
47
        return 'directory'
47
48
    elif entry_kind == 1:
48
 
        file_kind = (mode & 070000) / 010000
 
49
        file_kind = (mode & 0o70000) / 0o10000
49
50
        if file_kind == 0:
50
51
            return 'file'
51
52
        elif file_kind == 2:
307
308
    @classmethod
308
309
    def generate_file_id(self, path):
309
310
        """Create a synthetic file_id for an hg file."""
310
 
        if isinstance(path, unicode):
 
311
        if isinstance(path, text_type):
311
312
            path = path.encode("utf-8")
312
313
        if path == "":
313
314
            return "TREE_ROOT"
317
318
    def parse_file_id(self, fileid):
318
319
        """Parse a file id."""
319
320
        assert isinstance(fileid, str)
320
 
        if not fileid.startswith("hg:"):
321
 
            raise ValueError
 
321
        if not fileid.startswith(b"hg:"):
 
322
            raise ValueError('invalid file id %r' % fileid)
322
323
        return unescape_path(fileid[len("hg:"):])
323
324
 
324
325
    def export_revision(self, rev, lossy=True, fileids={}):