8 from i18n import _ |
8 from i18n import _ |
9 from node import hex, nullid |
9 from node import hex, nullid |
10 import errno |
10 import errno |
11 import util, scmutil, changegroup, base85 |
11 import util, scmutil, changegroup, base85 |
12 import discovery, phases, obsolete, bookmarks, bundle2 |
12 import discovery, phases, obsolete, bookmarks, bundle2 |
|
13 |
|
14 def readbundle(fh, fname, vfs=None): |
|
15 header = changegroup.readexactly(fh, 6) |
|
16 |
|
17 if not fname: |
|
18 fname = "stream" |
|
19 if not header.startswith('HG') and header.startswith('\0'): |
|
20 fh = changegroup.headerlessfixup(fh, header) |
|
21 header = "HG10UN" |
|
22 elif vfs: |
|
23 fname = vfs.join(fname) |
|
24 |
|
25 magic, version, alg = header[0:2], header[2:4], header[4:6] |
|
26 |
|
27 if magic != 'HG': |
|
28 raise util.Abort(_('%s: not a Mercurial bundle') % fname) |
|
29 if version != '10': |
|
30 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
|
31 return changegroup.unbundle10(fh, alg) |
13 |
32 |
14 |
33 |
15 class pushoperation(object): |
34 class pushoperation(object): |
16 """A object that represent a single push operation |
35 """A object that represent a single push operation |
17 |
36 |