Mercurial > hg-stable
annotate mercurial/bundlerepo.py @ 12347:6277a9469dff
bundlerepo: restore close() method
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 20 Sep 2010 16:14:05 -0500 |
parents | e21fe9c5fb25 |
children | 5dfd1c49dcc5 |
rev | line source |
---|---|
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
1 # bundlerepo.py - repository class for viewing uncompressed bundles |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
2 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
3 # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
4 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
7 |
8227
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
8 """Repository class for viewing uncompressed bundles. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
9 |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
10 This provides a read-only repository interface to bundles as if they |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
11 were part of the actual repository. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
12 """ |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
13 |
7873
4a4c7f6a5912
cleanup: drop unused imports
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7853
diff
changeset
|
14 from node import nullid |
3891 | 15 from i18n import _ |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
16 import os, struct, tempfile, shutil |
8312
b87a50b7125c
separate import lines from mercurial and general python modules
Simon Heimberg <simohe@besonet.ch>
parents:
8260
diff
changeset
|
17 import changegroup, util, mdiff |
7873
4a4c7f6a5912
cleanup: drop unused imports
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7853
diff
changeset
|
18 import localrepo, changelog, manifest, filelog, revlog, error |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
19 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
20 class bundlerevlog(revlog.revlog): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
21 def __init__(self, opener, indexfile, bundle, |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
22 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
|
23 # 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
|
24 # to retrieve a revision, we need to know the offset of |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
25 # the revision in the bundle (an unbundle object). |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
26 # |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
27 # 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
|
28 # 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
|
29 # 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
|
30 # (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
|
31 # |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
32 revlog.revlog.__init__(self, opener, indexfile) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
33 self.bundle = bundle |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
34 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
|
35 def chunkpositer(): |
12335
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
36 while 1: |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
37 chunk = bundle.chunk() |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
38 if not chunk: |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
39 break |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
40 pos = bundle.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
|
41 yield chunk, pos - len(chunk) |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6647
diff
changeset
|
42 n = len(self) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 if size < 80: |
6953
63b5f4c73c98
i18n: mark strings for translation in Mercurial
Martin Geisler <mg@daimi.au.dk>
parents:
6750
diff
changeset
|
47 raise util.Abort(_("invalid changegroup")) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 continue |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
54 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
|
55 if not p in self.nodemap: |
9650
1ad02c04356c
bundlerepo: fix small bug in exception raising
Sune Foldager <cryo@cyanite.org>
parents:
9198
diff
changeset
|
56 raise error.LookupError(p, self.indexfile, |
7633 | 57 _("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
|
58 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
|
59 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
|
60 else: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
61 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
|
62 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
63 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
|
64 prev = p1 |
5167
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
65 # 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
|
66 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
|
67 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
|
68 self.basemap[n] = prev |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 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
|
73 |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
74 def inbundle(self, rev): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
75 """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
|
76 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
|
77 return False |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
78 return rev in self.basemap |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
79 def bundlebase(self, rev): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
80 return self.basemap[rev] |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
81 def _chunk(self, rev): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
82 # 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
|
83 # 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
|
84 # XXX: could use some caching |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
85 if not self.inbundle(rev): |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
86 return revlog.revlog._chunk(self, rev) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
87 self.bundle.seek(self.start(rev)) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
88 return self.bundle.read(self.length(rev)) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
89 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
90 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
|
91 """return or calculate a delta between two revisions""" |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
92 if self.inbundle(rev1) and self.inbundle(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 # 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
|
94 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
|
95 if revb == rev1: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
96 return self._chunk(rev2) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
97 elif not self.inbundle(rev1) and not self.inbundle(rev2): |
4028
540d1059c802
bundlerepo: it was meant to be revdiff() instead of chunk()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3791
diff
changeset
|
98 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
|
99 |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
100 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
|
101 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
|
102 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
103 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
|
104 """return an uncompressed revision of a given""" |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
105 if node == nullid: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
106 return "" |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
107 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
108 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
|
109 chain = [] |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
110 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
|
111 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
|
112 # reconstruct the revision if it is from a changegroup |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
113 while self.inbundle(rev): |
4984 | 114 if self._cache and self._cache[0] == iter_node: |
115 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
|
116 break |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 if text is None: |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
121 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
|
122 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
123 while chain: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
124 delta = self._chunk(chain.pop()) |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
125 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
|
126 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
127 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
|
128 if node != revlog.hash(text, p1, p2): |
7633 | 129 raise error.RevlogError(_("integrity check failed on %s:%d") |
2257
8dafccbcede9
indent: fix alignment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2256
diff
changeset
|
130 % (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
|
131 |
4984 | 132 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
|
133 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
|
134 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
135 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
|
136 raise NotImplementedError |
6647
602f7c1ab954
drop superfluous param from revlog.addgroup()
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6569
diff
changeset
|
137 def addgroup(self, revs, linkmapper, transaction): |
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 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
144 class bundlechangelog(bundlerevlog, changelog.changelog): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
145 def __init__(self, opener, bundle): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
146 changelog.changelog.__init__(self, opener) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
147 bundlerevlog.__init__(self, opener, self.indexfile, bundle) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
148 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
149 class bundlemanifest(bundlerevlog, manifest.manifest): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
150 def __init__(self, opener, bundle, linkmapper): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
151 manifest.manifest.__init__(self, opener) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
152 bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
153 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
|
154 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
155 class bundlefilelog(bundlerevlog, filelog.filelog): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
156 def __init__(self, opener, path, bundle, linkmapper): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
157 filelog.filelog.__init__(self, opener, path) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
158 bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
159 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
|
160 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
161 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
|
162 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
|
163 self._tempparent = None |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
164 try: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
165 localrepo.localrepository.__init__(self, ui, path) |
7637 | 166 except error.RepoError: |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
167 self._tempparent = tempfile.mkdtemp() |
9198
061eeb602354
coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents:
8312
diff
changeset
|
168 localrepo.instance(ui, self._tempparent, 1) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
169 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
|
170 |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
171 if path: |
11154
17031fea4e95
expand paths to local repository or bundle in appropriate classes
Alexander Solovyov <piranha@piranha.org.ua>
parents:
10282
diff
changeset
|
172 self._url = 'bundle:' + util.expandpath(path) + '+' + bundlename |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
173 else: |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
174 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
|
175 |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
176 self.tempfile = None |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
177 f = open(bundlename, "rb") |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
178 self.bundle = changegroup.readbundle(f, bundlename) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
179 if self.bundle.compressed(): |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
180 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
|
181 suffix=".hg10un", dir=self.path) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
182 self.tempfile = temp |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
183 fptemp = os.fdopen(fdtemp, 'wb') |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
184 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
185 try: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
186 fptemp.write("HG10UN") |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
187 while 1: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
188 chunk = self.bundle.read(2**18) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
189 if not chunk: |
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
190 break |
2273
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 |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
195 f = open(self.tempfile, "rb") |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
196 self.bundle = changegroup.readbundle(f, bundlename) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
197 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
198 # 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
|
199 self.bundlefilespos = {} |
5262 | 200 |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
201 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
202 def changelog(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
203 c = bundlechangelog(self.sopener, self.bundle) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
204 self.manstart = self.bundle.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
205 return c |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
206 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
207 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
208 def manifest(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
209 self.bundle.seek(self.manstart) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
210 m = bundlemanifest(self.sopener, self.bundle, self.changelog.rev) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
211 self.filestart = self.bundle.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
212 return m |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
213 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
214 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
215 def manstart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
216 self.changelog |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
217 return self.manstart |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
218 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
219 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
220 def filestart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
221 self.manifest |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
222 return self.filestart |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
223 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
224 def url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
225 return self._url |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
226 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
227 def file(self, f): |
5262 | 228 if not self.bundlefilespos: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
229 self.bundle.seek(self.filestart) |
5262 | 230 while 1: |
12333
44c7dfc2f6a3
bundle: make getchunk() a method
Matt Mackall <mpm@selenic.com>
parents:
12332
diff
changeset
|
231 chunk = self.bundle.chunk() |
5262 | 232 if not chunk: |
233 break | |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
234 self.bundlefilespos[chunk] = self.bundle.tell() |
12335
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
235 while 1: |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
236 c = self.bundle.chunk() |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
237 if not c: |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
238 break |
5262 | 239 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
240 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
|
241 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
|
242 if f in self.bundlefilespos: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
243 self.bundle.seek(self.bundlefilespos[f]) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
244 return bundlefilelog(self.sopener, f, self.bundle, |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
245 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
|
246 else: |
3791
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3787
diff
changeset
|
247 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
|
248 |
12347
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
249 def close(self): |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
250 """Close assigned bundle file immediately.""" |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
251 self.bundle.close() |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
252 |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
253 def __del__(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
254 del self.bundle |
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 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
|
256 os.unlink(tempfile) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
257 if self._tempparent: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
258 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
|
259 |
6315 | 260 def cancopy(self): |
261 return False | |
262 | |
7435
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
263 def getcwd(self): |
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
264 return os.getcwd() # always outside the repo |
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
265 |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
266 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
|
267 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
|
268 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
|
269 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
|
270 if parentpath: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
271 # 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
|
272 # 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
|
273 cwd = os.getcwd() |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
274 if parentpath == cwd: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
275 parentpath = '' |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
276 else: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
277 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
|
278 if parentpath.startswith(cwd): |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 else: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
287 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
|
288 else: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
289 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
|
290 return bundlerepository(ui, repopath, bundlename) |