Show More
@@ -1,322 +1,324 | |||||
1 | # bundlerepo.py - repository class for viewing uncompressed bundles |
|
1 | # bundlerepo.py - repository class for viewing uncompressed bundles | |
2 | # |
|
2 | # | |
3 | # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
|
3 | # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | """Repository class for viewing uncompressed bundles. |
|
8 | """Repository class for viewing uncompressed bundles. | |
9 |
|
9 | |||
10 | This provides a read-only repository interface to bundles as if they |
|
10 | This provides a read-only repository interface to bundles as if they | |
11 | were part of the actual repository. |
|
11 | were part of the actual repository. | |
12 | """ |
|
12 | """ | |
13 |
|
13 | |||
14 | from node import nullid |
|
14 | from node import nullid | |
15 | from i18n import _ |
|
15 | from i18n import _ | |
16 | import os, struct, tempfile, shutil |
|
16 | import os, struct, tempfile, shutil | |
17 | import changegroup, util, mdiff, discovery |
|
17 | import changegroup, util, mdiff, discovery | |
18 | import localrepo, changelog, manifest, filelog, revlog, error |
|
18 | import localrepo, changelog, manifest, filelog, revlog, error | |
19 |
|
19 | |||
20 | class bundlerevlog(revlog.revlog): |
|
20 | class bundlerevlog(revlog.revlog): | |
21 | def __init__(self, opener, indexfile, bundle, |
|
21 | def __init__(self, opener, indexfile, bundle, | |
22 | linkmapper=None): |
|
22 | linkmapper=None): | |
23 | # How it works: |
|
23 | # How it works: | |
24 | # to retrieve a revision, we need to know the offset of |
|
24 | # to retrieve a revision, we need to know the offset of | |
25 | # the revision in the bundle (an unbundle object). |
|
25 | # the revision in the bundle (an unbundle object). | |
26 | # |
|
26 | # | |
27 | # We store this offset in the index (start), to differentiate a |
|
27 | # We store this offset in the index (start), to differentiate a | |
28 | # rev in the bundle and from a rev in the revlog, we check |
|
28 | # rev in the bundle and from a rev in the revlog, we check | |
29 | # len(index[r]). If the tuple is bigger than 7, it is a bundle |
|
29 | # len(index[r]). If the tuple is bigger than 7, it is a bundle | |
30 | # (it is bigger since we store the node to which the delta is) |
|
30 | # (it is bigger since we store the node to which the delta is) | |
31 | # |
|
31 | # | |
32 | revlog.revlog.__init__(self, opener, indexfile) |
|
32 | revlog.revlog.__init__(self, opener, indexfile) | |
33 | self.bundle = bundle |
|
33 | self.bundle = bundle | |
34 | self.basemap = {} |
|
34 | self.basemap = {} | |
35 | def chunkpositer(): |
|
35 | def chunkpositer(): | |
36 | while 1: |
|
36 | while 1: | |
37 | chunk = bundle.chunk() |
|
37 | chunk = bundle.chunk() | |
38 | if not chunk: |
|
38 | if not chunk: | |
39 | break |
|
39 | break | |
40 | pos = bundle.tell() |
|
40 | pos = bundle.tell() | |
41 | yield chunk, pos - len(chunk) |
|
41 | yield chunk, pos - len(chunk) | |
42 | n = len(self) |
|
42 | n = len(self) | |
43 | prev = None |
|
43 | prev = None | |
44 | for chunk, start in chunkpositer(): |
|
44 | for chunk, start in chunkpositer(): | |
45 | size = len(chunk) |
|
45 | size = len(chunk) | |
46 | if size < 80: |
|
46 | if size < 80: | |
47 | raise util.Abort(_("invalid changegroup")) |
|
47 | raise util.Abort(_("invalid changegroup")) | |
48 | start += 80 |
|
48 | start += 80 | |
49 | size -= 80 |
|
49 | size -= 80 | |
50 | node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80]) |
|
50 | node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80]) | |
51 | if node in self.nodemap: |
|
51 | if node in self.nodemap: | |
52 | prev = node |
|
52 | prev = node | |
53 | continue |
|
53 | continue | |
54 | for p in (p1, p2): |
|
54 | for p in (p1, p2): | |
55 | if not p in self.nodemap: |
|
55 | if not p in self.nodemap: | |
56 | raise error.LookupError(p, self.indexfile, |
|
56 | raise error.LookupError(p, self.indexfile, | |
57 | _("unknown parent")) |
|
57 | _("unknown parent")) | |
58 | if linkmapper is None: |
|
58 | if linkmapper is None: | |
59 | link = n |
|
59 | link = n | |
60 | else: |
|
60 | else: | |
61 | link = linkmapper(cs) |
|
61 | link = linkmapper(cs) | |
62 |
|
62 | |||
63 | if not prev: |
|
63 | if not prev: | |
64 | prev = p1 |
|
64 | prev = p1 | |
65 | # start, size, full unc. size, base (unused), link, p1, p2, node |
|
65 | # start, size, full unc. size, base (unused), link, p1, p2, node | |
66 | e = (revlog.offset_type(start, 0), size, -1, -1, link, |
|
66 | e = (revlog.offset_type(start, 0), size, -1, -1, link, | |
67 | self.rev(p1), self.rev(p2), node) |
|
67 | self.rev(p1), self.rev(p2), node) | |
68 | self.basemap[n] = prev |
|
68 | self.basemap[n] = prev | |
69 | self.index.insert(-1, e) |
|
69 | self.index.insert(-1, e) | |
70 | self.nodemap[node] = n |
|
70 | self.nodemap[node] = n | |
71 | prev = node |
|
71 | prev = node | |
72 | n += 1 |
|
72 | n += 1 | |
73 |
|
73 | |||
74 | def inbundle(self, rev): |
|
74 | def inbundle(self, rev): | |
75 | """is rev from the bundle""" |
|
75 | """is rev from the bundle""" | |
76 | if rev < 0: |
|
76 | if rev < 0: | |
77 | return False |
|
77 | return False | |
78 | return rev in self.basemap |
|
78 | return rev in self.basemap | |
79 | def bundlebase(self, rev): |
|
79 | def bundlebase(self, rev): | |
80 | return self.basemap[rev] |
|
80 | return self.basemap[rev] | |
81 | def _chunk(self, rev): |
|
81 | def _chunk(self, rev): | |
82 | # Warning: in case of bundle, the diff is against bundlebase, |
|
82 | # Warning: in case of bundle, the diff is against bundlebase, | |
83 | # not against rev - 1 |
|
83 | # not against rev - 1 | |
84 | # XXX: could use some caching |
|
84 | # XXX: could use some caching | |
85 | if not self.inbundle(rev): |
|
85 | if not self.inbundle(rev): | |
86 | return revlog.revlog._chunk(self, rev) |
|
86 | return revlog.revlog._chunk(self, rev) | |
87 | self.bundle.seek(self.start(rev)) |
|
87 | self.bundle.seek(self.start(rev)) | |
88 | return self.bundle.read(self.length(rev)) |
|
88 | return self.bundle.read(self.length(rev)) | |
89 |
|
89 | |||
90 | def revdiff(self, rev1, rev2): |
|
90 | def revdiff(self, rev1, rev2): | |
91 | """return or calculate a delta between two revisions""" |
|
91 | """return or calculate a delta between two revisions""" | |
92 | if self.inbundle(rev1) and self.inbundle(rev2): |
|
92 | if self.inbundle(rev1) and self.inbundle(rev2): | |
93 | # hot path for bundle |
|
93 | # hot path for bundle | |
94 | revb = self.rev(self.bundlebase(rev2)) |
|
94 | revb = self.rev(self.bundlebase(rev2)) | |
95 | if revb == rev1: |
|
95 | if revb == rev1: | |
96 | return self._chunk(rev2) |
|
96 | return self._chunk(rev2) | |
97 | elif not self.inbundle(rev1) and not self.inbundle(rev2): |
|
97 | elif not self.inbundle(rev1) and not self.inbundle(rev2): | |
98 | return revlog.revlog.revdiff(self, rev1, rev2) |
|
98 | return revlog.revlog.revdiff(self, rev1, rev2) | |
99 |
|
99 | |||
100 | return mdiff.textdiff(self.revision(self.node(rev1)), |
|
100 | return mdiff.textdiff(self.revision(self.node(rev1)), | |
101 | self.revision(self.node(rev2))) |
|
101 | self.revision(self.node(rev2))) | |
102 |
|
102 | |||
103 | def revision(self, node): |
|
103 | def revision(self, node): | |
104 | """return an uncompressed revision of a given""" |
|
104 | """return an uncompressed revision of a given""" | |
105 | if node == nullid: |
|
105 | if node == nullid: | |
106 | return "" |
|
106 | return "" | |
107 |
|
107 | |||
108 | text = None |
|
108 | text = None | |
109 | chain = [] |
|
109 | chain = [] | |
110 | iter_node = node |
|
110 | iter_node = node | |
111 | rev = self.rev(iter_node) |
|
111 | rev = self.rev(iter_node) | |
112 | # reconstruct the revision if it is from a changegroup |
|
112 | # reconstruct the revision if it is from a changegroup | |
113 | while self.inbundle(rev): |
|
113 | while self.inbundle(rev): | |
114 | if self._cache and self._cache[0] == iter_node: |
|
114 | if self._cache and self._cache[0] == iter_node: | |
115 | text = self._cache[2] |
|
115 | text = self._cache[2] | |
116 | break |
|
116 | break | |
117 | chain.append(rev) |
|
117 | chain.append(rev) | |
118 | iter_node = self.bundlebase(rev) |
|
118 | iter_node = self.bundlebase(rev) | |
119 | rev = self.rev(iter_node) |
|
119 | rev = self.rev(iter_node) | |
120 | if text is None: |
|
120 | if text is None: | |
121 | text = revlog.revlog.revision(self, iter_node) |
|
121 | text = revlog.revlog.revision(self, iter_node) | |
122 |
|
122 | |||
123 | while chain: |
|
123 | while chain: | |
124 | delta = self._chunk(chain.pop()) |
|
124 | delta = self._chunk(chain.pop()) | |
125 | text = mdiff.patches(text, [delta]) |
|
125 | text = mdiff.patches(text, [delta]) | |
126 |
|
126 | |||
127 | p1, p2 = self.parents(node) |
|
127 | p1, p2 = self.parents(node) | |
128 | if node != revlog.hash(text, p1, p2): |
|
128 | if node != revlog.hash(text, p1, p2): | |
129 | raise error.RevlogError(_("integrity check failed on %s:%d") |
|
129 | raise error.RevlogError(_("integrity check failed on %s:%d") | |
130 | % (self.datafile, self.rev(node))) |
|
130 | % (self.datafile, self.rev(node))) | |
131 |
|
131 | |||
132 | self._cache = (node, self.rev(node), text) |
|
132 | self._cache = (node, self.rev(node), text) | |
133 | return text |
|
133 | return text | |
134 |
|
134 | |||
135 | def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): |
|
135 | def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): | |
136 | raise NotImplementedError |
|
136 | raise NotImplementedError | |
137 | def addgroup(self, revs, linkmapper, transaction): |
|
137 | def addgroup(self, revs, linkmapper, transaction): | |
138 | raise NotImplementedError |
|
138 | raise NotImplementedError | |
139 | def strip(self, rev, minlink): |
|
139 | def strip(self, rev, minlink): | |
140 | raise NotImplementedError |
|
140 | raise NotImplementedError | |
141 | def checksize(self): |
|
141 | def checksize(self): | |
142 | raise NotImplementedError |
|
142 | raise NotImplementedError | |
143 |
|
143 | |||
144 | class bundlechangelog(bundlerevlog, changelog.changelog): |
|
144 | class bundlechangelog(bundlerevlog, changelog.changelog): | |
145 | def __init__(self, opener, bundle): |
|
145 | def __init__(self, opener, bundle): | |
146 | changelog.changelog.__init__(self, opener) |
|
146 | changelog.changelog.__init__(self, opener) | |
147 | bundlerevlog.__init__(self, opener, self.indexfile, bundle) |
|
147 | bundlerevlog.__init__(self, opener, self.indexfile, bundle) | |
148 |
|
148 | |||
149 | class bundlemanifest(bundlerevlog, manifest.manifest): |
|
149 | class bundlemanifest(bundlerevlog, manifest.manifest): | |
150 | def __init__(self, opener, bundle, linkmapper): |
|
150 | def __init__(self, opener, bundle, linkmapper): | |
151 | manifest.manifest.__init__(self, opener) |
|
151 | manifest.manifest.__init__(self, opener) | |
152 | bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
|
152 | bundlerevlog.__init__(self, opener, self.indexfile, bundle, | |
153 | linkmapper) |
|
153 | linkmapper) | |
154 |
|
154 | |||
155 | class bundlefilelog(bundlerevlog, filelog.filelog): |
|
155 | class bundlefilelog(bundlerevlog, filelog.filelog): | |
156 | def __init__(self, opener, path, bundle, linkmapper): |
|
156 | def __init__(self, opener, path, bundle, linkmapper): | |
157 | filelog.filelog.__init__(self, opener, path) |
|
157 | filelog.filelog.__init__(self, opener, path) | |
158 | bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
|
158 | bundlerevlog.__init__(self, opener, self.indexfile, bundle, | |
159 | linkmapper) |
|
159 | linkmapper) | |
160 |
|
160 | |||
161 | class bundlerepository(localrepo.localrepository): |
|
161 | class bundlerepository(localrepo.localrepository): | |
162 | def __init__(self, ui, path, bundlename): |
|
162 | def __init__(self, ui, path, bundlename): | |
163 | self._tempparent = None |
|
163 | self._tempparent = None | |
164 | try: |
|
164 | try: | |
165 | localrepo.localrepository.__init__(self, ui, path) |
|
165 | localrepo.localrepository.__init__(self, ui, path) | |
166 | except error.RepoError: |
|
166 | except error.RepoError: | |
167 | self._tempparent = tempfile.mkdtemp() |
|
167 | self._tempparent = tempfile.mkdtemp() | |
168 | localrepo.instance(ui, self._tempparent, 1) |
|
168 | localrepo.instance(ui, self._tempparent, 1) | |
169 | localrepo.localrepository.__init__(self, ui, self._tempparent) |
|
169 | localrepo.localrepository.__init__(self, ui, self._tempparent) | |
170 |
|
170 | |||
171 | if path: |
|
171 | if path: | |
172 | self._url = 'bundle:' + util.expandpath(path) + '+' + bundlename |
|
172 | self._url = 'bundle:' + util.expandpath(path) + '+' + bundlename | |
173 | else: |
|
173 | else: | |
174 | self._url = 'bundle:' + bundlename |
|
174 | self._url = 'bundle:' + bundlename | |
175 |
|
175 | |||
176 | self.tempfile = None |
|
176 | self.tempfile = None | |
177 | f = open(bundlename, "rb") |
|
177 | f = open(bundlename, "rb") | |
178 | self.bundle = changegroup.readbundle(f, bundlename) |
|
178 | self.bundle = changegroup.readbundle(f, bundlename) | |
179 | if self.bundle.compressed(): |
|
179 | if self.bundle.compressed(): | |
180 | fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-", |
|
180 | fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-", | |
181 | suffix=".hg10un", dir=self.path) |
|
181 | suffix=".hg10un", dir=self.path) | |
182 | self.tempfile = temp |
|
182 | self.tempfile = temp | |
183 | fptemp = os.fdopen(fdtemp, 'wb') |
|
183 | fptemp = os.fdopen(fdtemp, 'wb') | |
184 |
|
184 | |||
185 | try: |
|
185 | try: | |
186 | fptemp.write("HG10UN") |
|
186 | fptemp.write("HG10UN") | |
187 | while 1: |
|
187 | while 1: | |
188 | chunk = self.bundle.read(2**18) |
|
188 | chunk = self.bundle.read(2**18) | |
189 | if not chunk: |
|
189 | if not chunk: | |
190 | break |
|
190 | break | |
191 | fptemp.write(chunk) |
|
191 | fptemp.write(chunk) | |
192 | finally: |
|
192 | finally: | |
193 | fptemp.close() |
|
193 | fptemp.close() | |
194 |
|
194 | |||
195 | f = open(self.tempfile, "rb") |
|
195 | f = open(self.tempfile, "rb") | |
196 | self.bundle = changegroup.readbundle(f, bundlename) |
|
196 | self.bundle = changegroup.readbundle(f, bundlename) | |
197 |
|
197 | |||
198 | # dict with the mapping 'filename' -> position in the bundle |
|
198 | # dict with the mapping 'filename' -> position in the bundle | |
199 | self.bundlefilespos = {} |
|
199 | self.bundlefilespos = {} | |
200 |
|
200 | |||
201 | @util.propertycache |
|
201 | @util.propertycache | |
202 | def changelog(self): |
|
202 | def changelog(self): | |
203 | c = bundlechangelog(self.sopener, self.bundle) |
|
203 | c = bundlechangelog(self.sopener, self.bundle) | |
204 | self.manstart = self.bundle.tell() |
|
204 | self.manstart = self.bundle.tell() | |
205 | return c |
|
205 | return c | |
206 |
|
206 | |||
207 | @util.propertycache |
|
207 | @util.propertycache | |
208 | def manifest(self): |
|
208 | def manifest(self): | |
209 | self.bundle.seek(self.manstart) |
|
209 | self.bundle.seek(self.manstart) | |
210 | m = bundlemanifest(self.sopener, self.bundle, self.changelog.rev) |
|
210 | m = bundlemanifest(self.sopener, self.bundle, self.changelog.rev) | |
211 | self.filestart = self.bundle.tell() |
|
211 | self.filestart = self.bundle.tell() | |
212 | return m |
|
212 | return m | |
213 |
|
213 | |||
214 | @util.propertycache |
|
214 | @util.propertycache | |
215 | def manstart(self): |
|
215 | def manstart(self): | |
216 | self.changelog |
|
216 | self.changelog | |
217 | return self.manstart |
|
217 | return self.manstart | |
218 |
|
218 | |||
219 | @util.propertycache |
|
219 | @util.propertycache | |
220 | def filestart(self): |
|
220 | def filestart(self): | |
221 | self.manifest |
|
221 | self.manifest | |
222 | return self.filestart |
|
222 | return self.filestart | |
223 |
|
223 | |||
224 | def url(self): |
|
224 | def url(self): | |
225 | return self._url |
|
225 | return self._url | |
226 |
|
226 | |||
227 | def file(self, f): |
|
227 | def file(self, f): | |
228 | if not self.bundlefilespos: |
|
228 | if not self.bundlefilespos: | |
229 | self.bundle.seek(self.filestart) |
|
229 | self.bundle.seek(self.filestart) | |
230 | while 1: |
|
230 | while 1: | |
231 | chunk = self.bundle.chunk() |
|
231 | chunk = self.bundle.chunk() | |
232 | if not chunk: |
|
232 | if not chunk: | |
233 | break |
|
233 | break | |
234 | self.bundlefilespos[chunk] = self.bundle.tell() |
|
234 | self.bundlefilespos[chunk] = self.bundle.tell() | |
235 | while 1: |
|
235 | while 1: | |
236 | c = self.bundle.chunk() |
|
236 | c = self.bundle.chunk() | |
237 | if not c: |
|
237 | if not c: | |
238 | break |
|
238 | break | |
239 |
|
239 | |||
240 | if f[0] == '/': |
|
240 | if f[0] == '/': | |
241 | f = f[1:] |
|
241 | f = f[1:] | |
242 | if f in self.bundlefilespos: |
|
242 | if f in self.bundlefilespos: | |
243 | self.bundle.seek(self.bundlefilespos[f]) |
|
243 | self.bundle.seek(self.bundlefilespos[f]) | |
244 | return bundlefilelog(self.sopener, f, self.bundle, |
|
244 | return bundlefilelog(self.sopener, f, self.bundle, | |
245 | self.changelog.rev) |
|
245 | self.changelog.rev) | |
246 | else: |
|
246 | else: | |
247 | return filelog.filelog(self.sopener, f) |
|
247 | return filelog.filelog(self.sopener, f) | |
248 |
|
248 | |||
249 | def close(self): |
|
249 | def close(self): | |
250 | """Close assigned bundle file immediately.""" |
|
250 | """Close assigned bundle file immediately.""" | |
251 | self.bundle.close() |
|
251 | self.bundle.close() | |
|
252 | if self.tempfile is not None: | |||
|
253 | os.unlink(self.tempfile) | |||
252 |
|
254 | |||
253 | def __del__(self): |
|
255 | def __del__(self): | |
254 | del self.bundle |
|
256 | del self.bundle | |
255 | if self.tempfile is not None: |
|
257 | if self.tempfile is not None: | |
256 | os.unlink(self.tempfile) |
|
258 | os.unlink(self.tempfile) | |
257 | if self._tempparent: |
|
259 | if self._tempparent: | |
258 | shutil.rmtree(self._tempparent, True) |
|
260 | shutil.rmtree(self._tempparent, True) | |
259 |
|
261 | |||
260 | def cancopy(self): |
|
262 | def cancopy(self): | |
261 | return False |
|
263 | return False | |
262 |
|
264 | |||
263 | def getcwd(self): |
|
265 | def getcwd(self): | |
264 | return os.getcwd() # always outside the repo |
|
266 | return os.getcwd() # always outside the repo | |
265 |
|
267 | |||
266 | def instance(ui, path, create): |
|
268 | def instance(ui, path, create): | |
267 | if create: |
|
269 | if create: | |
268 | raise util.Abort(_('cannot create new bundle repository')) |
|
270 | raise util.Abort(_('cannot create new bundle repository')) | |
269 | parentpath = ui.config("bundle", "mainreporoot", "") |
|
271 | parentpath = ui.config("bundle", "mainreporoot", "") | |
270 | if parentpath: |
|
272 | if parentpath: | |
271 | # Try to make the full path relative so we get a nice, short URL. |
|
273 | # Try to make the full path relative so we get a nice, short URL. | |
272 | # In particular, we don't want temp dir names in test outputs. |
|
274 | # In particular, we don't want temp dir names in test outputs. | |
273 | cwd = os.getcwd() |
|
275 | cwd = os.getcwd() | |
274 | if parentpath == cwd: |
|
276 | if parentpath == cwd: | |
275 | parentpath = '' |
|
277 | parentpath = '' | |
276 | else: |
|
278 | else: | |
277 | cwd = os.path.join(cwd,'') |
|
279 | cwd = os.path.join(cwd,'') | |
278 | if parentpath.startswith(cwd): |
|
280 | if parentpath.startswith(cwd): | |
279 | parentpath = parentpath[len(cwd):] |
|
281 | parentpath = parentpath[len(cwd):] | |
280 | path = util.drop_scheme('file', path) |
|
282 | path = util.drop_scheme('file', path) | |
281 | if path.startswith('bundle:'): |
|
283 | if path.startswith('bundle:'): | |
282 | path = util.drop_scheme('bundle', path) |
|
284 | path = util.drop_scheme('bundle', path) | |
283 | s = path.split("+", 1) |
|
285 | s = path.split("+", 1) | |
284 | if len(s) == 1: |
|
286 | if len(s) == 1: | |
285 | repopath, bundlename = parentpath, s[0] |
|
287 | repopath, bundlename = parentpath, s[0] | |
286 | else: |
|
288 | else: | |
287 | repopath, bundlename = s |
|
289 | repopath, bundlename = s | |
288 | else: |
|
290 | else: | |
289 | repopath, bundlename = parentpath, path |
|
291 | repopath, bundlename = parentpath, path | |
290 | return bundlerepository(ui, repopath, bundlename) |
|
292 | return bundlerepository(ui, repopath, bundlename) | |
291 |
|
293 | |||
292 | def getremotechanges(ui, repo, other, revs=None, bundlename=None, force=False): |
|
294 | def getremotechanges(ui, repo, other, revs=None, bundlename=None, force=False): | |
293 | tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force) |
|
295 | tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force) | |
294 | common, incoming, rheads = tmp |
|
296 | common, incoming, rheads = tmp | |
295 | if not incoming: |
|
297 | if not incoming: | |
296 | try: |
|
298 | try: | |
297 | os.unlink(bundlename) |
|
299 | os.unlink(bundlename) | |
298 | except: |
|
300 | except: | |
299 | pass |
|
301 | pass | |
300 | return other, None, None |
|
302 | return other, None, None | |
301 |
|
303 | |||
302 | bundle = None |
|
304 | bundle = None | |
303 | if bundlename or not other.local(): |
|
305 | if bundlename or not other.local(): | |
304 | # create a bundle (uncompressed if other repo is not local) |
|
306 | # create a bundle (uncompressed if other repo is not local) | |
305 |
|
307 | |||
306 | if revs is None and other.capable('changegroupsubset'): |
|
308 | if revs is None and other.capable('changegroupsubset'): | |
307 | revs = rheads |
|
309 | revs = rheads | |
308 |
|
310 | |||
309 | if revs is None: |
|
311 | if revs is None: | |
310 | cg = other.changegroup(incoming, "incoming") |
|
312 | cg = other.changegroup(incoming, "incoming") | |
311 | else: |
|
313 | else: | |
312 | cg = other.changegroupsubset(incoming, revs, 'incoming') |
|
314 | cg = other.changegroupsubset(incoming, revs, 'incoming') | |
313 | bundletype = other.local() and "HG10BZ" or "HG10UN" |
|
315 | bundletype = other.local() and "HG10BZ" or "HG10UN" | |
314 | fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) |
|
316 | fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) | |
315 | # keep written bundle? |
|
317 | # keep written bundle? | |
316 | if bundlename: |
|
318 | if bundlename: | |
317 | bundle = None |
|
319 | bundle = None | |
318 | if not other.local(): |
|
320 | if not other.local(): | |
319 | # use the created uncompressed bundlerepo |
|
321 | # use the created uncompressed bundlerepo | |
320 | other = bundlerepository(ui, repo.root, fname) |
|
322 | other = bundlerepository(ui, repo.root, fname) | |
321 | return (other, incoming, bundle) |
|
323 | return (other, incoming, bundle) | |
322 |
|
324 |
@@ -1,131 +1,135 | |||||
1 | $ cat <<EOF >> $HGRCPATH |
|
1 | $ cat <<EOF >> $HGRCPATH | |
2 | > [extensions] |
|
2 | > [extensions] | |
3 | > mq= |
|
3 | > mq= | |
4 | > [alias] |
|
4 | > [alias] | |
5 | > tlog = log --template "{rev}: {desc}\\n" |
|
5 | > tlog = log --template "{rev}: {desc}\\n" | |
6 | > theads = heads --template "{rev}: {desc}\\n" |
|
6 | > theads = heads --template "{rev}: {desc}\\n" | |
7 | > tincoming = incoming --template "{rev}: {desc}\\n" |
|
7 | > tincoming = incoming --template "{rev}: {desc}\\n" | |
8 | > EOF |
|
8 | > EOF | |
9 |
|
9 | |||
10 | Setup main: |
|
10 | Setup main: | |
11 |
|
11 | |||
12 | $ hg init base |
|
12 | $ hg init base | |
13 | $ cd base |
|
13 | $ cd base | |
14 | $ echo "One" > one |
|
14 | $ echo "One" > one | |
15 | $ hg add |
|
15 | $ hg add | |
16 | adding one |
|
16 | adding one | |
17 | $ hg ci -m "main: one added" |
|
17 | $ hg ci -m "main: one added" | |
18 | $ echo "++" >> one |
|
18 | $ echo "++" >> one | |
19 | $ hg ci -m "main: one updated" |
|
19 | $ hg ci -m "main: one updated" | |
20 |
|
20 | |||
21 | Bundle main: |
|
21 | Bundle main: | |
22 |
|
22 | |||
23 | $ hg bundle --base=null ../main.hg |
|
23 | $ hg bundle --base=null ../main.hg | |
24 | 2 changesets found |
|
24 | 2 changesets found | |
25 |
|
25 | |||
26 | $ cd .. |
|
26 | $ cd .. | |
27 |
|
27 | |||
28 | Incoming to fresh repo: |
|
28 | Incoming to fresh repo: | |
29 |
|
29 | |||
30 | $ hg init fresh |
|
30 | $ hg init fresh | |
31 |
|
31 | |||
32 | $ hg -R fresh tincoming main.hg |
|
32 | $ hg -R fresh tincoming main.hg | |
33 | comparing with main.hg |
|
33 | comparing with main.hg | |
34 | 0: main: one added |
|
34 | 0: main: one added | |
35 | 1: main: one updated |
|
35 | 1: main: one updated | |
|
36 | $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true | |||
36 |
|
37 | |||
37 | $ hg -R fresh tincoming bundle:fresh+main.hg |
|
38 | $ hg -R fresh tincoming bundle:fresh+main.hg | |
38 | comparing with bundle:fresh+main.hg |
|
39 | comparing with bundle:fresh+main.hg | |
39 | 0: main: one added |
|
40 | 0: main: one added | |
40 | 1: main: one updated |
|
41 | 1: main: one updated | |
41 |
|
42 | |||
42 |
|
43 | |||
43 | Setup queue: |
|
44 | Setup queue: | |
44 |
|
45 | |||
45 | $ cd base |
|
46 | $ cd base | |
46 | $ hg qinit -c |
|
47 | $ hg qinit -c | |
47 | $ hg qnew -m "patch: two added" two.patch |
|
48 | $ hg qnew -m "patch: two added" two.patch | |
48 | $ echo two > two |
|
49 | $ echo two > two | |
49 | $ hg add |
|
50 | $ hg add | |
50 | adding two |
|
51 | adding two | |
51 | $ hg qrefresh |
|
52 | $ hg qrefresh | |
52 | $ hg qcommit -m "queue: two.patch added" |
|
53 | $ hg qcommit -m "queue: two.patch added" | |
53 | $ hg qpop -a |
|
54 | $ hg qpop -a | |
54 | popping two.patch |
|
55 | popping two.patch | |
55 | patch queue now empty |
|
56 | patch queue now empty | |
56 |
|
57 | |||
57 | Bundle queue: |
|
58 | Bundle queue: | |
58 |
|
59 | |||
59 | $ hg -R .hg/patches bundle --base=null ../queue.hgq |
|
60 | $ hg -R .hg/patches bundle --base=null ../queue.hgq | |
60 | 1 changesets found |
|
61 | 1 changesets found | |
|
62 | $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true | |||
61 |
|
63 | |||
62 | $ cd .. |
|
64 | $ cd .. | |
63 |
|
65 | |||
64 |
|
66 | |||
65 | Clone base: |
|
67 | Clone base: | |
66 |
|
68 | |||
67 | $ hg clone base copy |
|
69 | $ hg clone base copy | |
68 | updating to branch default |
|
70 | updating to branch default | |
69 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
71 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
70 | $ cd copy |
|
72 | $ cd copy | |
71 | $ hg qinit -c |
|
73 | $ hg qinit -c | |
72 |
|
74 | |||
73 | Incoming queue bundle: |
|
75 | Incoming queue bundle: | |
74 |
|
76 | |||
75 | $ hg -R .hg/patches tincoming ../queue.hgq |
|
77 | $ hg -R .hg/patches tincoming ../queue.hgq | |
76 | comparing with ../queue.hgq |
|
78 | comparing with ../queue.hgq | |
77 | 0: queue: two.patch added |
|
79 | 0: queue: two.patch added | |
|
80 | $ test -f .hg/hg-bundle* && echo 'temp. bundle file remained' || true | |||
78 |
|
81 | |||
79 | Pull queue bundle: |
|
82 | Pull queue bundle: | |
80 |
|
83 | |||
81 | $ hg -R .hg/patches pull --update ../queue.hgq |
|
84 | $ hg -R .hg/patches pull --update ../queue.hgq | |
82 | pulling from ../queue.hgq |
|
85 | pulling from ../queue.hgq | |
83 | requesting all changes |
|
86 | requesting all changes | |
84 | adding changesets |
|
87 | adding changesets | |
85 | adding manifests |
|
88 | adding manifests | |
86 | adding file changes |
|
89 | adding file changes | |
87 | added 1 changesets with 3 changes to 3 files |
|
90 | added 1 changesets with 3 changes to 3 files | |
88 | merging series |
|
91 | merging series | |
89 | 2 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
92 | 2 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
|
93 | $ test -f .hg/patches/hg-bundle* && echo 'temp. bundle file remained' || true | |||
90 |
|
94 | |||
91 | $ hg -R .hg/patches theads |
|
95 | $ hg -R .hg/patches theads | |
92 | 0: queue: two.patch added |
|
96 | 0: queue: two.patch added | |
93 |
|
97 | |||
94 | $ hg -R .hg/patches tlog |
|
98 | $ hg -R .hg/patches tlog | |
95 | 0: queue: two.patch added |
|
99 | 0: queue: two.patch added | |
96 |
|
100 | |||
97 | $ hg qseries |
|
101 | $ hg qseries | |
98 | two.patch |
|
102 | two.patch | |
99 |
|
103 | |||
100 | $ cd .. |
|
104 | $ cd .. | |
101 |
|
105 | |||
102 |
|
106 | |||
103 | Clone base again: |
|
107 | Clone base again: | |
104 |
|
108 | |||
105 | $ hg clone base copy2 |
|
109 | $ hg clone base copy2 | |
106 | updating to branch default |
|
110 | updating to branch default | |
107 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
111 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
108 | $ cd copy2 |
|
112 | $ cd copy2 | |
109 | $ hg qinit -c |
|
113 | $ hg qinit -c | |
110 |
|
114 | |||
111 | Unbundle queue bundle: |
|
115 | Unbundle queue bundle: | |
112 |
|
116 | |||
113 | $ hg -R .hg/patches unbundle --update ../queue.hgq |
|
117 | $ hg -R .hg/patches unbundle --update ../queue.hgq | |
114 | adding changesets |
|
118 | adding changesets | |
115 | adding manifests |
|
119 | adding manifests | |
116 | adding file changes |
|
120 | adding file changes | |
117 | added 1 changesets with 3 changes to 3 files |
|
121 | added 1 changesets with 3 changes to 3 files | |
118 | merging series |
|
122 | merging series | |
119 | 2 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
123 | 2 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
120 |
|
124 | |||
121 | $ hg -R .hg/patches theads |
|
125 | $ hg -R .hg/patches theads | |
122 | 0: queue: two.patch added |
|
126 | 0: queue: two.patch added | |
123 |
|
127 | |||
124 | $ hg -R .hg/patches tlog |
|
128 | $ hg -R .hg/patches tlog | |
125 | 0: queue: two.patch added |
|
129 | 0: queue: two.patch added | |
126 |
|
130 | |||
127 | $ hg qseries |
|
131 | $ hg qseries | |
128 | two.patch |
|
132 | two.patch | |
129 |
|
133 | |||
130 | $ cd .. |
|
134 | $ cd .. | |
131 |
|
135 |
General Comments 0
You need to be logged in to leave comments.
Login now