##// END OF EJS Templates
tests: AIX can't handle negative date in test-dirstate.t...
Jim Hague -
r19092:8c560ad1 stable
parent child Browse files
Show More
@@ -1,317 +1,321 b''
1 1 import os, stat, socket
2 2 import re
3 3 import sys
4 4 import tempfile
5 5
6 6 tempprefix = 'hg-hghave-'
7 7
8 8 def matchoutput(cmd, regexp, ignorestatus=False):
9 9 """Return True if cmd executes successfully and its output
10 10 is matched by the supplied regular expression.
11 11 """
12 12 r = re.compile(regexp)
13 13 fh = os.popen(cmd)
14 14 s = fh.read()
15 15 try:
16 16 ret = fh.close()
17 17 except IOError:
18 18 # Happen in Windows test environment
19 19 ret = 1
20 20 return (ignorestatus or ret is None) and r.search(s)
21 21
22 22 def has_baz():
23 23 return matchoutput('baz --version 2>&1', r'baz Bazaar version')
24 24
25 25 def has_bzr():
26 26 try:
27 27 import bzrlib
28 28 return bzrlib.__doc__ is not None
29 29 except ImportError:
30 30 return False
31 31
32 32 def has_bzr114():
33 33 try:
34 34 import bzrlib
35 35 return (bzrlib.__doc__ is not None
36 36 and bzrlib.version_info[:2] >= (1, 14))
37 37 except ImportError:
38 38 return False
39 39
40 40 def has_cvs():
41 41 re = r'Concurrent Versions System.*?server'
42 42 return matchoutput('cvs --version 2>&1', re) and not has_msys()
43 43
44 44 def has_cvs112():
45 45 re = r'Concurrent Versions System \(CVS\) 1.12.*?server'
46 46 return matchoutput('cvs --version 2>&1', re) and not has_msys()
47 47
48 48 def has_darcs():
49 49 return matchoutput('darcs --version', r'2\.[2-9]', True)
50 50
51 51 def has_mtn():
52 52 return matchoutput('mtn --version', r'monotone', True) and not matchoutput(
53 53 'mtn --version', r'monotone 0\.', True)
54 54
55 55 def has_eol_in_paths():
56 56 try:
57 57 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r')
58 58 os.close(fd)
59 59 os.remove(path)
60 60 return True
61 61 except (IOError, OSError):
62 62 return False
63 63
64 64 def has_executablebit():
65 65 try:
66 66 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
67 67 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
68 68 try:
69 69 os.close(fh)
70 70 m = os.stat(fn).st_mode & 0777
71 71 new_file_has_exec = m & EXECFLAGS
72 72 os.chmod(fn, m ^ EXECFLAGS)
73 73 exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m)
74 74 finally:
75 75 os.unlink(fn)
76 76 except (IOError, OSError):
77 77 # we don't care, the user probably won't be able to commit anyway
78 78 return False
79 79 return not (new_file_has_exec or exec_flags_cannot_flip)
80 80
81 81 def has_icasefs():
82 82 # Stolen from mercurial.util
83 83 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
84 84 os.close(fd)
85 85 try:
86 86 s1 = os.stat(path)
87 87 d, b = os.path.split(path)
88 88 p2 = os.path.join(d, b.upper())
89 89 if path == p2:
90 90 p2 = os.path.join(d, b.lower())
91 91 try:
92 92 s2 = os.stat(p2)
93 93 return s2 == s1
94 94 except OSError:
95 95 return False
96 96 finally:
97 97 os.remove(path)
98 98
99 99 def has_inotify():
100 100 try:
101 101 import hgext.inotify.linux.watcher
102 102 except ImportError:
103 103 return False
104 104 name = tempfile.mktemp(dir='.', prefix=tempprefix)
105 105 sock = socket.socket(socket.AF_UNIX)
106 106 try:
107 107 sock.bind(name)
108 108 except socket.error, err:
109 109 return False
110 110 sock.close()
111 111 os.unlink(name)
112 112 return True
113 113
114 114 def has_fifo():
115 115 if getattr(os, "mkfifo", None) is None:
116 116 return False
117 117 name = tempfile.mktemp(dir='.', prefix=tempprefix)
118 118 try:
119 119 os.mkfifo(name)
120 120 os.unlink(name)
121 121 return True
122 122 except OSError:
123 123 return False
124 124
125 125 def has_killdaemons():
126 126 return True
127 127
128 128 def has_cacheable_fs():
129 129 from mercurial import util
130 130
131 131 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
132 132 os.close(fd)
133 133 try:
134 134 return util.cachestat(path).cacheable()
135 135 finally:
136 136 os.remove(path)
137 137
138 138 def has_lsprof():
139 139 try:
140 140 import _lsprof
141 141 return True
142 142 except ImportError:
143 143 return False
144 144
145 145 def has_gettext():
146 146 return matchoutput('msgfmt --version', 'GNU gettext-tools')
147 147
148 148 def has_git():
149 149 return matchoutput('git --version 2>&1', r'^git version')
150 150
151 151 def has_docutils():
152 152 try:
153 153 from docutils.core import publish_cmdline
154 154 return True
155 155 except ImportError:
156 156 return False
157 157
158 158 def getsvnversion():
159 159 m = matchoutput('svn --version --quiet 2>&1', r'^(\d+)\.(\d+)')
160 160 if not m:
161 161 return (0, 0)
162 162 return (int(m.group(1)), int(m.group(2)))
163 163
164 164 def has_svn15():
165 165 return getsvnversion() >= (1, 5)
166 166
167 167 def has_svn13():
168 168 return getsvnversion() >= (1, 3)
169 169
170 170 def has_svn():
171 171 return matchoutput('svn --version 2>&1', r'^svn, version') and \
172 172 matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
173 173
174 174 def has_svn_bindings():
175 175 try:
176 176 import svn.core
177 177 version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR
178 178 if version < (1, 4):
179 179 return False
180 180 return True
181 181 except ImportError:
182 182 return False
183 183
184 184 def has_p4():
185 185 return (matchoutput('p4 -V', r'Rev\. P4/') and
186 186 matchoutput('p4d -V', r'Rev\. P4D/'))
187 187
188 188 def has_symlink():
189 189 if getattr(os, "symlink", None) is None:
190 190 return False
191 191 name = tempfile.mktemp(dir='.', prefix=tempprefix)
192 192 try:
193 193 os.symlink(".", name)
194 194 os.unlink(name)
195 195 return True
196 196 except (OSError, AttributeError):
197 197 return False
198 198
199 199 def has_hardlink():
200 200 from mercurial import util
201 201 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
202 202 os.close(fh)
203 203 name = tempfile.mktemp(dir='.', prefix=tempprefix)
204 204 try:
205 205 try:
206 206 util.oslink(fn, name)
207 207 os.unlink(name)
208 208 return True
209 209 except OSError:
210 210 return False
211 211 finally:
212 212 os.unlink(fn)
213 213
214 214 def has_tla():
215 215 return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
216 216
217 217 def has_gpg():
218 218 return matchoutput('gpg --version 2>&1', r'GnuPG')
219 219
220 220 def has_unix_permissions():
221 221 d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
222 222 try:
223 223 fname = os.path.join(d, 'foo')
224 224 for umask in (077, 007, 022):
225 225 os.umask(umask)
226 226 f = open(fname, 'w')
227 227 f.close()
228 228 mode = os.stat(fname).st_mode
229 229 os.unlink(fname)
230 230 if mode & 0777 != ~umask & 0666:
231 231 return False
232 232 return True
233 233 finally:
234 234 os.rmdir(d)
235 235
236 236 def has_pyflakes():
237 237 return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
238 238 r"<stdin>:1: 're' imported but unused",
239 239 True)
240 240
241 241 def has_pygments():
242 242 try:
243 243 import pygments
244 244 return True
245 245 except ImportError:
246 246 return False
247 247
248 248 def has_outer_repo():
249 249 # failing for other reasons than 'no repo' imply that there is a repo
250 250 return not matchoutput('hg root 2>&1',
251 251 r'abort: no repository found', True)
252 252
253 253 def has_ssl():
254 254 try:
255 255 import ssl
256 256 import OpenSSL
257 257 OpenSSL.SSL.Context
258 258 return True
259 259 except ImportError:
260 260 return False
261 261
262 262 def has_windows():
263 263 return os.name == 'nt'
264 264
265 265 def has_system_sh():
266 266 return os.name != 'nt'
267 267
268 268 def has_serve():
269 269 return os.name != 'nt' # gross approximation
270 270
271 271 def has_tic():
272 272 return matchoutput('test -x "`which tic`"', '')
273 273
274 274 def has_msys():
275 275 return os.getenv('MSYSTEM')
276 276
277 def has_aix():
278 return sys.platform.startswith("aix")
279
277 280 checks = {
278 281 "true": (lambda: True, "yak shaving"),
279 282 "false": (lambda: False, "nail clipper"),
280 283 "baz": (has_baz, "GNU Arch baz client"),
281 284 "bzr": (has_bzr, "Canonical's Bazaar client"),
282 285 "bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"),
283 286 "cacheable": (has_cacheable_fs, "cacheable filesystem"),
284 287 "cvs": (has_cvs, "cvs client/server"),
285 288 "cvs112": (has_cvs112, "cvs client/server >= 1.12"),
286 289 "darcs": (has_darcs, "darcs client"),
287 290 "docutils": (has_docutils, "Docutils text processing library"),
288 291 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
289 292 "execbit": (has_executablebit, "executable bit"),
290 293 "fifo": (has_fifo, "named pipes"),
291 294 "gettext": (has_gettext, "GNU Gettext (msgfmt)"),
292 295 "git": (has_git, "git command line client"),
293 296 "gpg": (has_gpg, "gpg client"),
294 297 "hardlink": (has_hardlink, "hardlinks"),
295 298 "icasefs": (has_icasefs, "case insensitive file system"),
296 299 "inotify": (has_inotify, "inotify extension support"),
297 300 "killdaemons": (has_killdaemons, 'killdaemons.py support'),
298 301 "lsprof": (has_lsprof, "python lsprof module"),
299 302 "mtn": (has_mtn, "monotone client (>= 1.0)"),
300 303 "outer-repo": (has_outer_repo, "outer repo"),
301 304 "p4": (has_p4, "Perforce server and client"),
302 305 "pyflakes": (has_pyflakes, "Pyflakes python linter"),
303 306 "pygments": (has_pygments, "Pygments source highlighting library"),
304 307 "serve": (has_serve, "platform and python can manage 'hg serve -d'"),
305 308 "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"),
306 309 "svn": (has_svn, "subversion client and admin tools"),
307 310 "svn13": (has_svn13, "subversion client and admin tools >= 1.3"),
308 311 "svn15": (has_svn15, "subversion client and admin tools >= 1.5"),
309 312 "svn-bindings": (has_svn_bindings, "subversion python bindings"),
310 313 "symlink": (has_symlink, "symbolic links"),
311 314 "system-sh": (has_system_sh, "system() uses sh"),
312 315 "tic": (has_tic, "terminfo compiler"),
313 316 "tla": (has_tla, "GNU Arch tla client"),
314 317 "unix-permissions": (has_unix_permissions, "unix-style permissions"),
315 318 "windows": (has_windows, "Windows"),
316 319 "msys": (has_msys, "Windows with MSYS"),
320 "aix": (has_aix, "AIX"),
317 321 }
@@ -1,62 +1,63 b''
1 1 ------ Test dirstate._dirs refcounting
2 2
3 3 $ hg init t
4 4 $ cd t
5 5 $ mkdir -p a/b/c/d
6 6 $ touch a/b/c/d/x
7 7 $ touch a/b/c/d/y
8 8 $ touch a/b/c/d/z
9 9 $ hg ci -Am m
10 10 adding a/b/c/d/x
11 11 adding a/b/c/d/y
12 12 adding a/b/c/d/z
13 13 $ hg mv a z
14 14 moving a/b/c/d/x to z/b/c/d/x (glob)
15 15 moving a/b/c/d/y to z/b/c/d/y (glob)
16 16 moving a/b/c/d/z to z/b/c/d/z (glob)
17 17
18 18 Test name collisions
19 19
20 20 $ rm z/b/c/d/x
21 21 $ mkdir z/b/c/d/x
22 22 $ touch z/b/c/d/x/y
23 23 $ hg add z/b/c/d/x/y
24 24 abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
25 25 [255]
26 26 $ rm -rf z/b/c/d
27 27 $ touch z/b/c/d
28 28 $ hg add z/b/c/d
29 29 abort: directory 'z/b/c/d' already in dirstate
30 30 [255]
31 31
32 32 $ cd ..
33 33
34 34 Issue1790: dirstate entry locked into unset if file mtime is set into
35 35 the future
36 36
37 37 Prepare test repo:
38 38
39 39 $ hg init u
40 40 $ cd u
41 41 $ echo a > a
42 42 $ hg add
43 43 adding a
44 44 $ hg ci -m1
45 45
46 46 Set mtime of a into the future:
47 47
48 48 $ touch -t 202101011200 a
49 49
50 50 Status must not set a's entry to unset (issue1790):
51 51
52 52 $ hg status
53 53 $ hg debugstate
54 54 n 644 2 2021-01-01 12:00:00 a
55 55
56 56 Test modulo storage/comparison of absurd dates:
57 57
58 #if no-aix
58 59 $ touch -t 195001011200 a
59 60 $ hg st
60 61 $ hg debugstate
61 62 n 644 2 2018-01-19 15:14:08 a
62
63 #endif
General Comments 0
You need to be logged in to leave comments. Login now