Mercurial > hg
annotate mercurial/bundlerepo.py @ 17241:c2f13180001f stable
histedit: end folding message with an LF
This is convenient when running tests dumping the editor content, it
avoids the following output line to be mixed with histedit message.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Wed, 25 Jul 2012 11:09:51 +0200 |
parents | 1d710fe5ee0e |
children | 03e552aaae67 8ab0640c3090 |
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 _ |
14158 | 16 import os, tempfile, shutil |
16042
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
17 import changegroup, util, mdiff, discovery, cmdutil |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
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): |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
21 def __init__(self, opener, indexfile, bundle, 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
|
22 # 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
|
23 # 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
|
24 # 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
|
25 # |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
26 # 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
|
27 # 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
|
28 # 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
|
29 # (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
|
30 # |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
31 revlog.revlog.__init__(self, opener, indexfile) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
32 self.bundle = bundle |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
33 self.basemap = {} |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6647
diff
changeset
|
34 n = len(self) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
35 chain = None |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14412
diff
changeset
|
36 while True: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
37 chunkdata = bundle.deltachunk(chain) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
38 if not chunkdata: |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
39 break |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
40 node = chunkdata['node'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
41 p1 = chunkdata['p1'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
42 p2 = chunkdata['p2'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
43 cs = chunkdata['cs'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
44 deltabase = chunkdata['deltabase'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
45 delta = chunkdata['delta'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
46 |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
47 size = len(delta) |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
48 start = bundle.tell() - size |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
49 |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
50 link = linkmapper(cs) |
1942
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: |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
52 # this can happen if two branches make the same change |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
53 chain = 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
|
54 continue |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
55 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
56 for p in (p1, p2): |
16686
67964cda8701
cleanup: "not x in y" -> "x not in y"
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
57 if p not in self.nodemap: |
9650
1ad02c04356c
bundlerepo: fix small bug in exception raising
Sune Foldager <cryo@cyanite.org>
parents:
9198
diff
changeset
|
58 raise error.LookupError(p, self.indexfile, |
7633 | 59 _("unknown parent")) |
5167
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
60 # start, size, full unc. size, base (unused), link, p1, p2, node |
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
61 e = (revlog.offset_type(start, 0), size, -1, -1, link, |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
62 self.rev(p1), self.rev(p2), node) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
63 self.basemap[n] = deltabase |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
64 self.index.insert(-1, e) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
65 self.nodemap[node] = n |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
66 chain = 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
|
67 n += 1 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
68 |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
69 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
|
70 """is rev from the bundle""" |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
71 if rev < 0: |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
72 return False |
2074
01ee43dda681
Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents:
1981
diff
changeset
|
73 return rev in self.basemap |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
74 def bundlebase(self, rev): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
75 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
|
76 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
|
77 # 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
|
78 # 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
|
79 # XXX: could use some caching |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
80 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
|
81 return revlog.revlog._chunk(self, rev) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
82 self.bundle.seek(self.start(rev)) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
83 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
|
84 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
85 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
|
86 """return or calculate a delta between two revisions""" |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
87 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
|
88 # 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
|
89 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
|
90 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
|
91 return self._chunk(rev2) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
92 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
|
93 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
|
94 |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
95 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
|
96 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
|
97 |
16375
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
98 def revision(self, nodeorrev): |
16435
df347129305d
revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents:
16375
diff
changeset
|
99 """return an uncompressed revision of a given node or revision |
df347129305d
revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents:
16375
diff
changeset
|
100 number. |
df347129305d
revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents:
16375
diff
changeset
|
101 """ |
16375
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
102 if isinstance(nodeorrev, int): |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
103 rev = nodeorrev |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
104 node = self.node(rev) |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
105 else: |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
106 node = nodeorrev |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
107 rev = self.rev(node) |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
108 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
109 if node == nullid: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
110 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
|
111 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
112 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
|
113 chain = [] |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
114 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
|
115 # 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
|
116 while self.inbundle(rev): |
4984 | 117 if self._cache and self._cache[0] == iter_node: |
118 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
|
119 break |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 if text is None: |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
124 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
|
125 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
126 while chain: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
127 delta = self._chunk(chain.pop()) |
4989
1aaed3d69772
revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents:
4988
diff
changeset
|
128 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
|
129 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
130 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
|
131 if node != revlog.hash(text, p1, p2): |
7633 | 132 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
|
133 % (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
|
134 |
4984 | 135 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
|
136 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
|
137 |
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 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
|
139 raise NotImplementedError |
6647
602f7c1ab954
drop superfluous param from revlog.addgroup()
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6569
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
147 class bundlechangelog(bundlerevlog, changelog.changelog): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
148 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
|
149 changelog.changelog.__init__(self, opener) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
150 linkmapper = lambda x: x |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
151 bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
152 linkmapper) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
153 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
154 class bundlemanifest(bundlerevlog, manifest.manifest): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
155 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
|
156 manifest.manifest.__init__(self, opener) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
157 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
|
158 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
|
159 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
160 class bundlefilelog(bundlerevlog, filelog.filelog): |
14287
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
161 def __init__(self, opener, path, bundle, linkmapper, repo): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
162 filelog.filelog.__init__(self, opener, path) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
163 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
|
164 linkmapper) |
14287
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
165 self._repo = repo |
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
166 |
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
167 def _file(self, f): |
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
168 self._repo.file(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
|
169 |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
170 class bundlepeer(localrepo.localpeer): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
171 def canpush(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
172 return False |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
173 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
174 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
|
175 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
|
176 self._tempparent = None |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
177 try: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
178 localrepo.localrepository.__init__(self, ui, path) |
7637 | 179 except error.RepoError: |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
180 self._tempparent = tempfile.mkdtemp() |
9198
061eeb602354
coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents:
8312
diff
changeset
|
181 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
|
182 localrepo.localrepository.__init__(self, ui, self._tempparent) |
16195
40cc20042fb4
bundlerepo: bundle repos should be non-publishing (issue3266)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16042
diff
changeset
|
183 self.ui.setconfig('phases', 'publish', False) |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
184 |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
185 if path: |
11154
17031fea4e95
expand paths to local repository or bundle in appropriate classes
Alexander Solovyov <piranha@piranha.org.ua>
parents:
10282
diff
changeset
|
186 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
|
187 else: |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
188 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
|
189 |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
190 self.tempfile = None |
13274
57d433f632b7
bundlerepo: use less intrusive util.posixfile to open bundle
Adrian Buehlmann <adrian@cadifra.com>
parents:
12962
diff
changeset
|
191 f = util.posixfile(bundlename, "rb") |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
192 self.bundle = changegroup.readbundle(f, bundlename) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
193 if self.bundle.compressed(): |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
194 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
|
195 suffix=".hg10un", dir=self.path) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
196 self.tempfile = temp |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
197 fptemp = os.fdopen(fdtemp, 'wb') |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
198 |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
199 try: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
200 fptemp.write("HG10UN") |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14412
diff
changeset
|
201 while True: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
202 chunk = self.bundle.read(2**18) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
203 if not chunk: |
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
204 break |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
205 fptemp.write(chunk) |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
206 finally: |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
207 fptemp.close() |
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
208 |
13274
57d433f632b7
bundlerepo: use less intrusive util.posixfile to open bundle
Adrian Buehlmann <adrian@cadifra.com>
parents:
12962
diff
changeset
|
209 f = util.posixfile(self.tempfile, "rb") |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
210 self.bundle = changegroup.readbundle(f, bundlename) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
211 |
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): |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
217 # consume the header if it exists |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
218 self.bundle.changelogheader() |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
219 c = bundlechangelog(self.sopener, self.bundle) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
220 self.manstart = self.bundle.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
221 return c |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
222 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
223 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
224 def manifest(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
225 self.bundle.seek(self.manstart) |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
226 # consume the header if it exists |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
227 self.bundle.manifestheader() |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
228 m = bundlemanifest(self.sopener, self.bundle, self.changelog.rev) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
229 self.filestart = self.bundle.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
230 return m |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
231 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
232 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
233 def manstart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
234 self.changelog |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
235 return self.manstart |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
236 |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
237 @util.propertycache |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
238 def filestart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
239 self.manifest |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
240 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
|
241 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
242 def url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
243 return self._url |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
244 |
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 def file(self, f): |
5262 | 246 if not self.bundlefilespos: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
247 self.bundle.seek(self.filestart) |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14412
diff
changeset
|
248 while True: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
249 chunkdata = self.bundle.filelogheader() |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
250 if not chunkdata: |
5262 | 251 break |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
252 fname = chunkdata['filename'] |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
253 self.bundlefilespos[fname] = self.bundle.tell() |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14412
diff
changeset
|
254 while True: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
255 c = self.bundle.deltachunk(None) |
12335
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
256 if not c: |
e21fe9c5fb25
bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
257 break |
5262 | 258 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
259 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
|
260 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
|
261 if f in self.bundlefilespos: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
262 self.bundle.seek(self.bundlefilespos[f]) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
263 return bundlefilelog(self.sopener, f, self.bundle, |
14287
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
264 self.changelog.rev, 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
|
265 else: |
3791
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3787
diff
changeset
|
266 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
|
267 |
12347
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
268 def close(self): |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
269 """Close assigned bundle file immediately.""" |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
270 self.bundle.close() |
12962
ff083040a555
bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents:
12961
diff
changeset
|
271 if self.tempfile is not None: |
ff083040a555
bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents:
12961
diff
changeset
|
272 os.unlink(self.tempfile) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
273 if self._tempparent: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
274 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
|
275 |
6315 | 276 def cancopy(self): |
277 return False | |
278 | |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
279 def peer(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
280 return bundlepeer(self) |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
281 |
7435
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
282 def getcwd(self): |
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
283 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
|
284 |
15597
bc0778f5619a
bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents:
15091
diff
changeset
|
285 def _writebranchcache(self, branches, tip, tiprev): |
bc0778f5619a
bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents:
15091
diff
changeset
|
286 # don't overwrite the disk cache with bundle-augmented data |
bc0778f5619a
bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents:
15091
diff
changeset
|
287 pass |
bc0778f5619a
bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents:
15091
diff
changeset
|
288 |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 parentpath = ui.config("bundle", "mainreporoot", "") |
16042
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
293 if not parentpath: |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
294 # try to find the correct path to the working directory repo |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
295 parentpath = cmdutil.findrepo(os.getcwd()) |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
296 if parentpath is None: |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
297 parentpath = '' |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
298 if parentpath: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
299 # 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
|
300 # 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
|
301 cwd = os.getcwd() |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
302 if parentpath == cwd: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
303 parentpath = '' |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
304 else: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
305 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
|
306 if parentpath.startswith(cwd): |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
307 parentpath = parentpath[len(cwd):] |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
308 u = util.url(path) |
13826
e574207e3bcd
url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents:
13742
diff
changeset
|
309 path = u.localpath() |
e574207e3bcd
url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents:
13742
diff
changeset
|
310 if u.scheme == 'bundle': |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
311 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
|
312 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
|
313 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
|
314 else: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
315 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
|
316 else: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
317 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
|
318 return bundlerepository(ui, repopath, bundlename) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
319 |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
320 def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None, |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14004
diff
changeset
|
321 force=False): |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
322 '''obtains a bundle of changes incoming from other |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
323 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
324 "onlyheads" restricts the returned changes to those reachable from the |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
325 specified heads. |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
326 "bundlename", if given, stores the bundle to this file path permanently; |
14190
8aab5a82685f
bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14161
diff
changeset
|
327 otherwise it's stored to a temp file and gets deleted again when you call |
8aab5a82685f
bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14161
diff
changeset
|
328 the returned "cleanupfn". |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
329 "force" indicates whether to proceed on unrelated repos. |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
330 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
331 Returns a tuple (local, csets, cleanupfn): |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
332 |
16683 | 333 "local" is a local repo from which to obtain the actual incoming |
334 changesets; it is a bundlerepo for the obtained bundle when the | |
335 original "other" is remote. | |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
336 "csets" lists the incoming changeset node ids. |
16683 | 337 "cleanupfn" must be called without arguments when you're done processing |
338 the changes; it closes both the original "other" and the one returned | |
339 here. | |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
340 ''' |
16683 | 341 tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, |
342 force=force) | |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
343 common, incoming, rheads = tmp |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
344 if not incoming: |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
345 try: |
15091
106f89299da6
bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents:
14494
diff
changeset
|
346 if bundlename: |
106f89299da6
bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents:
14494
diff
changeset
|
347 os.unlink(bundlename) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
13826
diff
changeset
|
348 except OSError: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
349 pass |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
350 return other, [], other.close |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
351 |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
352 bundle = None |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
353 bundlerepo = None |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
354 localrepo = other.local() |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
355 if bundlename or not localrepo: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
356 # create a bundle (uncompressed if other repo is not local) |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
357 |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14004
diff
changeset
|
358 if other.capable('getbundle'): |
14412
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
359 cg = other.getbundle('incoming', common=common, heads=rheads) |
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
360 elif onlyheads is None and not other.capable('changegroupsubset'): |
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
361 # compat with older servers when pulling all remote heads |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
362 cg = other.changegroup(incoming, "incoming") |
14412
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
363 rheads = None |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
364 else: |
14412
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
365 cg = other.changegroupsubset(incoming, rheads, 'incoming') |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
366 bundletype = localrepo and "HG10BZ" or "HG10UN" |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
367 fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
368 # keep written bundle? |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
369 if bundlename: |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
370 bundle = None |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
371 if not localrepo: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
372 # use the created uncompressed bundlerepo |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
373 localrepo = bundlerepo = bundlerepository(ui, repo.root, fname) |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
374 # this repo contains local and other now, so filter out local again |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
375 common = repo.heads() |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
376 |
14412
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
377 csets = localrepo.changelog.findmissing(common, rheads) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
378 |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
379 def cleanup(): |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
380 if bundlerepo: |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
381 bundlerepo.close() |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
382 if bundle: |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
383 os.unlink(bundle) |
14190
8aab5a82685f
bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14161
diff
changeset
|
384 other.close() |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
385 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
386 return (localrepo, csets, cleanup) |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
387 |