/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/views.py

  • Committer: Jelmer Vernooij
  • Date: 2018-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
  tree.views.lookup_view()
23
23
"""
24
24
 
 
25
from __future__ import absolute_import
 
26
 
25
27
import re
26
28
 
27
29
from . import (
30
32
    )
31
33
 
32
34
 
33
 
_VIEWS_FORMAT_MARKER_RE = re.compile(b'Bazaar views format (\\d+)')
34
 
_VIEWS_FORMAT1_MARKER = b"Bazaar views format 1\n"
 
35
_VIEWS_FORMAT_MARKER_RE = re.compile(r'Bazaar views format (\d+)')
 
36
_VIEWS_FORMAT1_MARKER = "Bazaar views format 1\n"
35
37
 
36
38
 
37
39
class NoSuchView(errors.BzrError):
187
189
                keywords = {}
188
190
            else:
189
191
                keywords = {'current': self._current}
190
 
            self.tree._transport.put_bytes(
191
 
                'views', self._serialize_view_content(keywords, self._views))
 
192
            self.tree._transport.put_bytes('views',
 
193
                self._serialize_view_content(keywords, self._views))
192
194
 
193
195
    def _load_view_info(self):
194
196
        """Load the current view and dictionary of view definitions."""
196
198
            with self.tree.lock_read():
197
199
                try:
198
200
                    view_content = self.tree._transport.get_bytes('views')
199
 
                except errors.NoSuchFile:
 
201
                except errors.NoSuchFile as e:
200
202
                    self._current, self._views = None, {}
201
203
                else:
202
204
                    keywords, self._views = \
221
223
        """Convert a stream into view keywords and a dictionary of views."""
222
224
        # as a special case to make initialization easy, an empty definition
223
225
        # maps to no current view and an empty view dictionary
224
 
        if view_content == b'':
 
226
        if view_content == '':
225
227
            return {}, {}
226
228
        lines = view_content.splitlines()
227
229
        match = _VIEWS_FORMAT_MARKER_RE.match(lines[0])
228
230
        if not match:
229
231
            raise ValueError(
230
232
                "format marker missing from top of views file")
231
 
        elif match.group(1) != b'1':
 
233
        elif match.group(1) != '1':
232
234
            raise ValueError(
233
235
                "cannot decode views format %s" % match.group(1))
234
236
        try:
250
252
                    keywords[keyword] = value
251
253
                else:
252
254
                    raise ValueError("failed to deserialize views line %s",
253
 
                                     text)
 
255
                        text)
254
256
            return keywords, views
255
257
        except ValueError as e:
256
258
            raise ValueError("failed to deserialize views content %r: %s"
257
 
                             % (view_content, e))
 
259
                % (view_content, e))
258
260
 
259
261
 
260
262
class DisabledViews(_Views):
295
297
    """If a working tree has a view enabled, check the path is within it."""
296
298
    if tree.supports_views():
297
299
        view_files = tree.views.lookup_view()
298
 
        if view_files and not osutils.is_inside_any(view_files, relpath):
 
300
        if  view_files and not osutils.is_inside_any(view_files, relpath):
299
301
            raise FileOutsideView(relpath, view_files)