Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 3660:8500a13ec44b
create a readbundle function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 15 Nov 2006 15:51:58 -0600 |
parents | 025f68f22ae2 |
children | f4dc02d7fb71 |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Nov 15 15:51:58 2006 -0600 +++ b/mercurial/commands.py Wed Nov 15 15:51:58 2006 -0600 @@ -11,7 +11,7 @@ demandload(globals(), "os re sys signal imp urllib pdb shlex") demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") demandload(globals(), "difflib patch time") -demandload(globals(), "traceback errno version atexit bz2") +demandload(globals(), "traceback errno version atexit") demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") class UnknownCommand(Exception): @@ -2195,29 +2195,8 @@ Apply a compressed changegroup file generated by the bundle command. """ - f = urllib.urlopen(fname) - - header = f.read(6) - if not header.startswith("HG"): - raise util.Abort(_("%s: not a Mercurial bundle file") % fname) - elif not header.startswith("HG10"): - raise util.Abort(_("%s: unknown bundle version") % fname) - elif header == "HG10BZ": - def generator(f): - zd = bz2.BZ2Decompressor() - zd.decompress("BZ") - for chunk in f: - yield zd.decompress(chunk) - elif header == "HG10UN": - def generator(f): - for chunk in f: - yield chunk - else: - raise util.Abort(_("%s: unknown bundle compression type") - % fname) - gen = generator(util.filechunkiter(f, 4096)) - modheads = repo.addchangegroup(util.chunkbuffer(gen), 'unbundle', - 'bundle:' + fname) + gen = changegroup.readbundle(urllib.urlopen(fname)) + modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) return postincoming(ui, repo, modheads, opts['update']) def update(ui, repo, node=None, merge=False, clean=False, force=None,