/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/tests/treeshape.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 12:50:32 UTC
  • mfrom: (6679 work)
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610125032-xb5rd5fjskjallos
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        elif name[-1] == '@':
54
54
            os.symlink(tt[1], tt[0][:-1])
55
55
        else:
56
 
            f = file(name, 'wb')
57
 
            try:
 
56
            with open(name, 'wb') as f:
58
57
                f.write(tt[1])
59
 
            finally:
60
 
                f.close()
61
58
 
62
59
 
63
60
def capture_tree_contents(top):
75
72
            if stat.S_ISLNK(info.st_mode):
76
73
                yield (fullpath + '@', os.readlink(fullpath))
77
74
            elif stat.S_ISREG(info.st_mode):
78
 
                yield (fullpath, file(fullpath, 'rb').read())
 
75
                with open(fullpath, 'rb') as f:
 
76
                    file_bytes = f.read()
 
77
                yield (fullpath, file_bytes)
79
78
            else:
80
79
                warning("can't capture file %s with mode %#o",
81
80
                        fullpath, info.st_mode)