我刚刚安装了这个"checkfiles"插件,它有一个语法错误。我不懂Python,但我尝试了一些东西,还是搞不懂。我想知道有没有人能帮我看一下,看看有没有什么特别的。它是下面代码的最后一行:
if self.opt_all:
self.check_diffs = False
if self.checked_exts == '""':
self.ui.debug('checkfiles: checked extensions: (all text files)n')
else:
self.ui.debug('checkfiles: checked extensions: %sn' % ' '.join(self.checked_exts))
self.ui.debug('checkfiles: ignored extensions: %sn' % ' '.join(self.ignored_exts))
self.ui.debug('checkfiles: ignored files: %sn' % ' '.join(self.ignored_files))
self.ui.debug('checkfiles: check diffs only: %rn' % self.check_diffs)
self.ui.debug('checkfiles: use spaces: %rn' % self.use_spaces)
if ctx:
self.set_changectx(ctx)
def set_changectx(self, ctx):
self.ctx = ctx
if self.opt_all:
modified, added, removed, deleted, unknown, ignored, clean = self.repo.status(clean=True)
self.files = modified + added + clean # we can't get filecontext for unknown files
else:
self.files = ctx.files() if ctx else [] #THIS IS LINE 120
*从/scripts/mercurly -extensions/checkfiles/checkfiles.py导入扩展名检查文件失败:invalid syntax (checkfiles.py, line 120)
最后一行是正确的现代Python。它包含一个在Python 2.5中添加的条件表达式。所以,我认为你的Hg必须运行Python 2.4或更早。
用
代替第120行self.files = ctx and ctx.files() or []
是Python 2.4兼容的
方式self.files = ctx.files() if ctx else []