/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/fastimport/idmapfile.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""Routines for saving and loading the id-map file."""
17
17
 
18
 
from __future__ import absolute_import
19
 
 
20
18
import os
21
19
 
22
20
 
31
29
    """
32
30
    with open(filename, 'wb') as f:
33
31
        for commit_id in revision_ids:
34
 
            f.write("%s %s\n" % (commit_id, revision_ids[commit_id]))
 
32
            f.write(b"%s %s\n" % (commit_id, revision_ids[commit_id]))
35
33
 
36
34
 
37
35
def load_id_map(filename):
51
49
    result = {}
52
50
    count = 0
53
51
    if os.path.exists(filename):
54
 
        f = open(filename)
55
 
        try:
 
52
        with open(filename) as f:
56
53
            for line in f:
57
54
                parts = line[:-1].split(' ', 1)
58
55
                result[parts[0]] = parts[1]
59
56
                count += 1
60
 
        finally:
61
 
            f.close()
62
57
    return result, count