mercurial/bundlerepo.py
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 06 Feb 2013 07:55:29 +0000
branchstable
changeset 18568 cd403d6d96ef
parent 18418 e72126135252
child 18643 cc28a84db8c9
permissions -rw-r--r--
incoming: fix incoming when a local head is remotely filtered (issue3805) In its current state discovery may return (remotely) filtered elements in "common". This has usually no impact as "missing" is kept clear of filtered elements. However when the "remote" repo is a local repo (disk accessible, and directly created in memory) the incoming code takes a shortcut and directly uses the "remote" repo to generate the incoming output. When some common elements are filtered this led to a crash. We now ensure we use an unfiltered repository to generate the incoming output. This does not change the behavior as missing is clear of filtered revision. Now that we have proper low level filtering, incoming code needs a deeper cleanup but it is already planned.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9676
diff changeset
     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
6b4127c7d52a Simplify i18n imports
Matt Mackall <mpm@selenic.com>
parents: 3877
diff changeset
    15
from i18n import _
14158
d8ba6fb2ce15 bundlerepo: drop struct
Matt Mackall <mpm@selenic.com>
parents: 14144
diff changeset
    16
import os, tempfile, shutil
18215
5e851ca54189 bundlerepo: enforce reading from core repo only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18142
diff changeset
    17
import changegroup, util, mdiff, discovery, cmdutil, scmutil
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:
18410
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    23
        # To retrieve a revision, we need to know the offset of the revision in
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    24
        # the bundle (an unbundle object). We store this offset in the index
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    25
        # (start).
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    26
        #
18410
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    27
        # basemap is indexed with revisions coming from the bundle, and it
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    28
        # maps to the revision that is the base of the corresponding 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
    29
        #
18410
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    30
        # To differentiate a rev in the bundle from a rev in the revlog, we
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    31
        # check revision against basemap.
18215
5e851ca54189 bundlerepo: enforce reading from core repo only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18142
diff changeset
    32
        opener = scmutil.readonlyvfs(opener)
4257
1b5c38e9d7aa revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents: 4029
diff changeset
    33
        revlog.revlog.__init__(self, opener, indexfile)
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
    34
        self.bundle = bundle
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    35
        self.basemap = {} # mapping rev to delta base rev
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6647
diff changeset
    36
        n = len(self)
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    37
        chain = None
18411
8b0f0dd56cec bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents: 18410
diff changeset
    38
        self.bundlerevs = set() # used by 'bundle()' revset expression
14494
1ffeeb91c55d check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents: 14412
diff changeset
    39
        while True:
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
    40
            chunkdata = bundle.deltachunk(chain)
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    41
            if not chunkdata:
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    42
                break
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    43
            node = chunkdata['node']
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    44
            p1 = chunkdata['p1']
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    45
            p2 = chunkdata['p2']
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    46
            cs = chunkdata['cs']
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    47
            deltabase = chunkdata['deltabase']
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    48
            delta = chunkdata['delta']
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
            size = len(delta)
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    51
            start = bundle.tell() - size
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    52
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    53
            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
    54
            if node in self.nodemap:
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    55
                # 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
    56
                chain = node
18411
8b0f0dd56cec bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents: 18410
diff changeset
    57
                self.bundlerevs.add(self.nodemap[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
    58
                continue
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    59
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    60
            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
    61
                if p not in self.nodemap:
9650
1ad02c04356c bundlerepo: fix small bug in exception raising
Sune Foldager <cryo@cyanite.org>
parents: 9198
diff changeset
    62
                    raise error.LookupError(p, self.indexfile,
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7435
diff changeset
    63
                                            _("unknown parent"))
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    64
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    65
            if deltabase not in self.nodemap:
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    66
                raise LookupError(deltabase, self.indexfile,
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    67
                                  _('unknown delta base'))
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    68
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    69
            baserev = self.rev(deltabase)
5167
aba624d2301d fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4989
diff changeset
    70
            # 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
    71
            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
    72
                 self.rev(p1), self.rev(p2), node)
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    73
            self.basemap[n] = baserev
4979
06abdaf78788 revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents: 4918
diff changeset
    74
            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
    75
            self.nodemap[node] = n
18411
8b0f0dd56cec bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents: 18410
diff changeset
    76
            self.bundlerevs.add(n)
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    77
            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
    78
            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
    79
9676
48bf28d3c8dd bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9650
diff changeset
    80
    def _chunk(self, rev):
18413
0ccb16f5956a bundlerepo: drop bundlebase wrapper function for basemap
Mads Kiilerich <madski@unity3d.com>
parents: 18412
diff changeset
    81
        # Warning: in case of bundle, the diff is against self.basemap,
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    82
        # 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
    83
        # XXX: could use some caching
18414
c448562ad85b bundlerepo: inline inbundle()
Mads Kiilerich <madski@unity3d.com>
parents: 18413
diff changeset
    84
        if rev not in self.basemap:
9676
48bf28d3c8dd bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9650
diff changeset
    85
            return revlog.revlog._chunk(self, rev)
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
    86
        self.bundle.seek(self.start(rev))
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
    87
        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
    88
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    89
    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
    90
        """return or calculate a delta between two revisions"""
18414
c448562ad85b bundlerepo: inline inbundle()
Mads Kiilerich <madski@unity3d.com>
parents: 18413
diff changeset
    91
        if rev1 in self.basemap and rev2 in self.basemap:
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    92
            # hot path for bundle
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    93
            revb = self.basemap[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
            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
    95
                return self._chunk(rev2)
18414
c448562ad85b bundlerepo: inline inbundle()
Mads Kiilerich <madski@unity3d.com>
parents: 18413
diff changeset
    96
        elif rev1 not in self.basemap and rev2 not in self.basemap:
4028
540d1059c802 bundlerepo: it was meant to be revdiff() instead of chunk()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3791
diff changeset
    97
            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
    98
4989
1aaed3d69772 revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents: 4988
diff changeset
    99
        return mdiff.textdiff(self.revision(self.node(rev1)),
18413
0ccb16f5956a bundlerepo: drop bundlebase wrapper function for basemap
Mads Kiilerich <madski@unity3d.com>
parents: 18412
diff changeset
   100
                              self.revision(self.node(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
   101
16375
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   102
    def revision(self, nodeorrev):
16435
df347129305d revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents: 16375
diff changeset
   103
        """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
   104
        number.
df347129305d revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents: 16375
diff changeset
   105
        """
16375
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   106
        if isinstance(nodeorrev, int):
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   107
            rev = nodeorrev
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   108
            node = self.node(rev)
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   109
        else:
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   110
            node = nodeorrev
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   111
            rev = self.rev(node)
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   112
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
   113
        if node == nullid:
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
   114
            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
   115
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   116
        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
   117
        chain = []
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   118
        iterrev = 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
   119
        # reconstruct the revision if it is from a changegroup
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   120
        while iterrev in self.basemap:
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   121
            if self._cache and self._cache[1] == iterrev:
4984
b4066fcbd6ba revlog: mark cache private
Matt Mackall <mpm@selenic.com>
parents: 4979
diff changeset
   122
                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
   123
                break
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   124
            chain.append(iterrev)
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
   125
            iterrev = self.basemap[iterrev]
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   126
        if text is None:
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   127
            text = revlog.revlog.revision(self, iterrev)
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
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   129
        while chain:
9676
48bf28d3c8dd bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9650
diff changeset
   130
            delta = self._chunk(chain.pop())
4989
1aaed3d69772 revlog: eliminate diff and patches functions
Matt Mackall <mpm@selenic.com>
parents: 4988
diff changeset
   131
            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
   132
18417
610706715778 bundlerepo: use revlog._checkhash
Mads Kiilerich <madski@unity3d.com>
parents: 18416
diff changeset
   133
        self._checkhash(text, node, rev)
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   134
        self._cache = (node, rev, 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
   135
        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
   136
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   137
    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
   138
        raise NotImplementedError
6647
602f7c1ab954 drop superfluous param from revlog.addgroup()
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 6569
diff changeset
   139
    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
   140
        raise NotImplementedError
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   141
    def 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
   142
        raise NotImplementedError
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   143
    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
   144
        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
   145
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   146
class bundlechangelog(bundlerevlog, changelog.changelog):
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   147
    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
   148
        changelog.changelog.__init__(self, opener)
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
   149
        linkmapper = lambda x: x
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
   150
        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
   151
                              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
   152
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   153
class bundlemanifest(bundlerevlog, manifest.manifest):
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   154
    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
   155
        manifest.manifest.__init__(self, opener)
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   156
        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
   157
                              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
   158
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   159
class bundlefilelog(bundlerevlog, filelog.filelog):
14287
7c231754a621 filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents: 14190
diff changeset
   160
    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
   161
        filelog.filelog.__init__(self, opener, path)
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   162
        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
   163
                              linkmapper)
14287
7c231754a621 filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents: 14190
diff changeset
   164
        self._repo = repo
7c231754a621 filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents: 14190
diff changeset
   165
7c231754a621 filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents: 14190
diff changeset
   166
    def _file(self, f):
7c231754a621 filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents: 14190
diff changeset
   167
        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
   168
17193
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   169
class bundlepeer(localrepo.localpeer):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   170
    def canpush(self):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   171
        return False
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   172
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   173
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
   174
    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
   175
        self._tempparent = None
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   176
        try:
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   177
            localrepo.localrepository.__init__(self, ui, path)
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
   178
        except error.RepoError:
6314
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   179
            self._tempparent = tempfile.mkdtemp()
9198
061eeb602354 coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents: 8312
diff changeset
   180
            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
   181
            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
   182
        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
   183
6129
3d666e8e6398 bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5664
diff changeset
   184
        if path:
11154
17031fea4e95 expand paths to local repository or bundle in appropriate classes
Alexander Solovyov <piranha@piranha.org.ua>
parents: 10282
diff changeset
   185
            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
   186
        else:
3d666e8e6398 bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5664
diff changeset
   187
            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
   188
2273
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   189
        self.tempfile = None
13274
57d433f632b7 bundlerepo: use less intrusive util.posixfile to open bundle
Adrian Buehlmann <adrian@cadifra.com>
parents: 12962
diff changeset
   190
        f = util.posixfile(bundlename, "rb")
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   191
        self.bundle = changegroup.readbundle(f, bundlename)
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   192
        if self.bundle.compressed():
2273
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   193
            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
   194
                                            suffix=".hg10un", dir=self.path)
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   195
            self.tempfile = temp
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   196
            fptemp = os.fdopen(fdtemp, 'wb')
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   197
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   198
            try:
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   199
                fptemp.write("HG10UN")
14494
1ffeeb91c55d check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents: 14412
diff changeset
   200
                while True:
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   201
                    chunk = self.bundle.read(2**18)
12044
bcc7139521b7 bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents: 11154
diff changeset
   202
                    if not chunk:
bcc7139521b7 bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents: 11154
diff changeset
   203
                        break
2273
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   204
                    fptemp.write(chunk)
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   205
            finally:
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   206
                fptemp.close()
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   207
13274
57d433f632b7 bundlerepo: use less intrusive util.posixfile to open bundle
Adrian Buehlmann <adrian@cadifra.com>
parents: 12962
diff changeset
   208
            f = util.posixfile(self.tempfile, "rb")
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   209
            self.bundle = changegroup.readbundle(f, bundlename)
12044
bcc7139521b7 bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents: 11154
diff changeset
   210
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   211
        # 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
   212
        self.bundlefilespos = {}
5262
a35756389ef4 Make bundlerepo lazier
Brendan Cully <brendan@kublai.com>
parents: 5167
diff changeset
   213
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   214
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   215
    def changelog(self):
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   216
        # consume the header if it exists
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   217
        self.bundle.changelogheader()
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   218
        c = bundlechangelog(self.sopener, self.bundle)
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   219
        self.manstart = self.bundle.tell()
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   220
        return c
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   221
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   222
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   223
    def manifest(self):
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   224
        self.bundle.seek(self.manstart)
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   225
        # consume the header if it exists
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   226
        self.bundle.manifestheader()
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   227
        m = bundlemanifest(self.sopener, self.bundle, self.changelog.rev)
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   228
        self.filestart = self.bundle.tell()
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   229
        return m
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   230
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   231
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   232
    def manstart(self):
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   233
        self.changelog
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   234
        return self.manstart
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   235
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   236
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   237
    def filestart(self):
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   238
        self.manifest
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   239
        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
   240
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   241
    def url(self):
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   242
        return self._url
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   243
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   244
    def file(self, f):
5262
a35756389ef4 Make bundlerepo lazier
Brendan Cully <brendan@kublai.com>
parents: 5167
diff changeset
   245
        if not self.bundlefilespos:
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   246
            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
   247
            while True:
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   248
                chunkdata = self.bundle.filelogheader()
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   249
                if not chunkdata:
5262
a35756389ef4 Make bundlerepo lazier
Brendan Cully <brendan@kublai.com>
parents: 5167
diff changeset
   250
                    break
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   251
                fname = chunkdata['filename']
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   252
                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
   253
                while True:
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   254
                    c = self.bundle.deltachunk(None)
12335
e21fe9c5fb25 bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents: 12333
diff changeset
   255
                    if not c:
e21fe9c5fb25 bundle: get rid of chunkiter
Matt Mackall <mpm@selenic.com>
parents: 12333
diff changeset
   256
                        break
5262
a35756389ef4 Make bundlerepo lazier
Brendan Cully <brendan@kublai.com>
parents: 5167
diff changeset
   257
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   258
        if f in self.bundlefilespos:
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   259
            self.bundle.seek(self.bundlefilespos[f])
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
   260
            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
   261
                                 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
   262
        else:
3791
8643b9f90b51 introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3787
diff changeset
   263
            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
   264
12347
6277a9469dff bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents: 12335
diff changeset
   265
    def close(self):
6277a9469dff bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents: 12335
diff changeset
   266
        """Close assigned bundle file immediately."""
6277a9469dff bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents: 12335
diff changeset
   267
        self.bundle.close()
12962
ff083040a555 bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents: 12961
diff changeset
   268
        if self.tempfile is not None:
ff083040a555 bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents: 12961
diff changeset
   269
            os.unlink(self.tempfile)
6314
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   270
        if self._tempparent:
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   271
            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
   272
6315
5c96a4bca66b clone: use cancopy
Matt Mackall <mpm@selenic.com>
parents: 6314
diff changeset
   273
    def cancopy(self):
5c96a4bca66b clone: use cancopy
Matt Mackall <mpm@selenic.com>
parents: 6314
diff changeset
   274
        return False
5c96a4bca66b clone: use cancopy
Matt Mackall <mpm@selenic.com>
parents: 6314
diff changeset
   275
17193
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   276
    def peer(self):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   277
        return bundlepeer(self)
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   278
7435
5e13df32fb74 bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6953
diff changeset
   279
    def getcwd(self):
5e13df32fb74 bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6953
diff changeset
   280
        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
   281
15597
bc0778f5619a bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents: 15091
diff changeset
   282
2740
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
   283
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
   284
    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
   285
        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
   286
    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
   287
    if not parentpath:
4b7aa1c899dc bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents: 15597
diff changeset
   288
        # 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
   289
        parentpath = cmdutil.findrepo(os.getcwd())
4b7aa1c899dc bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents: 15597
diff changeset
   290
        if parentpath is None:
4b7aa1c899dc bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents: 15597
diff changeset
   291
            parentpath = ''
5664
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   292
    if parentpath:
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   293
        # 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
   294
        # 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
   295
        cwd = os.getcwd()
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   296
        if parentpath == cwd:
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   297
            parentpath = ''
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   298
        else:
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   299
            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
   300
            if parentpath.startswith(cwd):
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   301
                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
   302
    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
   303
    path = u.localpath()
e574207e3bcd url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents: 13742
diff changeset
   304
    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
   305
        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
   306
        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
   307
            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
   308
        else:
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
   309
            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
   310
    else:
5664
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   311
        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
   312
    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
   313
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   314
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
   315
                     force=False):
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   316
    '''obtains a bundle of changes incoming from other
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   317
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   318
    "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
   319
      specified heads.
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   320
    "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
   321
      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
   322
      the returned "cleanupfn".
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   323
    "force" indicates whether to proceed on unrelated repos.
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   324
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   325
    Returns a tuple (local, csets, cleanupfn):
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   326
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   327
    "local" is a local repo from which to obtain the actual incoming
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   328
      changesets; it is a bundlerepo for the obtained bundle when the
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   329
      original "other" is remote.
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   330
    "csets" lists the incoming changeset node ids.
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   331
    "cleanupfn" must be called without arguments when you're done processing
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   332
      the changes; it closes both the original "other" and the one returned
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   333
      here.
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   334
    '''
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   335
    tmp = discovery.findcommonincoming(repo, other, heads=onlyheads,
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   336
                                       force=force)
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   337
    common, incoming, rheads = tmp
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   338
    if not incoming:
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   339
        try:
15091
106f89299da6 bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents: 14494
diff changeset
   340
            if bundlename:
106f89299da6 bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents: 14494
diff changeset
   341
                os.unlink(bundlename)
14004
97ed99d1f419 eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents: 13826
diff changeset
   342
        except OSError:
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   343
            pass
18138
8ab0640c3090 bundlerepo: don't return the peer without bundlerepo from getremotechanges
Mads Kiilerich <madski@unity3d.com>
parents: 17193
diff changeset
   344
        return repo, [], other.close
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   345
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   346
    bundle = None
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   347
    bundlerepo = None
17191
5884812686f7 peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents: 16686
diff changeset
   348
    localrepo = other.local()
5884812686f7 peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents: 16686
diff changeset
   349
    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
   350
        # 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
   351
14073
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14004
diff changeset
   352
        if other.capable('getbundle'):
14412
9ac479758d3b bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14287
diff changeset
   353
            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
   354
        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
   355
            # 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
   356
            cg = other.changegroup(incoming, "incoming")
14412
9ac479758d3b bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14287
diff changeset
   357
            rheads = None
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   358
        else:
14412
9ac479758d3b bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14287
diff changeset
   359
            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
   360
        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
   361
        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
   362
        # keep written bundle?
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   363
        if bundlename:
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   364
            bundle = None
17191
5884812686f7 peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents: 16686
diff changeset
   365
        if not localrepo:
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   366
            # use the created uncompressed bundlerepo
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   367
            localrepo = bundlerepo = bundlerepository(ui, repo.root, fname)
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   368
            # 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
   369
            common = repo.heads()
18568
cd403d6d96ef incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18418
diff changeset
   370
    if localrepo:
cd403d6d96ef incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18418
diff changeset
   371
        # Part of common may be remotely filtered
cd403d6d96ef incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18418
diff changeset
   372
        # So use an unfiltered version
cd403d6d96ef incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18418
diff changeset
   373
        # The discovery process probably need cleanup to avoid that
cd403d6d96ef incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18418
diff changeset
   374
        localrepo = localrepo.unfiltered()
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   375
14412
9ac479758d3b bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14287
diff changeset
   376
    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
   377
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   378
    def cleanup():
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   379
        if bundlerepo:
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   380
            bundlerepo.close()
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   381
        if bundle:
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   382
            os.unlink(bundle)
14190
8aab5a82685f bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14161
diff changeset
   383
        other.close()
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   384
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   385
    return (localrepo, csets, cleanup)