Show More
@@ -25,7 +25,7 b' from mercurial.i18n import _' | |||
|
25 | 25 | from mercurial.node import nullid, nullrev, bin, hex |
|
26 | 26 | from mercurial import changegroup, cmdutil, scmutil, phases, commands |
|
27 | 27 | from mercurial import error, hg, mdiff, merge, patch, repair, util |
|
28 | from mercurial import templatefilters, changegroup | |
|
28 | from mercurial import templatefilters, changegroup, exchange | |
|
29 | 29 | from mercurial import lock as lockmod |
|
30 | 30 | from hgext import rebase |
|
31 | 31 | import errno |
@@ -71,7 +71,7 b' class shelvedfile(object):' | |||
|
71 | 71 | def applybundle(self): |
|
72 | 72 | fp = self.opener() |
|
73 | 73 | try: |
|
74 |
gen = change |
|
|
74 | gen = exchange.readbundle(fp, self.fname, self.vfs) | |
|
75 | 75 | changegroup.addchangegroup(self.repo, gen, 'unshelve', |
|
76 | 76 | 'bundle:' + self.vfs.join(self.fname)) |
|
77 | 77 | finally: |
@@ -14,7 +14,7 b' were part of the actual repository.' | |||
|
14 | 14 | from node import nullid |
|
15 | 15 | from i18n import _ |
|
16 | 16 | import os, tempfile, shutil |
|
17 | import changegroup, util, mdiff, discovery, cmdutil, scmutil | |
|
17 | import changegroup, util, mdiff, discovery, cmdutil, scmutil, exchange | |
|
18 | 18 | import localrepo, changelog, manifest, filelog, revlog, error |
|
19 | 19 | |
|
20 | 20 | class bundlerevlog(revlog.revlog): |
@@ -202,7 +202,7 b' class bundlerepository(localrepo.localre' | |||
|
202 | 202 | |
|
203 | 203 | self.tempfile = None |
|
204 | 204 | f = util.posixfile(bundlename, "rb") |
|
205 |
self.bundle = change |
|
|
205 | self.bundle = exchange.readbundle(f, bundlename) | |
|
206 | 206 | if self.bundle.compressed(): |
|
207 | 207 | fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", |
|
208 | 208 | suffix=".hg10un") |
@@ -220,7 +220,7 b' class bundlerepository(localrepo.localre' | |||
|
220 | 220 | fptemp.close() |
|
221 | 221 | |
|
222 | 222 | f = self.vfs.open(self.tempfile, mode="rb") |
|
223 |
self.bundle = change |
|
|
223 | self.bundle = exchange.readbundle(f, bundlename, self.vfs) | |
|
224 | 224 | |
|
225 | 225 | # dict with the mapping 'filename' -> position in the bundle |
|
226 | 226 | self.bundlefilespos = {} |
@@ -227,25 +227,6 b' class headerlessfixup(object):' | |||
|
227 | 227 | return d |
|
228 | 228 | return readexactly(self._fh, n) |
|
229 | 229 | |
|
230 | def readbundle(fh, fname, vfs=None): | |
|
231 | header = readexactly(fh, 6) | |
|
232 | ||
|
233 | if not fname: | |
|
234 | fname = "stream" | |
|
235 | if not header.startswith('HG') and header.startswith('\0'): | |
|
236 | fh = headerlessfixup(fh, header) | |
|
237 | header = "HG10UN" | |
|
238 | elif vfs: | |
|
239 | fname = vfs.join(fname) | |
|
240 | ||
|
241 | magic, version, alg = header[0:2], header[2:4], header[4:6] | |
|
242 | ||
|
243 | if magic != 'HG': | |
|
244 | raise util.Abort(_('%s: not a Mercurial bundle') % fname) | |
|
245 | if version != '10': | |
|
246 | raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) | |
|
247 | return unbundle10(fh, alg) | |
|
248 | ||
|
249 | 230 | class bundle10(object): |
|
250 | 231 | deltaheader = _BUNDLE10_DELTA_HEADER |
|
251 | 232 | def __init__(self, repo, bundlecaps=None): |
@@ -20,7 +20,7 b' import minirst, revset, fileset' | |||
|
20 | 20 | import dagparser, context, simplemerge, graphmod |
|
21 | 21 | import random |
|
22 | 22 | import setdiscovery, treediscovery, dagutil, pvec, localrepo |
|
23 | import phases, obsolete | |
|
23 | import phases, obsolete, exchange | |
|
24 | 24 | |
|
25 | 25 | table = {} |
|
26 | 26 | |
@@ -1736,7 +1736,7 b' def debugbundle(ui, bundlepath, all=None' | |||
|
1736 | 1736 | """lists the contents of a bundle""" |
|
1737 | 1737 | f = hg.openpath(ui, bundlepath) |
|
1738 | 1738 | try: |
|
1739 |
gen = change |
|
|
1739 | gen = exchange.readbundle(f, bundlepath) | |
|
1740 | 1740 | if all: |
|
1741 | 1741 | ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n")) |
|
1742 | 1742 | |
@@ -5807,7 +5807,7 b' def unbundle(ui, repo, fname1, *fnames, ' | |||
|
5807 | 5807 | try: |
|
5808 | 5808 | for fname in fnames: |
|
5809 | 5809 | f = hg.openpath(ui, fname) |
|
5810 |
gen = change |
|
|
5810 | gen = exchange.readbundle(f, fname) | |
|
5811 | 5811 | modheads = changegroup.addchangegroup(repo, gen, 'unbundle', |
|
5812 | 5812 | 'bundle:' + fname) |
|
5813 | 5813 | finally: |
@@ -11,6 +11,25 b' import errno' | |||
|
11 | 11 | import util, scmutil, changegroup, base85 |
|
12 | 12 | import discovery, phases, obsolete, bookmarks, bundle2 |
|
13 | 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) | |
|
32 | ||
|
14 | 33 | |
|
15 | 34 | class pushoperation(object): |
|
16 | 35 | """A object that represent a single push operation |
@@ -6,7 +6,7 b'' | |||
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | from mercurial import changegroup | |
|
9 | from mercurial import changegroup, exchange | |
|
10 | 10 | from mercurial.node import short |
|
11 | 11 | from mercurial.i18n import _ |
|
12 | 12 | import errno |
@@ -147,7 +147,7 b' def strip(ui, repo, nodelist, backup="al' | |||
|
147 | 147 | if saveheads or savebases: |
|
148 | 148 | ui.note(_("adding branch\n")) |
|
149 | 149 | f = vfs.open(chgrpfile, "rb") |
|
150 |
gen = change |
|
|
150 | gen = exchange.readbundle(f, chgrpfile, vfs) | |
|
151 | 151 | if not repo.ui.verbose: |
|
152 | 152 | # silence internal shuffling chatter |
|
153 | 153 | repo.ui.pushbuffer() |
@@ -766,7 +766,7 b' def unbundle(repo, proto, heads):' | |||
|
766 | 766 | try: |
|
767 | 767 | proto.getfile(fp) |
|
768 | 768 | fp.seek(0) |
|
769 |
gen = change |
|
|
769 | gen = exchange.readbundle(fp, None) | |
|
770 | 770 | r = exchange.unbundle(repo, gen, their_heads, 'serve', |
|
771 | 771 | proto._client()) |
|
772 | 772 | return pushres(r) |
General Comments 0
You need to be logged in to leave comments.
Login now