/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/repofmt/pack_repo.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import re
20
20
import sys
21
21
 
22
 
from bzrlib.lazy_import import lazy_import
 
22
from ..lazy_import import lazy_import
23
23
lazy_import(globals(), """
24
24
from itertools import izip
25
25
import time
26
26
 
27
 
from bzrlib import (
 
27
from breezy import (
28
28
    chk_map,
29
29
    cleanup,
30
30
    config,
36
36
    tsort,
37
37
    ui,
38
38
    )
39
 
from bzrlib.index import (
 
39
from breezy.index import (
40
40
    CombinedGraphIndex,
41
41
    GraphIndexPrefixAdapter,
42
42
    )
43
43
""")
44
 
from bzrlib import (
 
44
from .. import (
45
45
    btree_index,
46
46
    errors,
47
47
    lockable_files,
48
48
    lockdir,
49
49
    )
50
50
 
51
 
from bzrlib.decorators import (
 
51
from ..decorators import (
52
52
    needs_read_lock,
53
53
    needs_write_lock,
54
54
    only_raises,
55
55
    )
56
 
from bzrlib.lock import LogicalLockResult
57
 
from bzrlib.repository import (
 
56
from ..lock import LogicalLockResult
 
57
from ..repository import (
58
58
    _LazyListJoin,
59
59
    MetaDirRepository,
60
60
    RepositoryFormatMetaDir,
61
61
    RepositoryWriteLockResult,
62
62
    )
63
 
from bzrlib.vf_repository import (
 
63
from ..sixish import (
 
64
    reraise,
 
65
)
 
66
from ..vf_repository import (
64
67
    MetaDirVersionedFileRepository,
65
68
    MetaDirVersionedFileRepositoryFormat,
66
69
    VersionedFileCommitBuilder,
67
70
    VersionedFileRootCommitBuilder,
68
71
    )
69
 
from bzrlib.trace import (
 
72
from ..trace import (
70
73
    mutter,
71
74
    note,
72
75
    warning,
91
94
 
92
95
    def _heads(self, file_id, revision_ids):
93
96
        keys = [(file_id, revision_id) for revision_id in revision_ids]
94
 
        return set([key[1] for key in self._file_graph.heads(keys)])
 
97
        return {key[1] for key in self._file_graph.heads(keys)}
95
98
 
96
99
 
97
100
class PackRootCommitBuilder(VersionedFileRootCommitBuilder):
113
116
 
114
117
    def _heads(self, file_id, revision_ids):
115
118
        keys = [(file_id, revision_id) for revision_id in revision_ids]
116
 
        return set([key[1] for key in self._file_graph.heads(keys)])
 
119
        return {key[1] for key in self._file_graph.heads(keys)}
117
120
 
118
121
 
119
122
class Pack(object):
1146
1149
                txt_index, sig_index, self._upload_transport,
1147
1150
                self._pack_transport, self._index_transport, self,
1148
1151
                chk_index=chk_index)
1149
 
        except errors.NoSuchFile, e:
 
1152
        except errors.NoSuchFile as e:
1150
1153
            raise errors.UnresumableWriteGroup(self.repo, [name], str(e))
1151
1154
        self.add_pack_to_memory(result)
1152
1155
        self._resumed_packs.append(result)
1235
1238
                        pass
1236
1239
                    pack.pack_transport.move(pack.file_name(),
1237
1240
                        '../obsolete_packs/' + pack.file_name())
1238
 
            except (errors.PathError, errors.TransportError), e:
 
1241
            except (errors.PathError, errors.TransportError) as e:
1239
1242
                # TODO: Should these be warnings or mutters?
1240
1243
                mutter("couldn't rename obsolete pack, skipping it:\n%s"
1241
1244
                       % (e,))
1249
1252
                try:
1250
1253
                    self._index_transport.move(pack.name + suffix,
1251
1254
                        '../obsolete_packs/' + pack.name + suffix)
1252
 
                except (errors.PathError, errors.TransportError), e:
 
1255
                except (errors.PathError, errors.TransportError) as e:
1253
1256
                    mutter("couldn't rename obsolete index, skipping it:\n%s"
1254
1257
                           % (e,))
1255
1258
 
1433
1436
            if clear_obsolete_packs:
1434
1437
                to_preserve = None
1435
1438
                if obsolete_packs:
1436
 
                    to_preserve = set([o.name for o in obsolete_packs])
 
1439
                    to_preserve = {o.name for o in obsolete_packs}
1437
1440
                already_obsolete = self._clear_obsolete_packs(to_preserve)
1438
1441
        finally:
1439
1442
            self._unlock_names()
1518
1521
                continue
1519
1522
            try:
1520
1523
                obsolete_pack_transport.delete(filename)
1521
 
            except (errors.PathError, errors.TransportError), e:
 
1524
            except (errors.PathError, errors.TransportError) as e:
1522
1525
                warning("couldn't delete obsolete pack, skipping it:\n%s"
1523
1526
                        % (e,))
1524
1527
        return found
1764
1767
    def lock_write(self, token=None):
1765
1768
        """Lock the repository for writes.
1766
1769
 
1767
 
        :return: A bzrlib.repository.RepositoryWriteLockResult.
 
1770
        :return: A breezy.repository.RepositoryWriteLockResult.
1768
1771
        """
1769
1772
        locked = self.is_locked()
1770
1773
        if not self._write_lock_count and locked:
1786
1789
    def lock_read(self):
1787
1790
        """Lock the repository for reads.
1788
1791
 
1789
 
        :return: A bzrlib.lock.LogicalLockResult.
 
1792
        :return: A breezy.lock.LogicalLockResult.
1790
1793
        """
1791
1794
        locked = self.is_locked()
1792
1795
        if self._write_lock_count:
1823
1826
    @needs_write_lock
1824
1827
    def reconcile(self, other=None, thorough=False):
1825
1828
        """Reconcile this repository."""
1826
 
        from bzrlib.reconcile import PackReconciler
 
1829
        from breezy.reconcile import PackReconciler
1827
1830
        reconciler = PackReconciler(self, thorough=thorough)
1828
1831
        reconciler.reconcile()
1829
1832
        return reconciler
1959
1962
            and file names for obtaining data.
1960
1963
        :param reload_func: A function to call if we determine that the pack
1961
1964
            files have moved and we need to reload our caches. See
1962
 
            bzrlib.repo_fmt.pack_repo.AggregateIndex for more details.
 
1965
            breezy.repo_fmt.pack_repo.AggregateIndex for more details.
1963
1966
        """
1964
1967
        self._container_writer = None
1965
1968
        self._write_index = None
1981
1984
            length), where the index field is the write_index object supplied
1982
1985
            to the PackAccess object.
1983
1986
        """
1984
 
        if type(raw_data) is not str:
 
1987
        if not isinstance(raw_data, str):
1985
1988
            raise AssertionError(
1986
1989
                'data must be plain bytes was %s' % type(raw_data))
1987
1990
        result = []
2084
2087
                # hard error
2085
2088
                is_error = True
2086
2089
        if is_error:
2087
 
            exc_class, exc_value, exc_traceback = retry_exc.exc_info
2088
 
            raise exc_class, exc_value, exc_traceback
2089
 
 
2090
 
 
2091
 
 
 
2090
            # GZ 2017-03-27: No real reason this needs the original traceback.
 
2091
            reraise(*retry_exc.exc_info)