mercurial/bundlerepo.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Fri, 30 Aug 2019 18:12:16 +0200
changeset 42833 5ba8c328a895
parent 42832 0f5652f17325
child 43076 2372284d9457
permissions -rw-r--r--
bundlerepo: drop the custom `rawdata` implementation We can rely on the main one now.
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
25920
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    14
from __future__ import absolute_import
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    15
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    16
import os
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    17
import shutil
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    18
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    19
from .i18n import _
42831
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
    20
from .node import (
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
    21
    nullid,
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
    22
    nullrev
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
    23
)
25920
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    24
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    25
from . import (
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    26
    bundle2,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    27
    changegroup,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    28
    changelog,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    29
    cmdutil,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    30
    discovery,
39823
24e493ec2229 py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 39779
diff changeset
    31
    encoding,
25920
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    32
    error,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    33
    exchange,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    34
    filelog,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    35
    localrepo,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    36
    manifest,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    37
    mdiff,
28714
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
    38
    node as nodemod,
25920
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    39
    pathutil,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    40
    phases,
30528
20a42325fdef py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30385
diff changeset
    41
    pycompat,
25920
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    42
    revlog,
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    43
    util,
31250
5f68e7341ada vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30944
diff changeset
    44
    vfs as vfsmod,
25920
5aaf51c14fea bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25830
diff changeset
    45
)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    46
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
    47
class bundlerevlog(revlog.revlog):
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
    48
    def __init__(self, opener, indexfile, cgunpacker, 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
    49
        # How it works:
18410
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    50
        # 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
    51
        # the bundle (an unbundle object). We store this offset in the index
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
    52
        # (start). The base of the delta is stored in the base field.
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    53
        #
18410
de7dac2a58e8 bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents: 18216
diff changeset
    54
        # To differentiate a rev in the bundle from a rev in the revlog, we
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
    55
        # check revision against repotiprev.
31250
5f68e7341ada vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30944
diff changeset
    56
        opener = vfsmod.readonlyvfs(opener)
4257
1b5c38e9d7aa revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents: 4029
diff changeset
    57
        revlog.revlog.__init__(self, opener, indexfile)
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
    58
        self.bundle = cgunpacker
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6647
diff changeset
    59
        n = len(self)
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
    60
        self.repotiprev = n - 1
18411
8b0f0dd56cec bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents: 18410
diff changeset
    61
        self.bundlerevs = set() # used by 'bundle()' revset expression
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
    62
        for deltadata in cgunpacker.deltaiter():
34300
0fe62d8bdd50 bundlerepo: update to use new deltaiter api
Durham Goode <durham@fb.com>
parents: 34226
diff changeset
    63
            node, p1, p2, cs, deltabase, delta, flags = deltadata
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    64
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    65
            size = len(delta)
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
    66
            start = cgunpacker.tell() - size
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    67
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    68
            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
    69
            if node in self.nodemap:
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    70
                # this can happen if two branches make the same change
18411
8b0f0dd56cec bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents: 18410
diff changeset
    71
                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
    72
                continue
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
    73
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    74
            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
    75
                if p not in self.nodemap:
9650
1ad02c04356c bundlerepo: fix small bug in exception raising
Sune Foldager <cryo@cyanite.org>
parents: 9198
diff changeset
    76
                    raise error.LookupError(p, self.indexfile,
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7435
diff changeset
    77
                                            _("unknown parent"))
18416
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    78
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    79
            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
    80
                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
    81
                                  _('unknown delta base'))
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    82
87f370c5fef5 bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents: 18415
diff changeset
    83
            baserev = self.rev(deltabase)
5167
aba624d2301d fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4989
diff changeset
    84
            # start, size, full unc. size, base (unused), link, p1, p2, node
31835
4bafc80f827e bundlerepo: build revlog index with flags
Jun Wu <quark@fb.com>
parents: 31834
diff changeset
    85
            e = (revlog.offset_type(start, flags), size, -1, baserev, link,
4979
06abdaf78788 revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents: 4918
diff changeset
    86
                 self.rev(p1), self.rev(p2), node)
38889
6104b203bec8 index: replace insert(-1, e) method by append(e) method
Martin von Zweigbergk <martinvonz@google.com>
parents: 38198
diff changeset
    87
            self.index.append(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
    88
            self.nodemap[node] = n
18411
8b0f0dd56cec bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents: 18410
diff changeset
    89
            self.bundlerevs.add(n)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    90
            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
    91
35070
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
    92
    def _chunk(self, rev, df=None):
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
    93
        # Warning: in case of bundle, the diff is against what we stored as
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
    94
        # delta base, not against rev - 1
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    95
        # XXX: could use some caching
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
    96
        if rev <= self.repotiprev:
9676
48bf28d3c8dd bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9650
diff changeset
    97
            return revlog.revlog._chunk(self, rev)
12332
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
    98
        self.bundle.seek(self.start(rev))
680fe77ab5b8 bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents: 12331
diff changeset
    99
        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
   100
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   101
    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
   102
        """return or calculate a delta between two revisions"""
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
   103
        if rev1 > self.repotiprev and rev2 > self.repotiprev:
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   104
            # hot path for bundle
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
   105
            revb = self.index[rev2][3]
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   106
            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
   107
                return self._chunk(rev2)
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
   108
        elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
4028
540d1059c802 bundlerepo: it was meant to be revdiff() instead of chunk()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3791
diff changeset
   109
            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
   110
42786
af9c591216ea rawdata: update callers in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42738
diff changeset
   111
        return mdiff.textdiff(self.rawdata(rev1),
af9c591216ea rawdata: update callers in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42738
diff changeset
   112
                              self.rawdata(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
   113
42831
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   114
    def _rawtext(self, node, rev, _df=None):
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   115
        if rev is None:
16375
d7d64b89a65c revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents: 16195
diff changeset
   116
            rev = self.rev(node)
42831
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   117
        validated = False
31836
4598e8f43e20 bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents: 31835
diff changeset
   118
        rawtext = None
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
        chain = []
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   120
        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
   121
        # reconstruct the revision if it is from a changegroup
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
   122
        while iterrev > self.repotiprev:
40053
55db747a21ad revlog: rename _cache to _revisioncache
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39945
diff changeset
   123
            if self._revisioncache and self._revisioncache[1] == iterrev:
55db747a21ad revlog: rename _cache to _revisioncache
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39945
diff changeset
   124
                rawtext = self._revisioncache[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
   125
                break
18415
95b8629fd2de bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents: 18414
diff changeset
   126
            chain.append(iterrev)
18643
cc28a84db8c9 bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents: 18568
diff changeset
   127
            iterrev = self.index[iterrev][3]
42831
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   128
        if iterrev == nullrev:
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   129
            rawtext = ''
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   130
        elif rawtext is None:
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   131
            r = super(bundlerevlog, self)._rawtext(self.node(iterrev),
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   132
                                                   iterrev,
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   133
                                                   _df=_df)
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   134
            __, rawtext, validated = r
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   135
        if chain:
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   136
            validated = False
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   137
        while chain:
9676
48bf28d3c8dd bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9650
diff changeset
   138
            delta = self._chunk(chain.pop())
31836
4598e8f43e20 bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents: 31835
diff changeset
   139
            rawtext = mdiff.patches(rawtext, [delta])
42831
c070ca6ed86d bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42786
diff changeset
   140
        return rev, rawtext, validated
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
35070
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   142
    def addrevision(self, *args, **kwargs):
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   143
        raise NotImplementedError
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   144
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   145
    def addgroup(self, *args, **kwargs):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   146
        raise NotImplementedError
35070
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   147
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   148
    def strip(self, *args, **kwargs):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   149
        raise NotImplementedError
35070
32d079f37207 bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35050
diff changeset
   150
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   151
    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
   152
        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
   153
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   154
class bundlechangelog(bundlerevlog, changelog.changelog):
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   155
    def __init__(self, opener, cgunpacker):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   156
        changelog.changelog.__init__(self, opener)
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
   157
        linkmapper = lambda x: x
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   158
        bundlerevlog.__init__(self, opener, self.indexfile, cgunpacker,
14142
cb91ea6af733 bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14076
diff changeset
   159
                              linkmapper)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   160
30383
31de088945cd manifest: add bundlemanifestlog support
Durham Goode <durham@fb.com>
parents: 30218
diff changeset
   161
class bundlemanifest(bundlerevlog, manifest.manifestrevlog):
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   162
    def __init__(self, opener, cgunpacker, linkmapper, dirlogstarts=None,
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   163
                 dir=''):
39271
0d97530eb535 manifest: rename dir argument and attribute to tree
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38889
diff changeset
   164
        manifest.manifestrevlog.__init__(self, opener, tree=dir)
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   165
        bundlerevlog.__init__(self, opener, self.indexfile, cgunpacker,
4257
1b5c38e9d7aa revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents: 4029
diff changeset
   166
                              linkmapper)
29728
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   167
        if dirlogstarts is None:
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   168
            dirlogstarts = {}
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   169
            if self.bundle.version == "03":
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   170
                dirlogstarts = _getfilestarts(self.bundle)
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   171
        self._dirlogstarts = dirlogstarts
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   172
        self._linkmapper = 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
   173
29728
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   174
    def dirlog(self, d):
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   175
        if d in self._dirlogstarts:
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   176
            self.bundle.seek(self._dirlogstarts[d])
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   177
            return bundlemanifest(
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   178
                self.opener, self.bundle, self._linkmapper,
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   179
                self._dirlogstarts, dir=d)
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   180
        return super(bundlemanifest, self).dirlog(d)
55d341877316 bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents: 29726
diff changeset
   181
37497
1541e1a8e87d filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37331
diff changeset
   182
class bundlefilelog(filelog.filelog):
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   183
    def __init__(self, opener, path, cgunpacker, linkmapper):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
   184
        filelog.filelog.__init__(self, opener, path)
37497
1541e1a8e87d filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37331
diff changeset
   185
        self._revlog = bundlerevlog(opener, self.indexfile,
1541e1a8e87d filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37331
diff changeset
   186
                                    cgunpacker, linkmapper)
14287
7c231754a621 filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents: 14190
diff changeset
   187
17193
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   188
class bundlepeer(localrepo.localpeer):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   189
    def canpush(self):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   190
        return False
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   191
23631
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   192
class bundlephasecache(phases.phasecache):
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   193
    def __init__(self, *args, **kwargs):
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   194
        super(bundlephasecache, self).__init__(*args, **kwargs)
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   195
        if util.safehasattr(self, 'opener'):
31250
5f68e7341ada vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30944
diff changeset
   196
            self.opener = vfsmod.readonlyvfs(self.opener)
23631
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   197
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   198
    def write(self):
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   199
        raise NotImplementedError
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   200
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   201
    def _write(self, fp):
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   202
        raise NotImplementedError
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   203
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   204
    def _updateroots(self, phase, newroots, tr):
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   205
        self.phaseroots[phase] = newroots
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   206
        self.invalidate()
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   207
        self.dirty = True
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   208
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   209
def _getfilestarts(cgunpacker):
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   210
    filespos = {}
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   211
    for chunkdata in iter(cgunpacker.filelogheader, {}):
29725
9e88077f972c bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents: 29724
diff changeset
   212
        fname = chunkdata['filename']
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   213
        filespos[fname] = cgunpacker.tell()
35099
90609be10891 bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35098
diff changeset
   214
        for chunk in iter(lambda: cgunpacker.deltachunk(None), {}):
29725
9e88077f972c bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents: 29724
diff changeset
   215
            pass
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   216
    return filespos
29725
9e88077f972c bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents: 29724
diff changeset
   217
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   218
class bundlerepository(object):
35073
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   219
    """A repository instance that is a union of a local repo and a bundle.
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   220
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   221
    Instances represent a read-only repository composed of a local repository
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   222
    with the contents of a bundle file applied. The repository instance is
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   223
    conceptually similar to the state of a repository after an
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   224
    ``hg unbundle`` operation. However, the contents of the bundle are never
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   225
    applied to the actual base repository.
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   226
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   227
    Instances constructed directly are not usable as repository objects.
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   228
    Use instance() or makebundlerepository() to create instances.
35073
d2458ba810c5 bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35072
diff changeset
   229
    """
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   230
    def __init__(self, bundlepath, url, tempparent):
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   231
        self._tempparent = tempparent
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   232
        self._url = url
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   233
20790
49f2d5644f04 config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents: 19629
diff changeset
   234
        self.ui.setconfig('phases', 'publish', False, 'bundlerepo')
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   235
2273
f116ddea537f add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2257
diff changeset
   236
        self.tempfile = None
35072
4696938d40f9 bundlerepo: rename arguments to bundlerepository.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35071
diff changeset
   237
        f = util.posixfile(bundlepath, "rb")
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   238
        bundle = exchange.readbundle(self.ui, f, bundlepath)
12044
bcc7139521b7 bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents: 11154
diff changeset
   239
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   240
        if isinstance(bundle, bundle2.unbundle20):
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   241
            self._bundlefile = bundle
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   242
            self._cgunpacker = None
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   243
35136
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   244
            cgpart = None
35137
da91e7309daf bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35136
diff changeset
   245
            for part in bundle.iterparts(seekable=True):
26803
ed41ce89822d bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26801
diff changeset
   246
                if part.type == 'changegroup':
35136
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   247
                    if cgpart:
26803
ed41ce89822d bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26801
diff changeset
   248
                        raise NotImplementedError("can't process "
ed41ce89822d bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26801
diff changeset
   249
                                                  "multiple changegroups")
35136
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   250
                    cgpart = part
24073
ff5caa8dfd99 bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents: 24072
diff changeset
   251
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   252
                self._handlebundle2part(bundle, part)
24073
ff5caa8dfd99 bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents: 24072
diff changeset
   253
35136
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   254
            if not cgpart:
33907
f672d060a931 bundlerepo: move bundle2 part handling out to a function
Durham Goode <durham@fb.com>
parents: 33906
diff changeset
   255
                raise error.Abort(_("No changegroups found"))
35136
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   256
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   257
            # This is required to placate a later consumer, which expects
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   258
            # the payload offset to be at the beginning of the changegroup.
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   259
            # We need to do this after the iterparts() generator advances
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   260
            # because iterparts() will seek to end of payload after the
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   261
            # generator returns control to iterparts().
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   262
            cgpart.seek(0, os.SEEK_SET)
2b72bc88043f bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35100
diff changeset
   263
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   264
        elif isinstance(bundle, changegroup.cg1unpacker):
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   265
            if bundle.compressed():
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   266
                f = self._writetempbundle(bundle.read, '.hg10un',
35074
4f04c9207a76 bundlerepo: don't assume there are only two bundle classes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35073
diff changeset
   267
                                          header='HG10UN')
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   268
                bundle = exchange.readbundle(self.ui, f, bundlepath, self.vfs)
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   269
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   270
            self._bundlefile = bundle
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   271
            self._cgunpacker = bundle
35074
4f04c9207a76 bundlerepo: don't assume there are only two bundle classes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35073
diff changeset
   272
        else:
4f04c9207a76 bundlerepo: don't assume there are only two bundle classes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35073
diff changeset
   273
            raise error.Abort(_('bundle type %s cannot be read') %
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   274
                              type(bundle))
26801
73bf76bf6f14 bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26800
diff changeset
   275
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   276
        # dict with the mapping 'filename' -> position in the changegroup.
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   277
        self._cgfilespos = {}
5262
a35756389ef4 Make bundlerepo lazier
Brendan Cully <brendan@kublai.com>
parents: 5167
diff changeset
   278
23632
e7fcf58acd71 bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents: 23631
diff changeset
   279
        self.firstnewrev = self.changelog.repotiprev + 1
e7fcf58acd71 bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents: 23631
diff changeset
   280
        phases.retractboundary(self, None, phases.draft,
e7fcf58acd71 bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents: 23631
diff changeset
   281
                               [ctx.node() for ctx in self[self.firstnewrev:]])
e7fcf58acd71 bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents: 23631
diff changeset
   282
35076
495fcff10124 bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35075
diff changeset
   283
    def _handlebundle2part(self, bundle, part):
35098
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   284
        if part.type != 'changegroup':
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   285
            return
33907
f672d060a931 bundlerepo: move bundle2 part handling out to a function
Durham Goode <durham@fb.com>
parents: 33906
diff changeset
   286
35098
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   287
        cgstream = part
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   288
        version = part.params.get('version', '01')
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   289
        legalcgvers = changegroup.supportedincomingversions(self)
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   290
        if version not in legalcgvers:
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   291
            msg = _('Unsupported changegroup version: %s')
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   292
            raise error.Abort(msg % version)
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   293
        if bundle.compressed():
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   294
            cgstream = self._writetempbundle(part.read, '.cg%sun' % version)
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   295
3eeb0a3eeaed bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35077
diff changeset
   296
        self._cgunpacker = changegroup.getunbundler(version, cgstream, 'UN')
33907
f672d060a931 bundlerepo: move bundle2 part handling out to a function
Durham Goode <durham@fb.com>
parents: 33906
diff changeset
   297
33905
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   298
    def _writetempbundle(self, readfn, suffix, header=''):
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   299
        """Write a temporary file to disk
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   300
        """
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   301
        fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
35071
80e9b85d96e5 bundlerepo: use suffix variable
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35070
diff changeset
   302
                                        suffix=suffix)
33905
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   303
        self.tempfile = temp
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   304
36843
5bc7ff103081 py3: use r'' instead of sysstr('') to get around code transformer
Yuya Nishihara <yuya@tcha.org>
parents: 35873
diff changeset
   305
        with os.fdopen(fdtemp, r'wb') as fptemp:
33905
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   306
            fptemp.write(header)
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   307
            while True:
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   308
                chunk = readfn(2**18)
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   309
                if not chunk:
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   310
                    break
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   311
                fptemp.write(chunk)
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   312
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   313
        return self.vfs.open(self.tempfile, mode="rb")
702a26fec3e2 bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents: 33184
diff changeset
   314
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   315
    @localrepo.unfilteredpropertycache
23631
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   316
    def _phasecache(self):
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   317
        return bundlephasecache(self, self._phasedefaults)
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   318
b8260abfeb7d bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents: 22182
diff changeset
   319
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   320
    def changelog(self):
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   321
        # consume the header if it exists
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   322
        self._cgunpacker.changelogheader()
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   323
        c = bundlechangelog(self.svfs, self._cgunpacker)
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   324
        self.manstart = self._cgunpacker.tell()
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   325
        return c
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   326
42182
3472a3f9d785 localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41041
diff changeset
   327
    def _refreshchangelog(self):
3472a3f9d785 localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41041
diff changeset
   328
        # changelog for bundle repo are not filecache, this method is not
3472a3f9d785 localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41041
diff changeset
   329
        # applicable.
3472a3f9d785 localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41041
diff changeset
   330
        pass
3472a3f9d785 localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41041
diff changeset
   331
39779
5ccd791344f3 localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39620
diff changeset
   332
    @localrepo.unfilteredpropertycache
5ccd791344f3 localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39620
diff changeset
   333
    def manifestlog(self):
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   334
        self._cgunpacker.seek(self.manstart)
14144
3c3c53d8343a unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 14142
diff changeset
   335
        # consume the header if it exists
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   336
        self._cgunpacker.manifestheader()
28221
7a8c44844f57 bundlerepo: properly handle hidden linkrev in manifestlog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28186
diff changeset
   337
        linkmapper = self.unfiltered().changelog.rev
39779
5ccd791344f3 localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39620
diff changeset
   338
        rootstore = bundlemanifest(self.svfs, self._cgunpacker, linkmapper)
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   339
        self.filestart = self._cgunpacker.tell()
39779
5ccd791344f3 localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39620
diff changeset
   340
41041
3913223417ea manifest: accept narrowmatch into constructor instead of getting from repo
Martin von Zweigbergk <martinvonz@google.com>
parents: 40053
diff changeset
   341
        return manifest.manifestlog(self.svfs, self, rootstore,
3913223417ea manifest: accept narrowmatch into constructor instead of getting from repo
Martin von Zweigbergk <martinvonz@google.com>
parents: 40053
diff changeset
   342
                                    self.narrowmatch())
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   343
35050
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   344
    def _consumemanifest(self):
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   345
        """Consumes the manifest portion of the bundle, setting filestart so the
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   346
        file portion can be read."""
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   347
        self._cgunpacker.seek(self.manstart)
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   348
        self._cgunpacker.manifestheader()
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   349
        for delta in self._cgunpacker.deltaiter():
35050
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   350
            pass
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   351
        self.filestart = self._cgunpacker.tell()
35050
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   352
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   353
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   354
    def manstart(self):
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   355
        self.changelog
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   356
        return self.manstart
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   357
18014
a39fe76c4c65 clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17913
diff changeset
   358
    @localrepo.unfilteredpropertycache
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   359
    def filestart(self):
30385
11b8b740d54a manifest: remove last uses of repo.manifest
Durham Goode <durham@fb.com>
parents: 30383
diff changeset
   360
        self.manifestlog
35050
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   361
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   362
        # If filestart was not set by self.manifestlog, that means the
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   363
        # manifestlog implementation did not consume the manifests from the
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   364
        # changegroup (ex: it might be consuming trees from a separate bundle2
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   365
        # part instead). So we need to manually consume it.
35873
87b085a4f9d1 bundlerepo: use native str when peeking in __dict__
Augie Fackler <augie@google.com>
parents: 35783
diff changeset
   366
        if r'filestart' not in self.__dict__:
35050
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   367
            self._consumemanifest()
a2dfc723b6b5 bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents: 34300
diff changeset
   368
8260
54a4b520bd7d localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   369
        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
   370
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   371
    def url(self):
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   372
        return self._url
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2273
diff changeset
   373
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
   374
    def file(self, f):
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   375
        if not self._cgfilespos:
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   376
            self._cgunpacker.seek(self.filestart)
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   377
            self._cgfilespos = _getfilestarts(self._cgunpacker)
5262
a35756389ef4 Make bundlerepo lazier
Brendan Cully <brendan@kublai.com>
parents: 5167
diff changeset
   378
35100
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   379
        if f in self._cgfilespos:
cd4cd7b94ff1 bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35099
diff changeset
   380
            self._cgunpacker.seek(self._cgfilespos[f])
28186
5ab6f0fde75f bundlerepo: properly handle hidden linkrev in filelog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27953
diff changeset
   381
            linkmapper = self.unfiltered().changelog.rev
35077
3f393e4593f2 bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35076
diff changeset
   382
            return bundlefilelog(self.svfs, f, self._cgunpacker, 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
   383
        else:
37331
c68262401c8c bundlerepo: use super() when calling file()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36843
diff changeset
   384
            return super(bundlerepository, self).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
   385
12347
6277a9469dff bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents: 12335
diff changeset
   386
    def close(self):
6277a9469dff bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents: 12335
diff changeset
   387
        """Close assigned bundle file immediately."""
35075
df2a676a2e9e bundlerepo: make bundle and bundlefile attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35074
diff changeset
   388
        self._bundlefile.close()
12962
ff083040a555 bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents: 12961
diff changeset
   389
        if self.tempfile is not None:
20981
4fdd1172d37e bundlerepo: treat temporarily extracted bundle file via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20790
diff changeset
   390
            self.vfs.unlink(self.tempfile)
6314
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   391
        if self._tempparent:
9a1c59283ad3 Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 6312
diff changeset
   392
            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
   393
6315
5c96a4bca66b clone: use cancopy
Matt Mackall <mpm@selenic.com>
parents: 6314
diff changeset
   394
    def cancopy(self):
5c96a4bca66b clone: use cancopy
Matt Mackall <mpm@selenic.com>
parents: 6314
diff changeset
   395
        return False
5c96a4bca66b clone: use cancopy
Matt Mackall <mpm@selenic.com>
parents: 6314
diff changeset
   396
17193
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   397
    def peer(self):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   398
        return bundlepeer(self)
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17191
diff changeset
   399
7435
5e13df32fb74 bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6953
diff changeset
   400
    def getcwd(self):
39823
24e493ec2229 py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 39779
diff changeset
   401
        return encoding.getcwd() # always outside the repo
7435
5e13df32fb74 bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6953
diff changeset
   402
28714
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   403
    # Check if parents exist in localrepo before setting
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   404
    def setparents(self, p1, p2=nullid):
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   405
        p1rev = self.changelog.rev(p1)
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   406
        p2rev = self.changelog.rev(p2)
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   407
        msg = _("setting parent to node %s that only exists in the bundle\n")
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   408
        if self.changelog.repotiprev < p1rev:
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   409
            self.ui.warn(msg % nodemod.hex(p1))
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   410
        if self.changelog.repotiprev < p2rev:
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   411
            self.ui.warn(msg % nodemod.hex(p2))
dac81729fea4 bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents: 28666
diff changeset
   412
        return super(bundlerepository, self).setparents(p1, p2)
15597
bc0778f5619a bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents: 15091
diff changeset
   413
39565
089fc0db0954 hg: allow extra arguments to be passed to repo creation (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39271
diff changeset
   414
def instance(ui, path, create, intents=None, createopts=None):
2740
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
   415
    if create:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26544
diff changeset
   416
        raise error.Abort(_('cannot create new bundle repository'))
25830
5418dd5be8ac bundlerepo: mark internal-only config variable
Matt Mackall <mpm@selenic.com>
parents: 24921
diff changeset
   417
    # internal config: bundle.mainreporoot
33184
634997248c97 configitems: register the 'bundle.mainreporoot' config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 31837
diff changeset
   418
    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
   419
    if not parentpath:
4b7aa1c899dc bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents: 15597
diff changeset
   420
        # try to find the correct path to the working directory repo
39823
24e493ec2229 py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 39779
diff changeset
   421
        parentpath = cmdutil.findrepo(encoding.getcwd())
16042
4b7aa1c899dc bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents: 15597
diff changeset
   422
        if parentpath is None:
4b7aa1c899dc bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents: 15597
diff changeset
   423
            parentpath = ''
5664
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   424
    if parentpath:
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   425
        # 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
   426
        # In particular, we don't want temp dir names in test outputs.
39823
24e493ec2229 py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 39779
diff changeset
   427
        cwd = encoding.getcwd()
5664
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   428
        if parentpath == cwd:
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   429
            parentpath = ''
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   430
        else:
24834
6e31e1274080 bundlerepo: use pathutil.normasprefix to ensure os.sep at the end of cwd
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 24686
diff changeset
   431
            cwd = pathutil.normasprefix(cwd)
5664
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   432
            if parentpath.startswith(cwd):
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   433
                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
   434
    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
   435
    path = u.localpath()
e574207e3bcd url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents: 13742
diff changeset
   436
    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
   437
        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
   438
        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
   439
            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
   440
        else:
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
   441
            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
   442
    else:
5664
da72b4d24797 Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5558
diff changeset
   443
        repopath, bundlename = parentpath, path
39619
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   444
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   445
    return makebundlerepository(ui, repopath, bundlename)
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   446
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   447
def makebundlerepository(ui, repopath, bundlepath):
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   448
    """Make a bundle repository object based on repo and bundle paths."""
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   449
    if repopath:
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   450
        url = 'bundle:%s+%s' % (util.expandpath(repopath), bundlepath)
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   451
    else:
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   452
        url = 'bundle:%s' % bundlepath
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   453
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   454
    # Because we can't make any guarantees about the type of the base
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   455
    # repository, we can't have a static class representing the bundle
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   456
    # repository. We also can't make any guarantees about how to even
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   457
    # call the base repository's constructor!
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   458
    #
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   459
    # So, our strategy is to go through ``localrepo.instance()`` to construct
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   460
    # a repo instance. Then, we dynamically create a new type derived from
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   461
    # both it and our ``bundlerepository`` class which overrides some
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   462
    # functionality. We then change the type of the constructed repository
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   463
    # to this new type and initialize the bundle-specific bits of it.
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   464
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   465
    try:
39945
75b53b809e87 bundlerepo: remove a variable alias
Martin von Zweigbergk <martinvonz@google.com>
parents: 39823
diff changeset
   466
        repo = localrepo.instance(ui, repopath, create=False)
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   467
        tempparent = None
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   468
    except error.RepoError:
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   469
        tempparent = pycompat.mkdtemp()
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   470
        try:
39945
75b53b809e87 bundlerepo: remove a variable alias
Martin von Zweigbergk <martinvonz@google.com>
parents: 39823
diff changeset
   471
            repo = localrepo.instance(ui, tempparent, create=True)
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   472
        except Exception:
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   473
            shutil.rmtree(tempparent)
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   474
            raise
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   475
39945
75b53b809e87 bundlerepo: remove a variable alias
Martin von Zweigbergk <martinvonz@google.com>
parents: 39823
diff changeset
   476
    class derivedbundlerepository(bundlerepository, repo.__class__):
39620
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   477
        pass
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   478
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   479
    repo.__class__ = derivedbundlerepository
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   480
    bundlerepository.__init__(repo, bundlepath, url, tempparent)
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   481
335ae4d0a552 bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39619
diff changeset
   482
    return repo
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   483
23633
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   484
class bundletransactionmanager(object):
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   485
    def transaction(self):
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   486
        return None
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   487
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   488
    def close(self):
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   489
        raise NotImplementedError
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   490
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   491
    def release(self):
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   492
        raise NotImplementedError
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   493
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   494
def getremotechanges(ui, repo, peer, onlyheads=None, bundlename=None,
14073
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14004
diff changeset
   495
                     force=False):
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   496
    '''obtains a bundle of changes incoming from peer
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   497
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   498
    "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
   499
      specified heads.
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   500
    "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
   501
      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
   502
      the returned "cleanupfn".
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   503
    "force" indicates whether to proceed on unrelated repos.
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   504
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   505
    Returns a tuple (local, csets, cleanupfn):
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   506
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   507
    "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
   508
      changesets; it is a bundlerepo for the obtained bundle when the
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   509
      original "peer" is remote.
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   510
    "csets" lists the incoming changeset node ids.
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   511
    "cleanupfn" must be called without arguments when you're done processing
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   512
      the changes; it closes both the original "peer" and the one returned
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   513
      here.
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   514
    '''
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   515
    tmp = discovery.findcommonincoming(repo, peer, heads=onlyheads,
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16435
diff changeset
   516
                                       force=force)
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   517
    common, incoming, rheads = tmp
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   518
    if not incoming:
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   519
        try:
15091
106f89299da6 bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents: 14494
diff changeset
   520
            if bundlename:
21694
c08a22bfa16e bundlerepo: backout dbf292f65b09
Matt Mackall <mpm@selenic.com>
parents: 21562
diff changeset
   521
                os.unlink(bundlename)
14004
97ed99d1f419 eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents: 13826
diff changeset
   522
        except OSError:
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   523
            pass
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   524
        return repo, [], peer.close
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   525
22182
510cafe72004 incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents: 21694
diff changeset
   526
    commonset = set(common)
510cafe72004 incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents: 21694
diff changeset
   527
    rheads = [x for x in rheads if x not in commonset]
510cafe72004 incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents: 21694
diff changeset
   528
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   529
    bundle = None
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   530
    bundlerepo = None
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   531
    localrepo = peer.local()
17191
5884812686f7 peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents: 16686
diff changeset
   532
    if bundlename or not localrepo:
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   533
        # create a bundle (uncompressed if peer repo is not local)
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   534
29698
ff5d5751fc1b bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29389
diff changeset
   535
        # developer config: devel.legacy.exchange
ff5d5751fc1b bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29389
diff changeset
   536
        legexc = ui.configlist('devel', 'legacy.exchange')
29703
39537bc64442 bundle2: remove 'experimental.bundle2-exp' boolean config (BC)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29698
diff changeset
   537
        forcebundle1 = 'bundle2' not in legexc and 'bundle1' in legexc
29698
ff5d5751fc1b bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29389
diff changeset
   538
        canbundle2 = (not forcebundle1
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   539
                      and peer.capable('getbundle')
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   540
                      and peer.capable('bundle2'))
26544
1e8e0b01faba incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26543
diff changeset
   541
        if canbundle2:
37643
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   542
            with peer.commandexecutor() as e:
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   543
                b2 = e.callcommand('getbundle', {
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   544
                    'source': 'incoming',
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   545
                    'common': common,
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   546
                    'heads': rheads,
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   547
                    'bundlecaps': exchange.caps20to10(repo, role='client'),
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   548
                    'cg': True,
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   549
                }).result()
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   550
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   551
                fname = bundle = changegroup.writechunks(ui,
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   552
                                                         b2._forwardchunks(),
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   553
                                                         bundlename)
26544
1e8e0b01faba incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26543
diff changeset
   554
        else:
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   555
            if peer.capable('getbundle'):
37643
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   556
                with peer.commandexecutor() as e:
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   557
                    cg = e.callcommand('getbundle', {
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   558
                        'source': 'incoming',
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   559
                        'common': common,
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   560
                        'heads': rheads,
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   561
                    }).result()
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   562
            elif onlyheads is None and not peer.capable('changegroupsubset'):
26543
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   563
                # compat with older servers when pulling all remote heads
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   564
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   565
                with peer.commandexecutor() as e:
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   566
                    cg = e.callcommand('changegroup', {
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   567
                        'nodes': incoming,
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   568
                        'source': 'incoming',
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   569
                    }).result()
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   570
26543
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   571
                rheads = None
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   572
            else:
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   573
                with peer.commandexecutor() as e:
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   574
                    cg = e.callcommand('changegroupsubset', {
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   575
                        'bases': incoming,
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   576
                        'heads': rheads,
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   577
                        'source': 'incoming',
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   578
                    }).result()
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37497
diff changeset
   579
26543
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   580
            if localrepo:
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   581
                bundletype = "HG10BZ"
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   582
            else:
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   583
                bundletype = "HG10UN"
28666
ae53ecc47414 bundle: move writebundle() from changegroup.py to bundle2.py (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 28221
diff changeset
   584
            fname = bundle = bundle2.writebundle(ui, cg, bundlename,
26543
a018cbabdb51 bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26399
diff changeset
   585
                                                     bundletype)
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   586
        # keep written bundle?
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   587
        if bundlename:
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   588
            bundle = None
17191
5884812686f7 peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents: 16686
diff changeset
   589
        if not localrepo:
12734
5dfd1c49dcc5 bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12347
diff changeset
   590
            # use the created uncompressed bundlerepo
39619
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   591
            localrepo = bundlerepo = makebundlerepository(repo. baseui,
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   592
                                                          repo.root,
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   593
                                                          fname)
a8d2faeca49e bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39618
diff changeset
   594
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   595
            # this repo contains local and peer now, so filter out local again
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   596
            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
   597
    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
   598
        # 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
   599
        # 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
   600
        # 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
   601
        localrepo = localrepo.unfiltered()
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   602
14412
9ac479758d3b bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14287
diff changeset
   603
    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
   604
23633
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   605
    if bundlerepo:
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   606
        reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]]
37643
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   607
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   608
        with peer.commandexecutor() as e:
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   609
            remotephases = e.callcommand('listkeys', {
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   610
                'namespace': 'phases',
1aa4d646d0de bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37642
diff changeset
   611
            }).result()
23633
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   612
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   613
        pullop = exchange.pulloperation(bundlerepo, peer, heads=reponodes)
23633
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   614
        pullop.trmanager = bundletransactionmanager()
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   615
        exchange._pullapplyphases(pullop, remotephases)
96c3cbec006f incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents: 23632
diff changeset
   616
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   617
    def cleanup():
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   618
        if bundlerepo:
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   619
            bundlerepo.close()
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   620
        if bundle:
21694
c08a22bfa16e bundlerepo: backout dbf292f65b09
Matt Mackall <mpm@selenic.com>
parents: 21562
diff changeset
   621
            os.unlink(bundle)
37642
d959277ff1b5 bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   622
        peer.close()
14161
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   623
8a0fca925992 bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14158
diff changeset
   624
    return (localrepo, csets, cleanup)