/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

  • Committer: Jelmer Vernooij
  • Date: 2018-03-06 01:46:14 UTC
  • mfrom: (0.200.1819 work)
  • mto: (0.200.1820 work)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180306014614-w4yooagw6ufouzf4
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
240
240
        """Export a file id map to a fileid map.
241
241
 
242
242
        :param fileid_map: File id map, mapping paths to file ids
243
 
        :return: A Git blob object
 
243
        :return: A Git blob object (or None if there are no entries)
244
244
        """
245
245
        from dulwich.objects import Blob
246
246
        b = Blob()
 
247
        for path, file_id in fileid_map.items():
 
248
            if self.generate_file_id(path) != file_id:
 
249
                del fileid_map[path]
 
250
        if not fileid_map:
 
251
            return None
247
252
        b.set_raw_chunks(serialize_fileid_map(fileid_map))
248
253
        return b
249
254
 
282
287
            encoding = rev.properties['git-explicit-encoding']
283
288
        except KeyError:
284
289
            encoding = rev.properties.get('git-implicit-encoding', 'utf-8')
285
 
        commit.encoding = rev.properties.get('git-explicit-encoding')
 
290
        try:
 
291
            commit.encoding = rev.properties['git-explicit-encoding'].encode('ascii')
 
292
        except KeyError:
 
293
            pass
286
294
        commit.committer = fix_person_identifier(rev.committer.encode(
287
295
            encoding))
288
296
        commit.author = fix_person_identifier(
299
307
            commit.author_timezone = int(rev.properties['author-timezone'])
300
308
        else:
301
309
            commit.author_timezone = commit.commit_timezone
 
310
        if 'git-gpg-signature' in rev.properties:
 
311
            commit.gpgsig = rev.properties['git-gpg-signature'].encode('ascii')
302
312
        commit.message = self._encode_commit_message(rev, rev.message,
303
313
            encoding)
304
314
        assert type(commit.message) == str
310
320
            mapping_properties = set(
311
321
                ['author', 'author-timezone', 'author-timezone-neg-utc',
312
322
                 'commit-timezone-neg-utc', 'git-implicit-encoding',
313
 
                 'git-explicit-encoding', 'author-timestamp', 'file-modes'])
 
323
                 'git-gpg-signature', 'git-explicit-encoding',
 
324
                 'author-timestamp', 'file-modes'])
314
325
            for k, v in rev.properties.iteritems():
315
326
                if not k in mapping_properties:
316
327
                    metadata.properties[k] = v
317
 
        if not lossy:
 
328
        if not lossy and metadata:
318
329
            if self.roundtripping:
319
330
                commit.message = inject_bzr_metadata(commit.message, metadata,
320
331
                                                     encoding)
371
382
            rev.properties['author-timezone-neg-utc'] = ""
372
383
        if commit._commit_timezone_neg_utc:
373
384
            rev.properties['commit-timezone-neg-utc'] = ""
 
385
        if commit.gpgsig:
 
386
            rev.properties['git-gpg-signature'] = commit.gpgsig.decode('ascii')
374
387
        rev.timestamp = commit.commit_time
375
388
        rev.timezone = commit.commit_timezone
376
389
        rev.parent_ids = None
662
675
 
663
676
    def copy(self):
664
677
        return self.__class__(dict(self.file_ids), self.mapping)
 
678
 
 
679
 
 
680
def needs_roundtripping(repo, revid):
 
681
    try:
 
682
        mapping_registry.parse_revision_id(revid)
 
683
    except errors.InvalidRevisionId:
 
684
        return True
 
685
    else:
 
686
        return False