Mercurial > hg
annotate contrib/casesmash.py @ 44923:1f114c797961 stable
rebase: avoid clobbering wdir() with --dry-run or --confirm (issue6291)
See 56d3e0b499df for the source of adding originalwd to the list of things that
cause wdir to be updated. That change didn't come with tests, and attempts to
recreate the scenario described have thus far failed.
Differential Revision: https://phab.mercurial-scm.org/D8489
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 30 Apr 2020 00:33:00 -0400 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
28351
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
1 from __future__ import absolute_import |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
2 import __builtin__ |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
3 import os |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28351
diff
changeset
|
4 from mercurial import util |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28351
diff
changeset
|
5 |
14730 | 6 |
7 def lowerwrap(scope, funcname): | |
8 f = getattr(scope, funcname) | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28351
diff
changeset
|
9 |
14730 | 10 def wrap(fname, *args, **kwargs): |
11 d, base = os.path.split(fname) | |
12 try: | |
13 files = os.listdir(d or '.') | |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19322
diff
changeset
|
14 except OSError: |
14730 | 15 files = [] |
16 if base in files: | |
17 return f(fname, *args, **kwargs) | |
18 for fn in files: | |
19 if fn.lower() == base.lower(): | |
20 return f(os.path.join(d, fn), *args, **kwargs) | |
21 return f(fname, *args, **kwargs) | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28351
diff
changeset
|
22 |
14730 | 23 scope.__dict__[funcname] = wrap |
24 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28351
diff
changeset
|
25 |
14730 | 26 def normcase(path): |
27 return path.lower() | |
28 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28351
diff
changeset
|
29 |
14730 | 30 os.path.normcase = normcase |
31 | |
32 for f in 'file open'.split(): | |
33 lowerwrap(__builtin__, f) | |
34 | |
35 for f in "chmod chown open lstat stat remove unlink".split(): | |
36 lowerwrap(os, f) | |
37 | |
38 for f in "exists lexists".split(): | |
39 lowerwrap(os.path, f) | |
40 | |
41 lowerwrap(util, 'posixfile') |