9 from node import * |
9 from node import * |
10 from i18n import gettext as _ |
10 from i18n import gettext as _ |
11 demandload(globals(), "os re sys signal imp urllib pdb shlex") |
11 demandload(globals(), "os re sys signal imp urllib pdb shlex") |
12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") |
12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") |
13 demandload(globals(), "difflib patch time") |
13 demandload(globals(), "difflib patch time") |
14 demandload(globals(), "traceback errno version atexit bz2") |
14 demandload(globals(), "traceback errno version atexit") |
15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") |
15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") |
16 |
16 |
17 class UnknownCommand(Exception): |
17 class UnknownCommand(Exception): |
18 """Exception raised if command is not in the command table.""" |
18 """Exception raised if command is not in the command table.""" |
19 class AmbiguousCommand(Exception): |
19 class AmbiguousCommand(Exception): |
2193 """apply a changegroup file |
2193 """apply a changegroup file |
2194 |
2194 |
2195 Apply a compressed changegroup file generated by the bundle |
2195 Apply a compressed changegroup file generated by the bundle |
2196 command. |
2196 command. |
2197 """ |
2197 """ |
2198 f = urllib.urlopen(fname) |
2198 gen = changegroup.readbundle(urllib.urlopen(fname)) |
2199 |
2199 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) |
2200 header = f.read(6) |
|
2201 if not header.startswith("HG"): |
|
2202 raise util.Abort(_("%s: not a Mercurial bundle file") % fname) |
|
2203 elif not header.startswith("HG10"): |
|
2204 raise util.Abort(_("%s: unknown bundle version") % fname) |
|
2205 elif header == "HG10BZ": |
|
2206 def generator(f): |
|
2207 zd = bz2.BZ2Decompressor() |
|
2208 zd.decompress("BZ") |
|
2209 for chunk in f: |
|
2210 yield zd.decompress(chunk) |
|
2211 elif header == "HG10UN": |
|
2212 def generator(f): |
|
2213 for chunk in f: |
|
2214 yield chunk |
|
2215 else: |
|
2216 raise util.Abort(_("%s: unknown bundle compression type") |
|
2217 % fname) |
|
2218 gen = generator(util.filechunkiter(f, 4096)) |
|
2219 modheads = repo.addchangegroup(util.chunkbuffer(gen), 'unbundle', |
|
2220 'bundle:' + fname) |
|
2221 return postincoming(ui, repo, modheads, opts['update']) |
2200 return postincoming(ui, repo, modheads, opts['update']) |
2222 |
2201 |
2223 def update(ui, repo, node=None, merge=False, clean=False, force=None, |
2202 def update(ui, repo, node=None, merge=False, clean=False, force=None, |
2224 branch=None): |
2203 branch=None): |
2225 """update or merge working directory |
2204 """update or merge working directory |