Mercurial > hg
comparison mercurial/exchange.py @ 21063:7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
The `readbundle` function is going to understand the bundle2 header. We move the
function to a more suitable place before making any other changes.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 14 Apr 2014 15:33:50 -0400 |
parents | e7c0a65a5c9c |
children | 4d9d490d7bbe |
comparison
equal
deleted
inserted
replaced
21062:e7c0a65a5c9c | 21063:7ca4f2049d3b |
---|---|
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 |