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

Warn about unusual modes and escaped XML-invalid characters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    errors,
25
25
    foreign,
26
26
    osutils,
 
27
    trace,
27
28
    urlutils,
28
29
    )
29
30
from bzrlib.inventory import (
69
70
    return "%s <%s>" % (text, text)
70
71
 
71
72
 
 
73
def warn_escaped(commit, num_escaped):
 
74
    trace.warning("Escaped %d XML-invalid characters in %s. Will be unable "
 
75
                  "to regenerate the SHA map.", num_escaped, commit)
 
76
 
 
77
 
 
78
def warn_unusual_mode(commit, path, mode):
 
79
    trace.warning("Unusual file mode %o for %s in %s. Will be unable to "
 
80
                  "regenerate the SHA map.", mode, path, commit)
 
81
 
 
82
 
72
83
class BzrGitMapping(foreign.VcsMapping):
73
84
    """Class that maps between Git and Bazaar semantics."""
74
85
    experimental = False
112
123
            raise AssertionError("Commit object can't be None")
113
124
        rev = ForeignRevision(commit.id, self, self.revision_id_foreign_to_bzr(commit.id))
114
125
        rev.parent_ids = tuple([self.revision_id_foreign_to_bzr(p) for p in commit.parents])
115
 
        rev.message = escape_invalid_chars(commit.message.decode("utf-8", "replace"))[0]
116
 
        rev.committer = escape_invalid_chars(str(commit.committer).decode("utf-8", "replace"))[0]
 
126
        rev.message, num_escaped = escape_invalid_chars(commit.message.decode("utf-8", "replace"))
 
127
        if num_escaped:
 
128
            warn_escaped(commit.id, num_escaped)
 
129
        rev.committer, num_escaped = escape_invalid_chars(str(commit.committer).decode("utf-8", "replace"))
 
130
        if num_escaped:
 
131
            warn_escaped(commit.id, num_escaped)
117
132
        if commit.committer != commit.author:
118
 
            rev.properties['author'] = escape_invalid_chars(str(commit.author).decode("utf-8", "replace"))[0]
 
133
            rev.properties['author'], num_escaped = escape_invalid_chars(str(commit.author).decode("utf-8", "replace"))
 
134
            if num_escaped:
 
135
                warn_escaped(commit.id, num_escaped)
119
136
 
120
137
        if commit.commit_time != commit.author_time:
121
138
            rev.properties['author-timestamp'] = str(commit.author_time)