把 Tortoise Hg 升級到 3.2.1 版(原本是 2.x),之前慣用的 exportfiles 套件就突然不能用了,錯誤訊息如下。

** Unknown exception encountered with possibly-broken third-party extension exportfiles
** which supports versions 2.2.2 of Mercurial.
** Please disable exportfiles and try your action again.
** If that fixes the bug please report it to https://bitbucket.org/albert_brand/
hgexportfiles/issues
** Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
** Mercurial Distributed SCM (version 3.2.1)
** 載入額外套件: exportfiles, extdiff, win32text
Traceback (most recent call last):
  File "hg", line 42, in <module>
  File "mercurial\dispatch.pyo", line 28, in run
  File "mercurial\dispatch.pyo", line 71, in dispatch
  File "mercurial\dispatch.pyo", line 140, in _runcatch
  File "mercurial\dispatch.pyo", line 850, in _dispatch
  File "mercurial\dispatch.pyo", line 611, in runcommand
  File "mercurial\dispatch.pyo", line 941, in _runcommand
  File "mercurial\dispatch.pyo", line 912, in checkargs
  File "mercurial\dispatch.pyo", line 847, in <lambda>
  File "mercurial\util.pyo", line 677, in check
  File "C:/TortoiseHg/extensions/exportfiles.py", line 81, in exportfiles
    first = rng[0]
TypeError: 'baseset' object does not support indexing

雖然在瀏覽 Hg Workbench 時,還是可以透過右鍵選單→「匯出」→「封存」,把指定版本與其前一次版本的差異檔案匯出,可是有時候我還是需要匯出連續多個版本之間的差異檔。(例如:想一口氣匯出第 10 版與第 5 版之間的差異檔案,如果用 exportfiles extension,就可以直接設定 From 5 to 10 來匯出全部的差異檔)

上網 Google 最後一行 TypeError 錯誤訊息,很幸運的是,這貌似是 Mericurial extension 的常見錯誤,在 "TypeError on newer versions of Mercurial" 這篇裡建議修改 Python 檔。

原來的程式碼:

first = rng[0]
last = rng[-1]

改成這樣:

if hasattr(rng, 'first'):
    first = rng.first()
    last = rng.last()
else:
    first = rng[0]
    last = rng[-1]

再重新載入套件,讓 *.pyo 檔重新產生,就可以囉。 

 

 

 

arrow
arrow

    小攻城師 發表在 痞客邦 留言(1) 人氣()