擅长:python、mysql、java
<p>确实没有正式的API,但是您可以通过阅读其他扩展,特别是与hg捆绑在一起的扩展,了解最佳实践。对于这个特殊的问题,我会这样做:</p>
<pre><code>from mercurial import ui, hg
from mercurial.node import hex
repo = hg.repository('/path/to/repo/root', ui.ui())
fctx = repo.filectx('/path/to/file', 'tip')
hexnode = hex(fctx.node())
</code></pre>
<p><strong>更新</strong>在某个时刻,参数顺序发生了更改,现在如下所示:</p>
<pre><code> repo = hg.repository(ui.ui(), '/path/to/repo/root' )
</code></pre>