Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 1972:ce127cb4ee6e
Documented behaviour of write_bundle regarding file handles.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sat, 18 Mar 2006 10:45:21 +0100 |
parents | 915b81a35e46 |
children | 9103902a5a8d |
comparison
equal
deleted
inserted
replaced
1971:915b81a35e46 | 1972:ce127cb4ee6e |
---|---|
273 return open(make_filename(repo, r, pat, node, total, seqno, revwidth, | 273 return open(make_filename(repo, r, pat, node, total, seqno, revwidth, |
274 pathname), | 274 pathname), |
275 mode) | 275 mode) |
276 | 276 |
277 def write_bundle(cg, filename, compress=True, fh=None): | 277 def write_bundle(cg, filename, compress=True, fh=None): |
278 """Write a bundle file, optionally without bz2 compression. | |
279 | |
280 A file handle (fh) may be passed and is guaranteed to be closed. | |
281 """ | |
278 if fh is None: | 282 if fh is None: |
279 fh = open(filename, "wb") | 283 fh = open(filename, "wb") |
280 | 284 |
281 class nocompress(object): | 285 class nocompress(object): |
282 def compress(self, x): | 286 def compress(self, x): |
1790 fname = opts["bundle"] | 1794 fname = opts["bundle"] |
1791 f = open(fname, "wb") | 1795 f = open(fname, "wb") |
1792 | 1796 |
1793 cg = other.changegroup(incoming, "incoming") | 1797 cg = other.changegroup(incoming, "incoming") |
1794 write_bundle(cg, fname, compress=other.local(), fh=f) | 1798 write_bundle(cg, fname, compress=other.local(), fh=f) |
1799 # write_bundle closed f for us. | |
1795 if not other.local(): | 1800 if not other.local(): |
1796 # use a bundlerepo | 1801 # use a bundlerepo |
1797 other = bundlerepo.bundlerepository(ui, repo.root, fname) | 1802 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
1798 | 1803 |
1799 o = other.changelog.nodesbetween(incoming)[0] | 1804 o = other.changelog.nodesbetween(incoming)[0] |