Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 1969:6d17d420c46c
write_bundle: close the file before removing it in case of failure
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 17 Mar 2006 18:53:04 +0100 |
parents | f8b0e73e320f |
children | 119165543ce6 |
comparison
equal
deleted
inserted
replaced
1968:37dd4928d042 | 1969:6d17d420c46c |
---|---|
295 if not chunk: | 295 if not chunk: |
296 break | 296 break |
297 fh.write(z.compress(chunk)) | 297 fh.write(z.compress(chunk)) |
298 fh.write(z.flush()) | 298 fh.write(z.flush()) |
299 except: | 299 except: |
300 fh.close() | |
300 os.unlink(filename) | 301 os.unlink(filename) |
301 raise | 302 raise |
303 fh.close() | |
302 | 304 |
303 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, | 305 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
304 changes=None, text=False, opts={}): | 306 changes=None, text=False, opts={}): |
305 if not node1: | 307 if not node1: |
306 node1 = repo.dirstate.parents()[0] | 308 node1 = repo.dirstate.parents()[0] |
1788 fname = opts["bundle"] | 1790 fname = opts["bundle"] |
1789 f = open(fname, "wb") | 1791 f = open(fname, "wb") |
1790 | 1792 |
1791 cg = other.changegroup(incoming, "incoming") | 1793 cg = other.changegroup(incoming, "incoming") |
1792 write_bundle(cg, fname, compress=other.local(), fh=f) | 1794 write_bundle(cg, fname, compress=other.local(), fh=f) |
1793 f.close() | |
1794 if not other.local(): | 1795 if not other.local(): |
1795 # use a bundlerepo | 1796 # use a bundlerepo |
1796 other = bundlerepo.bundlerepository(ui, repo.root, fname) | 1797 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
1797 | 1798 |
1798 o = other.changelog.nodesbetween(incoming)[0] | 1799 o = other.changelog.nodesbetween(incoming)[0] |