Mercurial > hg
annotate mercurial/bundlerepo.py @ 6437:101526031d06
hgweb: fix merge breakage
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 31 Mar 2008 23:14:25 -0500 |
parents | 5c96a4bca66b |
children | c15bfe9cdcd6 |
rev | line source |
---|---|
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
1 """ |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
2 bundlerepo.py - repository class for viewing uncompressed bundles |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
3 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
4 This provides a read-only repository interface to bundles as if |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
5 they were part of the actual repository. |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
6 |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4257
diff
changeset
|
7 Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
8 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
9 This software may be used and distributed according to the terms |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
10 of the GNU General Public License, incorporated herein by reference. |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
11 """ |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
12 |
6211
f89fd07fc51d
Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents:
6129
diff
changeset
|
13 from node import hex, nullid, short |
3891 | 14 from i18n import _ |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
15 import changegroup, util, os, struct, bz2, tempfile, shutil, mdiff |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
16 import repo, localrepo, changelog, manifest, filelog, revlog |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
17 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
18 class bundlerevlog(revlog.revlog): |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
19 def __init__(self, opener, indexfile, bundlefile, |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
20 linkmapper=None): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
21 # How it works: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
22 # to retrieve a revision, we need to know the offset of |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
23 # the revision in the bundlefile (an opened file). |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
24 # |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
25 # We store this offset in the index (start), to differentiate a |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
26 # rev in the bundle and from a rev in the revlog, we check |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
27 # len(index[r]). If the tuple is bigger than 7, it is a bundle |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
28 # (it is bigger since we store the node to which the delta is) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
29 # |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
30 revlog.revlog.__init__(self, opener, indexfile) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
31 self.bundlefile = bundlefile |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
32 self.basemap = {} |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
33 def chunkpositer(): |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
34 for chunk in changegroup.chunkiter(bundlefile): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
35 pos = bundlefile.tell() |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
36 yield chunk, pos - len(chunk) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
37 n = self.count() |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
38 prev = None |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
39 for chunk, start in chunkpositer(): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
40 size = len(chunk) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
41 if size < 80: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
42 raise util.Abort("invalid changegroup") |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
43 start += 80 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
44 size -= 80 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
45 node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80]) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
46 if node in self.nodemap: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
47 prev = node |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
48 continue |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
49 for p in (p1, p2): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
50 if not p in self.nodemap: |
6228
c0c4c7b1e8d3
revlog: report node and file when lookup fails
Matt Mackall <mpm@selenic.com>
parents:
6211
diff
changeset
|
51 raise revlog.LookupError(p1, self.indexfile, |
c0c4c7b1e8d3
revlog: report node and file when lookup fails
Matt Mackall <mpm@selenic.com>
parents:
6211
diff
changeset
|
52 _("unknown parent")) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
53 if linkmapper is None: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
54 link = n |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
55 else: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
56 link = linkmapper(cs) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
57 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
58 if not prev: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
59 prev = p1 |
5167
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
60 # start, size, full unc. size, base (unused), link, p1, p2, node |
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
61 e = (revlog.offset_type(start, 0), size, -1, -1, link, |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
62 self.rev(p1), self.rev(p2), node) |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
63 self.basemap[n] = prev |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
64 self.index.insert(-1, e) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
65 self.nodemap[node] = n |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
66 prev = node |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
67 n += 1 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
68 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
69 def bundle(self, rev): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
70 """is rev from the bundle""" |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
71 if rev < 0: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
72 return False |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
73 return rev in self.basemap |
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
74 def bundlebase(self, rev): return self.basemap[rev] |
2256
4b71f37cbdb7
fix errors spotted by pychecker (mostly scope problems)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2176
diff
changeset
|
75 def chunk(self, rev, df=None, cachelen=4096): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
76 # Warning: in case of bundle, the diff is against bundlebase, |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
77 # not against rev - 1 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
78 # XXX: could use some caching |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
79 if not self.bundle(rev): |
4988
14486eea8e7a
revlog: speed up chunkcache
Matt Mackall <mpm@selenic.com>
parents:
4984
diff
changeset
|
80 return revlog.revlog.chunk(self, rev, df) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
81 self.bundlefile.seek(self.start(rev)) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
82 return self.bundlefile.read(self.length(rev)) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
83 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
84 def revdiff(self, rev1, rev2): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
85 """return or calculate a delta between two revisions""" |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
86 if self.bundle(rev1) and self.bundle(rev2): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
87 # hot path for bundle |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
88 revb = self.rev(self.bundlebase(rev2)) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
89 if revb == rev1: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
90 return self.chunk(rev2) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
91 elif not self.bundle(rev1) and not self.bundle(rev2): |
4028
540d1059c802
bundlerepo: it was meant to be revdiff() instead of chunk()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3791
diff
changeset
|
92 return revlog.revlog.revdiff(self, rev1, rev2) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
93 |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
94 return mdiff.textdiff(self.revision(self.node(rev1)), |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
95 self.revision(self.node(rev2))) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
96 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
97 def revision(self, node): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
98 """return an uncompressed revision of a given""" |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
99 if node == nullid: return "" |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
100 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
101 text = None |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
102 chain = [] |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
103 iter_node = node |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
104 rev = self.rev(iter_node) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
105 # reconstruct the revision if it is from a changegroup |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
106 while self.bundle(rev): |
4984 | 107 if self._cache and self._cache[0] == iter_node: |
108 text = self._cache[2] | |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
109 break |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
110 chain.append(rev) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
111 iter_node = self.bundlebase(rev) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
112 rev = self.rev(iter_node) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
113 if text is None: |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
114 text = revlog.revlog.revision(self, iter_node) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
115 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
116 while chain: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
117 delta = self.chunk(chain.pop()) |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
118 text = mdiff.patches(text, [delta]) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
119 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
120 p1, p2 = self.parents(node) |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
121 if node != revlog.hash(text, p1, p2): |
2256
4b71f37cbdb7
fix errors spotted by pychecker (mostly scope problems)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2176
diff
changeset
|
122 raise revlog.RevlogError(_("integrity check failed on %s:%d") |
2257
8dafccbcede9
indent: fix alignment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2256
diff
changeset
|
123 % (self.datafile, self.rev(node))) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
124 |
4984 | 125 self._cache = (node, self.rev(node), text) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
126 return text |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
127 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
128 def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
129 raise NotImplementedError |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
130 def addgroup(self, revs, linkmapper, transaction, unique=0): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
131 raise NotImplementedError |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
132 def strip(self, rev, minlink): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
133 raise NotImplementedError |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
134 def checksize(self): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
135 raise NotImplementedError |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
136 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
137 class bundlechangelog(bundlerevlog, changelog.changelog): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
138 def __init__(self, opener, bundlefile): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
139 changelog.changelog.__init__(self, opener) |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
140 bundlerevlog.__init__(self, opener, self.indexfile, bundlefile) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
141 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
142 class bundlemanifest(bundlerevlog, manifest.manifest): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
143 def __init__(self, opener, bundlefile, linkmapper): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
144 manifest.manifest.__init__(self, opener) |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
145 bundlerevlog.__init__(self, opener, self.indexfile, bundlefile, |
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
146 linkmapper) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
147 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
148 class bundlefilelog(bundlerevlog, filelog.filelog): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
149 def __init__(self, opener, path, bundlefile, linkmapper): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
150 filelog.filelog.__init__(self, opener, path) |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
151 bundlerevlog.__init__(self, opener, self.indexfile, bundlefile, |
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
152 linkmapper) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
153 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
154 class bundlerepository(localrepo.localrepository): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
155 def __init__(self, ui, path, bundlename): |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
156 self._tempparent = None |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
157 try: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
158 localrepo.localrepository.__init__(self, ui, path) |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
159 except repo.RepoError: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
160 self._tempparent = tempfile.mkdtemp() |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
161 tmprepo = localrepo.instance(ui,self._tempparent,1) |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
162 localrepo.localrepository.__init__(self, ui, self._tempparent) |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
163 |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
164 if path: |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
165 self._url = 'bundle:' + path + '+' + bundlename |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
166 else: |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
167 self._url = 'bundle:' + bundlename |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
168 |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
169 self.tempfile = None |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
170 self.bundlefile = open(bundlename, "rb") |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
171 header = self.bundlefile.read(6) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
172 if not header.startswith("HG"): |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
173 raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
174 elif not header.startswith("HG10"): |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
175 raise util.Abort(_("%s: unknown bundle version") % bundlename) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
176 elif header == "HG10BZ": |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
177 fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-", |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
178 suffix=".hg10un", dir=self.path) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
179 self.tempfile = temp |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
180 fptemp = os.fdopen(fdtemp, 'wb') |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
181 def generator(f): |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
182 zd = bz2.BZ2Decompressor() |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
183 zd.decompress("BZ") |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
184 for chunk in f: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
185 yield zd.decompress(chunk) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
186 gen = generator(util.filechunkiter(self.bundlefile, 4096)) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
187 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
188 try: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
189 fptemp.write("HG10UN") |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
190 for chunk in gen: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
191 fptemp.write(chunk) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
192 finally: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
193 fptemp.close() |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
194 self.bundlefile.close() |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
195 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
196 self.bundlefile = open(self.tempfile, "rb") |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
197 # seek right after the header |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
198 self.bundlefile.seek(6) |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
199 elif header == "HG10UN": |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
200 # nothing to do |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
201 pass |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
202 else: |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
203 raise util.Abort(_("%s: unknown bundle compression type") |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
204 % bundlename) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
205 # dict with the mapping 'filename' -> position in the bundle |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
206 self.bundlefilespos = {} |
5262 | 207 |
208 def __getattr__(self, name): | |
209 if name == 'changelog': | |
210 self.changelog = bundlechangelog(self.sopener, self.bundlefile) | |
5263
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
211 self.manstart = self.bundlefile.tell() |
5262 | 212 return self.changelog |
213 if name == 'manifest': | |
5263
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
214 self.bundlefile.seek(self.manstart) |
5262 | 215 self.manifest = bundlemanifest(self.sopener, self.bundlefile, |
216 self.changelog.rev) | |
217 self.filestart = self.bundlefile.tell() | |
218 return self.manifest | |
5263
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
219 if name == 'manstart': |
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
220 self.changelog |
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
221 return self.manstart |
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
222 if name == 'filestart': |
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
223 self.manifest |
8040f2e4cad0
bundle: fix up lazy reads
Brendan Cully <brendan@kublai.com>
parents:
5262
diff
changeset
|
224 return self.filestart |
5262 | 225 return localrepo.localrepository.__getattr__(self, name) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
226 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
227 def url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
228 return self._url |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
229 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
230 def file(self, f): |
5262 | 231 if not self.bundlefilespos: |
232 self.bundlefile.seek(self.filestart) | |
233 while 1: | |
234 chunk = changegroup.getchunk(self.bundlefile) | |
235 if not chunk: | |
236 break | |
237 self.bundlefilespos[chunk] = self.bundlefile.tell() | |
238 for c in changegroup.chunkiter(self.bundlefile): | |
239 pass | |
240 | |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
241 if f[0] == '/': |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
242 f = f[1:] |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
243 if f in self.bundlefilespos: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
244 self.bundlefile.seek(self.bundlefilespos[f]) |
3791
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3787
diff
changeset
|
245 return bundlefilelog(self.sopener, f, self.bundlefile, |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
246 self.changelog.rev) |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
247 else: |
3791
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3787
diff
changeset
|
248 return filelog.filelog(self.sopener, f) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
249 |
1971
915b81a35e46
imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1946
diff
changeset
|
250 def close(self): |
915b81a35e46
imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1946
diff
changeset
|
251 """Close assigned bundle file immediately.""" |
915b81a35e46
imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1946
diff
changeset
|
252 self.bundlefile.close() |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
253 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
254 def __del__(self): |
3429
b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2740
diff
changeset
|
255 bundlefile = getattr(self, 'bundlefile', None) |
b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2740
diff
changeset
|
256 if bundlefile and not bundlefile.closed: |
b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2740
diff
changeset
|
257 bundlefile.close() |
b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2740
diff
changeset
|
258 tempfile = getattr(self, 'tempfile', None) |
b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2740
diff
changeset
|
259 if tempfile is not None: |
b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2740
diff
changeset
|
260 os.unlink(tempfile) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
261 if self._tempparent: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
262 shutil.rmtree(self._tempparent, True) |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
263 |
6315 | 264 def cancopy(self): |
265 return False | |
266 | |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
267 def instance(ui, path, create): |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
268 if create: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
269 raise util.Abort(_('cannot create new bundle repository')) |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
270 parentpath = ui.config("bundle", "mainreporoot", "") |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
271 if parentpath: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
272 # Try to make the full path relative so we get a nice, short URL. |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
273 # In particular, we don't want temp dir names in test outputs. |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
274 cwd = os.getcwd() |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
275 if parentpath == cwd: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
276 parentpath = '' |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
277 else: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
278 cwd = os.path.join(cwd,'') |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
279 if parentpath.startswith(cwd): |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
280 parentpath = parentpath[len(cwd):] |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
281 path = util.drop_scheme('file', path) |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
282 if path.startswith('bundle:'): |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
283 path = util.drop_scheme('bundle', path) |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
284 s = path.split("+", 1) |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
285 if len(s) == 1: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
286 repopath, bundlename = parentpath, s[0] |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
287 else: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
288 repopath, bundlename = s |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
289 else: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
290 repopath, bundlename = parentpath, path |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
291 return bundlerepository(ui, repopath, bundlename) |