Mercurial > public > mercurial-scm > hg
comparison tests/test-verify-repo-operations.py @ 52008:cd788962c6d9 stable
tests: use shlex.quote instead of pipes.quote
The pipes module got removed in python 3.13.
https://bugs.debian.org/1084553
author | Julien Cristau <jcristau@debian.org> |
---|---|
date | Mon, 14 Oct 2024 16:46:25 +0200 |
parents | 53e9422a9b45 |
children | 5713adc51f2a |
comparison
equal
deleted
inserted
replaced
52006:37f693975cbc | 52008:cd788962c6d9 |
---|---|
34 sys.stderr.write("skipped: enum34 not installed" + os.linesep) | 34 sys.stderr.write("skipped: enum34 not installed" + os.linesep) |
35 sys.exit(80) | 35 sys.exit(80) |
36 | 36 |
37 import binascii | 37 import binascii |
38 from contextlib import contextmanager | 38 from contextlib import contextmanager |
39 import pipes | 39 import shlex |
40 import shutil | 40 import shutil |
41 import silenttestrunner | 41 import silenttestrunner |
42 import subprocess | 42 import subprocess |
43 | 43 |
44 from hypothesis.errors import HypothesisException | 44 from hypothesis.errors import HypothesisException |
265 # Section: Basic commands. | 265 # Section: Basic commands. |
266 def mkdirp(self, path): | 266 def mkdirp(self, path): |
267 if os.path.exists(path): | 267 if os.path.exists(path): |
268 return | 268 return |
269 self.log.append( | 269 self.log.append( |
270 "$ mkdir -p -- %s" % (pipes.quote(os.path.relpath(path)),) | 270 "$ mkdir -p -- %s" % (shlex.quote(os.path.relpath(path)),) |
271 ) | 271 ) |
272 os.makedirs(path) | 272 os.makedirs(path) |
273 | 273 |
274 def cd(self, path): | 274 def cd(self, path): |
275 path = os.path.relpath(path) | 275 path = os.path.relpath(path) |
276 if path == ".": | 276 if path == ".": |
277 return | 277 return |
278 os.chdir(path) | 278 os.chdir(path) |
279 self.log.append("$ cd -- %s" % (pipes.quote(path),)) | 279 self.log.append("$ cd -- %s" % (shlex.quote(path),)) |
280 | 280 |
281 def hg(self, *args): | 281 def hg(self, *args): |
282 extra_flags = [] | 282 extra_flags = [] |
283 for key, value in self.config.items(): | 283 for key, value in self.config.items(): |
284 extra_flags.append("--config") | 284 extra_flags.append("--config") |
285 extra_flags.append("%s=%s" % (key, value)) | 285 extra_flags.append("%s=%s" % (key, value)) |
286 self.command("hg", *(tuple(extra_flags) + args)) | 286 self.command("hg", *(tuple(extra_flags) + args)) |
287 | 287 |
288 def command(self, *args): | 288 def command(self, *args): |
289 self.log.append("$ " + ' '.join(map(pipes.quote, args))) | 289 self.log.append("$ " + ' '.join(map(shlex.quote, args))) |
290 subprocess.check_output(args, stderr=subprocess.STDOUT) | 290 subprocess.check_output(args, stderr=subprocess.STDOUT) |
291 | 291 |
292 # Section: Set up basic data | 292 # Section: Set up basic data |
293 # This section has no side effects but generates data that we will want | 293 # This section has no side effects but generates data that we will want |
294 # to use later. | 294 # to use later. |
353 "$ \"$PYTHON\" -c 'import binascii; " | 353 "$ \"$PYTHON\" -c 'import binascii; " |
354 "print(binascii.unhexlify(\"%s\"))' > %s" | 354 "print(binascii.unhexlify(\"%s\"))' > %s" |
355 ) | 355 ) |
356 % ( | 356 % ( |
357 binascii.hexlify(content), | 357 binascii.hexlify(content), |
358 pipes.quote(path), | 358 shlex.quote(path), |
359 ) | 359 ) |
360 ) | 360 ) |
361 | 361 |
362 @rule(path=paths) | 362 @rule(path=paths) |
363 def addpath(self, path): | 363 def addpath(self, path): |
403 command = ["commit"] | 403 command = ["commit"] |
404 errors = ["nothing changed"] | 404 errors = ["nothing changed"] |
405 if amend: | 405 if amend: |
406 errors.append("cannot amend public changesets") | 406 errors.append("cannot amend public changesets") |
407 command.append("--amend") | 407 command.append("--amend") |
408 command.append("-m" + pipes.quote(message)) | 408 command.append("-m" + shlex.quote(message)) |
409 if secret: | 409 if secret: |
410 command.append("--secret") | 410 command.append("--secret") |
411 if close_branch: | 411 if close_branch: |
412 command.append("--close-branch") | 412 command.append("--close-branch") |
413 errors.append("can only close branch heads") | 413 errors.append("can only close branch heads") |