2011-11-16 37 views
0

我剛安裝了這個「checkfiles」插件,它有一個語法錯誤。我不知道Python,但我已經嘗試了一些東西,但無法弄清楚。我想知道是否有人可以偷看,看看有沒有什麼突出的。這是下面的代碼的最後一行:python mercurial插件中的語法錯誤

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: %s\n' % ' '.join(self.checked_exts)) 

    self.ui.debug('checkfiles: ignored extensions: %s\n' % ' '.join(self.ignored_exts)) 
    self.ui.debug('checkfiles: ignored files: %s\n' % ' '.join(self.ignored_files)) 
    self.ui.debug('checkfiles: check diffs only: %r\n' % self.check_diffs) 
    self.ui.debug('checkfiles: use spaces: %r\n' % 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/mercurial-extensions/checkfiles/checkfiles.py導入擴展checkfiles:無效的語法(checkfiles.py,線120)

+0

操作系統,操作系統版本,Python版本? – delnan

+0

Linux ...但不確定Python版本 – Webnet

回答

4

最後一行是正確的現代Python。 它包含一個在Python 2.5中添加的條件表達式。 所以,我認爲你的Hg必須運行Python 2.4或更早的版本。

0

替換線120

self.files = ctx and ctx.files() or [] 

這是Python 2.4兼容的方式做

self.files = ctx.files() if ctx else []