Show More
@@ -161,18 +161,55 b' def checkexec(path):' | |||||
161 | try: |
|
161 | try: | |
162 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
|
162 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | |
163 | cachedir = os.path.join(path, '.hg', 'cache') |
|
163 | cachedir = os.path.join(path, '.hg', 'cache') | |
164 |
if |
|
164 | if os.path.isdir(cachedir): | |
165 | cachedir = path |
|
165 | checkisexec = os.path.join(cachedir, 'checkisexec') | |
166 | fh, fn = tempfile.mkstemp(dir=cachedir, prefix='hg-checkexec-') |
|
166 | checknoexec = os.path.join(cachedir, 'checknoexec') | |
|
167 | ||||
|
168 | try: | |||
|
169 | m = os.stat(checkisexec).st_mode | |||
|
170 | except OSError as e: | |||
|
171 | if e.errno != errno.ENOENT: | |||
|
172 | raise | |||
|
173 | # checkisexec does not exist - fall through ... | |||
|
174 | else: | |||
|
175 | # checkisexec exists, check if it actually is exec | |||
|
176 | if m & EXECFLAGS != 0: | |||
|
177 | # ensure checkisexec exists, check it isn't exec | |||
|
178 | try: | |||
|
179 | m = os.stat(checknoexec).st_mode | |||
|
180 | except OSError as e: | |||
|
181 | if e.errno != errno.ENOENT: | |||
|
182 | raise | |||
|
183 | file(checknoexec, 'w').close() # might fail | |||
|
184 | m = os.stat(checknoexec).st_mode | |||
|
185 | if m & EXECFLAGS == 0: | |||
|
186 | # check-exec is exec and check-no-exec is not exec | |||
|
187 | return True | |||
|
188 | # checknoexec exists but is exec - delete it | |||
|
189 | os.unlink(checknoexec) | |||
|
190 | # checkisexec exists but is not exec - delete it | |||
|
191 | os.unlink(checkisexec) | |||
|
192 | ||||
|
193 | # check using one file, leave it as checkisexec | |||
|
194 | checkdir = cachedir | |||
|
195 | else: | |||
|
196 | # check directly in path and don't leave checkisexec behind | |||
|
197 | checkdir = path | |||
|
198 | checkisexec = None | |||
|
199 | fh, fn = tempfile.mkstemp(dir=checkdir, prefix='hg-checkexec-') | |||
167 | try: |
|
200 | try: | |
168 | os.close(fh) |
|
201 | os.close(fh) | |
169 | m = os.stat(fn).st_mode |
|
202 | m = os.stat(fn).st_mode | |
170 | if m & EXECFLAGS: |
|
203 | if m & EXECFLAGS == 0: | |
171 | return False |
|
204 | os.chmod(fn, m & 0o777 | EXECFLAGS) | |
172 | os.chmod(fn, m & 0o777 | EXECFLAGS) |
|
205 | if os.stat(fn).st_mode & EXECFLAGS != 0: | |
173 | return os.stat(fn).st_mode & EXECFLAGS |
|
206 | if checkisexec is not None: | |
|
207 | os.rename(fn, checkisexec) | |||
|
208 | fn = None | |||
|
209 | return True | |||
174 | finally: |
|
210 | finally: | |
175 | os.unlink(fn) |
|
211 | if fn is not None: | |
|
212 | os.unlink(fn) | |||
176 | except (IOError, OSError): |
|
213 | except (IOError, OSError): | |
177 | # we don't care, the user probably won't be able to commit anyway |
|
214 | # we don't care, the user probably won't be able to commit anyway | |
178 | return False |
|
215 | return False |
@@ -31,6 +31,8 b' Trigger branchcache creation:' | |||||
31 | default 10:a7949464abda |
|
31 | default 10:a7949464abda | |
32 | $ ls .hg/cache |
|
32 | $ ls .hg/cache | |
33 | branch2-served |
|
33 | branch2-served | |
|
34 | checkisexec | |||
|
35 | checknoexec | |||
34 | rbc-names-v1 |
|
36 | rbc-names-v1 | |
35 | rbc-revs-v1 |
|
37 | rbc-revs-v1 | |
36 |
|
38 | |||
@@ -45,6 +47,7 b' Ensure branchcache got copied over:' | |||||
45 |
|
47 | |||
46 | $ ls .hg/cache |
|
48 | $ ls .hg/cache | |
47 | branch2-served |
|
49 | branch2-served | |
|
50 | checkisexec | |||
48 |
|
51 | |||
49 | $ cat a |
|
52 | $ cat a | |
50 | a |
|
53 | a |
@@ -211,6 +211,8 b' r4 has hardlinks in the working dir (not' | |||||
211 | 2 r4/.hg/00changelog.i |
|
211 | 2 r4/.hg/00changelog.i | |
212 | 2 r4/.hg/branch |
|
212 | 2 r4/.hg/branch | |
213 | 2 r4/.hg/cache/branch2-served |
|
213 | 2 r4/.hg/cache/branch2-served | |
|
214 | 2 r4/.hg/cache/checkisexec | |||
|
215 | 2 r4/.hg/cache/checknoexec | |||
214 | 2 r4/.hg/cache/rbc-names-v1 |
|
216 | 2 r4/.hg/cache/rbc-names-v1 | |
215 | 2 r4/.hg/cache/rbc-revs-v1 |
|
217 | 2 r4/.hg/cache/rbc-revs-v1 | |
216 | 2 r4/.hg/dirstate |
|
218 | 2 r4/.hg/dirstate | |
@@ -247,6 +249,8 b' Update back to revision 11 in r4 should ' | |||||
247 | 2 r4/.hg/00changelog.i |
|
249 | 2 r4/.hg/00changelog.i | |
248 | 1 r4/.hg/branch |
|
250 | 1 r4/.hg/branch | |
249 | 2 r4/.hg/cache/branch2-served |
|
251 | 2 r4/.hg/cache/branch2-served | |
|
252 | 2 r4/.hg/cache/checkisexec | |||
|
253 | 2 r4/.hg/cache/checknoexec | |||
250 | 2 r4/.hg/cache/rbc-names-v1 |
|
254 | 2 r4/.hg/cache/rbc-names-v1 | |
251 | 2 r4/.hg/cache/rbc-revs-v1 |
|
255 | 2 r4/.hg/cache/rbc-revs-v1 | |
252 | 1 r4/.hg/dirstate |
|
256 | 1 r4/.hg/dirstate |
@@ -672,6 +672,7 b' Missing tags2* files means the cache was' | |||||
672 |
|
672 | |||
673 | $ ls tagsclient/.hg/cache |
|
673 | $ ls tagsclient/.hg/cache | |
674 | branch2-served |
|
674 | branch2-served | |
|
675 | checkisexec | |||
675 | hgtagsfnodes1 |
|
676 | hgtagsfnodes1 | |
676 | rbc-names-v1 |
|
677 | rbc-names-v1 | |
677 | rbc-revs-v1 |
|
678 | rbc-revs-v1 | |
@@ -696,6 +697,7 b' Running hg tags should produce tags2* fi' | |||||
696 |
|
697 | |||
697 | $ ls tagsclient/.hg/cache |
|
698 | $ ls tagsclient/.hg/cache | |
698 | branch2-served |
|
699 | branch2-served | |
|
700 | checkisexec | |||
699 | hgtagsfnodes1 |
|
701 | hgtagsfnodes1 | |
700 | rbc-names-v1 |
|
702 | rbc-names-v1 | |
701 | rbc-revs-v1 |
|
703 | rbc-revs-v1 |
General Comments 0
You need to be logged in to leave comments.
Login now