Mercurial > hg
annotate mercurial/bundlerepo.py @ 11916:d1ea16ca6520
tests: unify test-subrepo-svn
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Tue, 17 Aug 2010 16:53:03 +0200 |
parents | 17031fea4e95 |
children | bcc7139521b7 |
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 _ |
8312
b87a50b7125c
separate import lines from mercurial and general python modules
Simon Heimberg <simohe@besonet.ch>
parents:
8260
diff
changeset
|
16 import os, struct, bz2, zlib, tempfile, shutil |
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): |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
21 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
|
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 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
25 # 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
|
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) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
33 self.bundlefile = bundlefile |
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(): |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 if size < 80: |
6953
63b5f4c73c98
i18n: mark strings for translation in Mercurial
Martin Geisler <mg@daimi.au.dk>
parents:
6750
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 continue |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
51 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
|
52 if not p in self.nodemap: |
9650
1ad02c04356c
bundlerepo: fix small bug in exception raising
Sune Foldager <cryo@cyanite.org>
parents:
9198
diff
changeset
|
53 raise error.LookupError(p, self.indexfile, |
7633 | 54 _("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
|
55 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
|
56 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
|
57 else: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
58 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
|
59 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
60 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
|
61 prev = p1 |
5167
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
62 # 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
|
63 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
|
64 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
|
65 self.basemap[n] = prev |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 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
|
70 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
71 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
|
72 """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
|
73 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
|
74 return False |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
75 return rev in self.basemap |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
76 def bundlebase(self, rev): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
77 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
|
78 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
|
79 # 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
|
80 # 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
|
81 # 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
|
82 if not self.bundle(rev): |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
83 return revlog.revlog._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
|
84 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
|
85 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
|
86 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
87 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
|
88 """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
|
89 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
|
90 # 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
|
91 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
|
92 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
|
93 return self._chunk(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
|
94 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
|
95 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
|
96 |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
97 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
|
98 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
|
99 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
100 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
|
101 """return an uncompressed revision of a given""" |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
102 if node == nullid: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
103 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
|
104 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
105 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
|
106 chain = [] |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
107 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
|
108 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
|
109 # 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
|
110 while self.bundle(rev): |
4984 | 111 if self._cache and self._cache[0] == iter_node: |
112 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
|
113 break |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 if text is None: |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
118 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
|
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 while chain: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
121 delta = self._chunk(chain.pop()) |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
122 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
|
123 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
124 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
|
125 if node != revlog.hash(text, p1, p2): |
7633 | 126 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
|
127 % (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
|
128 |
4984 | 129 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
|
130 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
|
131 |
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 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
|
133 raise NotImplementedError |
6647
602f7c1ab954
drop superfluous param from revlog.addgroup()
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6569
diff
changeset
|
134 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
|
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 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
|
137 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
|
138 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
|
139 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
|
140 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
141 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
|
142 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
|
143 changelog.changelog.__init__(self, opener) |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
144 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
|
145 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
146 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
|
147 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
|
148 manifest.manifest.__init__(self, opener) |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
149 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
|
150 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
|
151 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
158 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
|
159 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
|
160 self._tempparent = None |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
161 try: |
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, path) |
7637 | 163 except error.RepoError: |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
164 self._tempparent = tempfile.mkdtemp() |
9198
061eeb602354
coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents:
8312
diff
changeset
|
165 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
|
166 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
|
167 |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
168 if path: |
11154
17031fea4e95
expand paths to local repository or bundle in appropriate classes
Alexander Solovyov <piranha@piranha.org.ua>
parents:
10282
diff
changeset
|
169 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
|
170 else: |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
171 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
|
172 |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
173 self.tempfile = None |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
174 self.bundlefile = open(bundlename, "rb") |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
175 header = self.bundlefile.read(6) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
176 if not header.startswith("HG"): |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
177 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
|
178 elif not header.startswith("HG10"): |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
179 raise util.Abort(_("%s: unknown bundle version") % bundlename) |
6569
c15bfe9cdcd6
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
Benoit Allard <benoit@aeteurope.nl>
parents:
6315
diff
changeset
|
180 elif (header == "HG10BZ") or (header == "HG10GZ"): |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
181 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
|
182 suffix=".hg10un", dir=self.path) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
183 self.tempfile = temp |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
184 fptemp = os.fdopen(fdtemp, 'wb') |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
185 def generator(f): |
6569
c15bfe9cdcd6
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
Benoit Allard <benoit@aeteurope.nl>
parents:
6315
diff
changeset
|
186 if header == "HG10BZ": |
c15bfe9cdcd6
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
Benoit Allard <benoit@aeteurope.nl>
parents:
6315
diff
changeset
|
187 zd = bz2.BZ2Decompressor() |
c15bfe9cdcd6
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
Benoit Allard <benoit@aeteurope.nl>
parents:
6315
diff
changeset
|
188 zd.decompress("BZ") |
c15bfe9cdcd6
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
Benoit Allard <benoit@aeteurope.nl>
parents:
6315
diff
changeset
|
189 elif header == "HG10GZ": |
c15bfe9cdcd6
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
Benoit Allard <benoit@aeteurope.nl>
parents:
6315
diff
changeset
|
190 zd = zlib.decompressobj() |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
191 for chunk in f: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
192 yield zd.decompress(chunk) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
193 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
|
194 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
195 try: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
196 fptemp.write("HG10UN") |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
197 for chunk in gen: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
198 fptemp.write(chunk) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
199 finally: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
200 fptemp.close() |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
201 self.bundlefile.close() |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
202 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
203 self.bundlefile = open(self.tempfile, "rb") |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
204 # seek right after the header |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
205 self.bundlefile.seek(6) |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
206 elif header == "HG10UN": |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
207 # nothing to do |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
208 pass |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
209 else: |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1971
diff
changeset
|
210 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
|
211 % 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
|
212 # 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
|
213 self.bundlefilespos = {} |
5262 | 214 |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
215 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
216 def changelog(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
217 c = bundlechangelog(self.sopener, self.bundlefile) |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
218 self.manstart = self.bundlefile.tell() |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
219 return c |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
220 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
221 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
222 def manifest(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
223 self.bundlefile.seek(self.manstart) |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
224 m = bundlemanifest(self.sopener, self.bundlefile, self.changelog.rev) |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
225 self.filestart = self.bundlefile.tell() |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
226 return m |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
227 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
228 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
229 def manstart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
230 self.changelog |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
231 return self.manstart |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
232 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
233 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
234 def filestart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
235 self.manifest |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
236 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
|
237 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
238 def url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
239 return self._url |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
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 def file(self, f): |
5262 | 242 if not self.bundlefilespos: |
243 self.bundlefile.seek(self.filestart) | |
244 while 1: | |
245 chunk = changegroup.getchunk(self.bundlefile) | |
246 if not chunk: | |
247 break | |
248 self.bundlefilespos[chunk] = self.bundlefile.tell() | |
249 for c in changegroup.chunkiter(self.bundlefile): | |
250 pass | |
251 | |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 else: |
3791
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3787
diff
changeset
|
259 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
|
260 |
1971
915b81a35e46
imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1946
diff
changeset
|
261 def close(self): |
915b81a35e46
imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1946
diff
changeset
|
262 """Close assigned bundle file immediately.""" |
915b81a35e46
imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1946
diff
changeset
|
263 self.bundlefile.close() |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
264 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 os.unlink(tempfile) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
272 if self._tempparent: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
273 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
|
274 |
6315 | 275 def cancopy(self): |
276 return False | |
277 | |
7435
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
278 def getcwd(self): |
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
279 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
|
280 |
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 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
|
282 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
|
283 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
|
284 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
|
285 if parentpath: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
286 # 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
|
287 # 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
|
288 cwd = os.getcwd() |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
289 if parentpath == cwd: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
290 parentpath = '' |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
291 else: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
292 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
|
293 if parentpath.startswith(cwd): |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 else: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
302 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
|
303 else: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
304 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
|
305 return bundlerepository(ui, repopath, bundlename) |