##// END OF EJS Templates
bundle2: prepare readbundle to return more that one type of bundle...
Pierre-Yves David -
r21065:f9a9a6d6 default
parent child Browse files
Show More
@@ -12,23 +12,28 b' import util, scmutil, changegroup, base8'
12 import discovery, phases, obsolete, bookmarks, bundle2
12 import discovery, phases, obsolete, bookmarks, bundle2
13
13
14 def readbundle(ui, fh, fname, vfs=None):
14 def readbundle(ui, fh, fname, vfs=None):
15 header = changegroup.readexactly(fh, 6)
15 header = changegroup.readexactly(fh, 4)
16
16
17 alg = None
17 if not fname:
18 if not fname:
18 fname = "stream"
19 fname = "stream"
19 if not header.startswith('HG') and header.startswith('\0'):
20 if not header.startswith('HG') and header.startswith('\0'):
20 fh = changegroup.headerlessfixup(fh, header)
21 fh = changegroup.headerlessfixup(fh, header)
21 header = "HG10UN"
22 header = "HG10"
23 alg = 'UN'
22 elif vfs:
24 elif vfs:
23 fname = vfs.join(fname)
25 fname = vfs.join(fname)
24
26
25 magic, version, alg = header[0:2], header[2:4], header[4:6]
27 magic, version = header[0:2], header[2:4]
26
28
27 if magic != 'HG':
29 if magic != 'HG':
28 raise util.Abort(_('%s: not a Mercurial bundle') % fname)
30 raise util.Abort(_('%s: not a Mercurial bundle') % fname)
29 if version != '10':
31 if version == '10':
32 if alg is None:
33 alg = changegroup.readexactly(fh, 2)
34 return changegroup.unbundle10(fh, alg)
35 else:
30 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
36 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
31 return changegroup.unbundle10(fh, alg)
32
37
33
38
34 class pushoperation(object):
39 class pushoperation(object):
General Comments 0
You need to be logged in to leave comments. Login now