Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 31634:35738db2037a
debugfsinfo: improve case-sensitive testing
Previously the case-sensitive test was for the current directory, and is
fragile with errors, and could remove a real file called ".debugfsinfo".
This patch improves the case-sensitive testing so it test the given path
using a unique temporary file, and does not crash on errors.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sun, 26 Mar 2017 17:59:33 -0700 |
parents | 5b3d55a6821f |
children | 57a22f699179 |
comparison
equal
deleted
inserted
replaced
31633:5b3d55a6821f | 31634:35738db2037a |
---|---|
786 ui.write("%s\n" % f) | 786 ui.write("%s\n" % f) |
787 | 787 |
788 @command('debugfsinfo', [], _('[PATH]'), norepo=True) | 788 @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
789 def debugfsinfo(ui, path="."): | 789 def debugfsinfo(ui, path="."): |
790 """show information detected about current filesystem""" | 790 """show information detected about current filesystem""" |
791 util.writefile('.debugfsinfo', '') | |
792 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) | 791 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
793 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) | 792 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |
794 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) | 793 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
795 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) | 794 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
796 ui.write(('case-sensitive: %s\n') % (util.fscasesensitive('.debugfsinfo') | 795 casesensitive = '(unknown)' |
797 and 'yes' or 'no')) | 796 try: |
798 util.tryunlink('.debugfsinfo') | 797 with tempfile.NamedTemporaryFile(prefix='.debugfsinfo', dir=path) as f: |
798 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' | |
799 except OSError: | |
800 pass | |
801 ui.write(('case-sensitive: %s\n') % casesensitive) | |
799 | 802 |
800 @command('debuggetbundle', | 803 @command('debuggetbundle', |
801 [('H', 'head', [], _('id of head node'), _('ID')), | 804 [('H', 'head', [], _('id of head node'), _('ID')), |
802 ('C', 'common', [], _('id of common node'), _('ID')), | 805 ('C', 'common', [], _('id of common node'), _('ID')), |
803 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], | 806 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |