bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
1 |
# Copyright (C) 2007 Canonical Ltd
|
|
0.200.910
by Jelmer Vernooij
update copyright years |
2 |
# Copyright (C) 2010 Jelmer Vernooij
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
18 |
"""An adapter between a Git control dir and a Bazaar ControlDir."""
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
19 |
|
20 |
from bzrlib import ( |
|
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
21 |
errors as bzr_errors, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
22 |
lockable_files, |
23 |
urlutils, |
|
|
0.200.768
by Jelmer Vernooij
Fix compatibility with older versions of bzrlib. |
24 |
version_info as bzrlib_version, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
25 |
)
|
26 |
||
|
0.200.280
by Jelmer Vernooij
Support bzr.dev. |
27 |
LockWarner = getattr(lockable_files, "_LockWarner", None) |
28 |
||
|
0.200.27
by David Allouche
Flat is better than nested, remove the gitlib hierarchy. |
29 |
from bzrlib.plugins.git import ( |
|
0.200.1032
by Jelmer Vernooij
Support bare repositories. |
30 |
BareLocalGitControlDirFormat, |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
31 |
LocalGitControlDirFormat, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
32 |
)
|
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
33 |
try: |
34 |
from bzrlib.controldir import ( |
|
35 |
ControlDir, |
|
|
0.200.1013
by Jelmer Vernooij
More renames. |
36 |
format_registry, |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
37 |
)
|
38 |
except ImportError: |
|
39 |
# bzr < 2.3
|
|
40 |
from bzrlib.bzrdir import ( |
|
41 |
BzrDir, |
|
|
0.200.1013
by Jelmer Vernooij
More renames. |
42 |
format_registry, |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
43 |
)
|
44 |
ControlDir = BzrDir |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
45 |
|
|
0.200.123
by Jelmer Vernooij
Use central git module. |
46 |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
47 |
class GitLock(object): |
48 |
"""A lock that thunks through to Git.""" |
|
49 |
||
|
0.200.84
by Jelmer Vernooij
Fix lock_write argument. |
50 |
def lock_write(self, token=None): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
51 |
pass
|
52 |
||
53 |
def lock_read(self): |
|
54 |
pass
|
|
55 |
||
56 |
def unlock(self): |
|
57 |
pass
|
|
58 |
||
|
0.200.73
by Jelmer Vernooij
Implement GitLock.peek(). |
59 |
def peek(self): |
60 |
pass
|
|
61 |
||
|
0.200.130
by Jelmer Vernooij
Make most tree inspection tests succeed. |
62 |
def validate_token(self, token): |
63 |
pass
|
|
64 |
||
|
0.200.629
by Jelmer Vernooij
Add GitLock.break_lock(). |
65 |
def break_lock(self): |
66 |
pass
|
|
67 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
68 |
|
69 |
class GitLockableFiles(lockable_files.LockableFiles): |
|
70 |
"""Git specific lockable files abstraction.""" |
|
71 |
||
|
0.200.129
by Jelmer Vernooij
merge dulwich. |
72 |
def __init__(self, transport, lock): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
73 |
self._lock = lock |
74 |
self._transaction = None |
|
75 |
self._lock_mode = None |
|
|
0.200.129
by Jelmer Vernooij
merge dulwich. |
76 |
self._transport = transport |
|
0.200.280
by Jelmer Vernooij
Support bzr.dev. |
77 |
if LockWarner is None: |
78 |
# Bzr 1.13
|
|
79 |
self._lock_count = 0 |
|
80 |
else: |
|
81 |
self._lock_warner = LockWarner(repr(self)) |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
82 |
|
83 |
||
|
0.200.1026
by Jelmer Vernooij
Fix typo. |
84 |
class GitDirConfig(object): |
|
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
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 |
||
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
93 |
class GitDir(ControlDir): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
94 |
"""An adapter to the '.git' dir used by git.""" |
95 |
||
|
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
96 |
def is_supported(self): |
97 |
return True |
|
98 |
||
|
0.200.981
by Jelmer Vernooij
Mark git directories as not convertable (for now). |
99 |
def can_convert_format(self): |
100 |
return False |
|
101 |
||
|
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
102 |
def break_lock(self): |
103 |
pass
|
|
104 |
||
|
0.200.155
by Jelmer Vernooij
Fix formatting, remove catch-all for exceptions when opening local repositories. |
105 |
def cloning_metadir(self, stacked=False): |
|
0.200.1013
by Jelmer Vernooij
More renames. |
106 |
return format_registry.make_bzrdir("default") |
|
0.200.155
by Jelmer Vernooij
Fix formatting, remove catch-all for exceptions when opening local repositories. |
107 |
|
|
0.200.729
by Jelmer Vernooij
Improve colocated branches support. |
108 |
def _branch_name_to_ref(self, name): |
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
109 |
raise NotImplementedError(self._branch_name_to_ref) |
|
0.200.729
by Jelmer Vernooij
Improve colocated branches support. |
110 |
|
|
0.200.777
by Jelmer Vernooij
Fix colocated remote branches. |
111 |
if bzrlib_version >= (2, 2): |
|
0.200.999
by Jelmer Vernooij
Fix argument ordering. |
112 |
def open_branch(self, name=None, unsupported=False, |
113 |
ignore_fallbacks=None): |
|
|
0.200.777
by Jelmer Vernooij
Fix colocated remote branches. |
114 |
return self._open_branch(name=name, |
115 |
ignore_fallbacks=ignore_fallbacks, unsupported=unsupported) |
|
116 |
else: |
|
117 |
def open_branch(self, ignore_fallbacks=None, unsupported=False): |
|
118 |
return self._open_branch(name=None, |
|
119 |
ignore_fallbacks=ignore_fallbacks, unsupported=unsupported) |
|
120 |
||
|
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
121 |
def get_config(self): |
122 |
return GitDirConfig() |
|
123 |
||
|
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
124 |
|
125 |
class LocalGitDir(GitDir): |
|
126 |
"""An adapter to the '.git' dir used by git.""" |
|
127 |
||
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
128 |
def _get_gitrepository_class(self): |
129 |
from bzrlib.plugins.git.repository import LocalGitRepository |
|
130 |
return LocalGitRepository |
|
131 |
||
132 |
_gitrepository_class = property(_get_gitrepository_class) |
|
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
133 |
|
|
0.200.1014
by Jelmer Vernooij
Fix tests. |
134 |
@property
|
135 |
def user_transport(self): |
|
136 |
return self.root_transport |
|
137 |
||
138 |
@property
|
|
139 |
def control_transport(self): |
|
140 |
return self.transport |
|
141 |
||
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
142 |
def __init__(self, transport, lockfiles, gitrepo, format): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
143 |
self._format = format |
144 |
self.root_transport = transport |
|
|
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
145 |
self._mode_check_done = False |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
146 |
self._git = gitrepo |
147 |
if gitrepo.bare: |
|
148 |
self.transport = transport |
|
149 |
else: |
|
150 |
self.transport = transport.clone('.git') |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
151 |
self._lockfiles = lockfiles |
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
152 |
self._mode_check_done = None |
153 |
||
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
154 |
def _branch_name_to_ref(self, name): |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
155 |
from bzrlib.plugins.git.refs import branch_name_to_ref |
|
0.200.916
by Jelmer Vernooij
Set refs/heads/master if no ref is set yet. |
156 |
ref = branch_name_to_ref(name, None) |
|
0.200.915
by Jelmer Vernooij
Cope with the fact that the old format didn't export file ids. |
157 |
if ref == "HEAD": |
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
158 |
from dulwich.repo import SYMREF |
|
0.200.915
by Jelmer Vernooij
Cope with the fact that the old format didn't export file ids. |
159 |
refcontents = self._git.refs.read_ref(ref) |
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
160 |
if refcontents.startswith(SYMREF): |
|
0.200.915
by Jelmer Vernooij
Cope with the fact that the old format didn't export file ids. |
161 |
ref = refcontents[len(SYMREF):] |
162 |
return ref |
|
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
163 |
|
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
164 |
def is_control_filename(self, filename): |
165 |
return filename == '.git' or filename.startswith('.git/') |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
166 |
|
|
0.200.978
by Jelmer Vernooij
Allow name argument to get_branch_transport to be missing. |
167 |
def get_branch_transport(self, branch_format, name=None): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
168 |
if branch_format is None: |
169 |
return self.transport |
|
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
170 |
if isinstance(branch_format, LocalGitControlDirFormat): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
171 |
return self.transport |
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
172 |
raise bzr_errors.IncompatibleFormat(branch_format, self._format) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
173 |
|
|
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
174 |
def get_repository_transport(self, format): |
175 |
if format is None: |
|
176 |
return self.transport |
|
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
177 |
if isinstance(format, LocalGitControlDirFormat): |
|
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
178 |
return self.transport |
179 |
raise bzr_errors.IncompatibleFormat(format, self._format) |
|
180 |
||
181 |
def get_workingtree_transport(self, format): |
|
182 |
if format is None: |
|
183 |
return self.transport |
|
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
184 |
if isinstance(format, LocalGitControlDirFormat): |
|
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
185 |
return self.transport |
186 |
raise bzr_errors.IncompatibleFormat(format, self._format) |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
187 |
|
|
0.200.769
by Jelmer Vernooij
Cope with open_branch() actually checking whether there is a branch present. |
188 |
def _open_branch(self, name=None, ignore_fallbacks=None, unsupported=False): |
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
189 |
"""'create' a branch for this dir.""" |
190 |
repo = self.open_repository() |
|
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
191 |
from bzrlib.plugins.git.branch import LocalGitBranch |
|
0.200.726
by Jelmer Vernooij
Factor out conversion of branch names to refs. |
192 |
return LocalGitBranch(self, repo, self._branch_name_to_ref(name), |
193 |
self._lockfiles) |
|
|
0.200.722
by Jelmer Vernooij
Implement GitDir.list_branches() and support name argument to open_branch. |
194 |
|
|
0.200.724
by Jelmer Vernooij
support destroy_branch |
195 |
def destroy_branch(self, name=None): |
|
0.200.997
by Jelmer Vernooij
Implement BzrDir.needs_format_conversion. |
196 |
refname = self._branch_name_to_ref(name) |
197 |
if not refname in self._git.refs: |
|
198 |
raise bzr_errors.NotBranchError(self.root_transport.base, |
|
199 |
bzrdir=self) |
|
200 |
del self._git.refs[refname] |
|
|
0.200.724
by Jelmer Vernooij
support destroy_branch |
201 |
|
|
0.200.980
by Jelmer Vernooij
Implement LocalGitBzrDir.destroy_repository(). |
202 |
def destroy_repository(self): |
203 |
raise bzr_errors.UnsupportedOperation(self.destroy_repository, self) |
|
204 |
||
|
0.200.986
by Jelmer Vernooij
Implement GitDir.destroy_workingtree. |
205 |
def destroy_workingtree(self): |
206 |
raise bzr_errors.UnsupportedOperation(self.destroy_workingtree, self) |
|
207 |
||
|
0.200.997
by Jelmer Vernooij
Implement BzrDir.needs_format_conversion. |
208 |
def needs_format_conversion(self, format=None): |
209 |
return not isinstance(self._format, format.__class__) |
|
210 |
||
|
0.200.722
by Jelmer Vernooij
Implement GitDir.list_branches() and support name argument to open_branch. |
211 |
def list_branches(self): |
212 |
ret = [] |
|
213 |
for name in self._git.get_refs(): |
|
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
214 |
if name.startswith("refs/heads/"): |
|
0.200.766
by Jelmer Vernooij
Only list actual branches, not tags. |
215 |
ret.append(self.open_branch(name=name)) |
|
0.200.722
by Jelmer Vernooij
Implement GitDir.list_branches() and support name argument to open_branch. |
216 |
return ret |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
217 |
|
218 |
def open_repository(self, shared=False): |
|
219 |
"""'open' a repository for this dir.""" |
|
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
220 |
return self._gitrepository_class(self, self._lockfiles) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
221 |
|
|
0.203.1
by Aaron Bentley
Make checkouts work |
222 |
def open_workingtree(self, recommend_upgrade=True): |
|
0.246.5
by Jelmer Vernooij
Cope with has_index not existing. |
223 |
if not self._git.bare: |
224 |
from dulwich.errors import NoIndexPresent |
|
|
0.200.803
by Jelmer Vernooij
Default to non-bare repositories when initializing a control directory. |
225 |
repo = self.open_repository() |
|
0.246.5
by Jelmer Vernooij
Cope with has_index not existing. |
226 |
try: |
|
0.200.803
by Jelmer Vernooij
Default to non-bare repositories when initializing a control directory. |
227 |
index = repo._git.open_index() |
|
0.246.5
by Jelmer Vernooij
Cope with has_index not existing. |
228 |
except NoIndexPresent: |
229 |
pass
|
|
|
0.200.803
by Jelmer Vernooij
Default to non-bare repositories when initializing a control directory. |
230 |
else: |
231 |
from bzrlib.plugins.git.workingtree import GitWorkingTree |
|
|
0.200.921
by Jelmer Vernooij
fix init tests. |
232 |
try: |
233 |
branch = self.open_branch() |
|
234 |
except bzr_errors.NotBranchError: |
|
235 |
pass
|
|
236 |
else: |
|
237 |
return GitWorkingTree(self, repo, branch, index) |
|
|
0.200.392
by Jelmer Vernooij
Fix some tests now that working trees are supported. |
238 |
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii') |
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
239 |
raise bzr_errors.NoWorkingTree(loc) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
240 |
|
|
0.200.108
by Jelmer Vernooij
Support bzr init --git. |
241 |
def create_repository(self, shared=False): |
242 |
return self.open_repository() |
|
|
0.200.288
by Jelmer Vernooij
Add test for init-repo. |
243 |
|
|
0.200.726
by Jelmer Vernooij
Factor out conversion of branch names to refs. |
244 |
def create_branch(self, name=None): |
245 |
refname = self._branch_name_to_ref(name) |
|
|
0.200.891
by Jelmer Vernooij
Use ZERO_SHA constant where possible. |
246 |
from dulwich.protocol import ZERO_SHA |
|
0.200.920
by Jelmer Vernooij
Fix some more tests. |
247 |
self._git.refs[refname or "HEAD"] = ZERO_SHA |
|
0.200.731
by Jelmer Vernooij
Handle unsupported flag to open_branch(). |
248 |
return self.open_branch(name) |
|
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
249 |
|
250 |
def backup_bzrdir(self): |
|
251 |
if self._git.bare: |
|
252 |
self.root_transport.copy_tree(".git", ".git.backup") |
|
253 |
return (self.root_transport.abspath(".git"), |
|
254 |
self.root_transport.abspath(".git.backup")) |
|
255 |
else: |
|
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
256 |
raise bzr_errors.BzrError("Unable to backup bare repositories") |
|
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
257 |
|
258 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
259 |
accelerator_tree=None, hardlink=False): |
|
260 |
if self._git.bare: |
|
|
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
261 |
raise bzr_errors.BzrError("Can't create working tree in a bare repo") |
|
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
262 |
from dulwich.index import write_index |
|
0.200.613
by Jelmer Vernooij
Support creating working tree for existing git repo. |
263 |
from dulwich.pack import SHA1Writer |
264 |
f = open(self.transport.local_abspath("index"), 'w+') |
|
265 |
try: |
|
266 |
f = SHA1Writer(f) |
|
267 |
write_index(f, []) |
|
268 |
finally: |
|
269 |
f.close() |
|
|
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
270 |
return self.open_workingtree() |
|
0.200.1015
by Jelmer Vernooij
Fix GitControlDir.find_repository(). |
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() |
|
|
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
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 |