/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 dir.py

Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
LockWarner = getattr(lockable_files, "_LockWarner", None)
28
28
 
29
29
from bzrlib.plugins.git import (
30
 
    BareLocalGitControlDirFormat,
31
30
    LocalGitControlDirFormat,
32
31
    )
33
32
try:
81
80
            self._lock_warner = LockWarner(repr(self))
82
81
 
83
82
 
84
 
class GitDirConfig(object):
85
 
 
86
 
    def get_default_stack_on(self):
87
 
        return None
88
 
 
89
 
    def set_default_stack_on(self, value):
90
 
        raise bzr_errors.BzrError("Cannot set configuration")
91
 
 
92
 
 
93
83
class GitDir(ControlDir):
94
84
    """An adapter to the '.git' dir used by git."""
95
85
 
99
89
    def can_convert_format(self):
100
90
        return False
101
91
 
102
 
    def break_lock(self):
103
 
        pass
104
 
 
105
92
    def cloning_metadir(self, stacked=False):
106
93
        return format_registry.make_bzrdir("default")
107
94
 
118
105
            return self._open_branch(name=None,
119
106
                ignore_fallbacks=ignore_fallbacks, unsupported=unsupported)
120
107
 
121
 
    def get_config(self):
122
 
        return GitDirConfig()
123
 
 
124
108
 
125
109
class LocalGitDir(GitDir):
126
110
    """An adapter to the '.git' dir used by git."""
142
126
    def __init__(self, transport, lockfiles, gitrepo, format):
143
127
        self._format = format
144
128
        self.root_transport = transport
145
 
        self._mode_check_done = False
146
129
        self._git = gitrepo
147
130
        if gitrepo.bare:
148
131
            self.transport = transport
268
251
        finally:
269
252
            f.close()
270
253
        return self.open_workingtree()
271
 
 
272
 
    def find_repository(self):
273
 
        """Find the repository that should be used.
274
 
 
275
 
        This does not require a branch as we use it to find the repo for
276
 
        new branches as well as to hook existing branches up to their
277
 
        repository.
278
 
        """
279
 
        return self.open_repository()
280
 
 
281
 
    def _find_creation_modes(self):
282
 
        """Determine the appropriate modes for files and directories.
283
 
 
284
 
        They're always set to be consistent with the base directory,
285
 
        assuming that this transport allows setting modes.
286
 
        """
287
 
        # TODO: Do we need or want an option (maybe a config setting) to turn
288
 
        # this off or override it for particular locations? -- mbp 20080512
289
 
        if self._mode_check_done:
290
 
            return
291
 
        self._mode_check_done = True
292
 
        try:
293
 
            st = self.transport.stat('.')
294
 
        except TransportNotPossible:
295
 
            self._dir_mode = None
296
 
            self._file_mode = None
297
 
        else:
298
 
            # Check the directory mode, but also make sure the created
299
 
            # directories and files are read-write for this user. This is
300
 
            # mostly a workaround for filesystems which lie about being able to
301
 
            # write to a directory (cygwin & win32)
302
 
            if (st.st_mode & 07777 == 00000):
303
 
                # FTP allows stat but does not return dir/file modes
304
 
                self._dir_mode = None
305
 
                self._file_mode = None
306
 
            else:
307
 
                self._dir_mode = (st.st_mode & 07777) | 00700
308
 
                # Remove the sticky and execute bits for files
309
 
                self._file_mode = self._dir_mode & ~07111
310
 
 
311
 
    def _get_file_mode(self):
312
 
        """Return Unix mode for newly created files, or None.
313
 
        """
314
 
        if not self._mode_check_done:
315
 
            self._find_creation_modes()
316
 
        return self._file_mode
317
 
 
318
 
    def _get_dir_mode(self):
319
 
        """Return Unix mode for newly created directories, or None.
320
 
        """
321
 
        if not self._mode_check_done:
322
 
            self._find_creation_modes()
323
 
        return self._dir_mode
324
 
 
325