您好我有一个简单的pyQt文本编辑器,
基本上我想添加mercurial支持
我在其他编辑中看到了支持多种DVCS(Mercurial,GIT,Bazaar等)的能力,它们使用户能够执行提交,更新等功能
我真的想知道我在pyQt文本编辑器中集成mercurial的方式/方式,以便它的行为或多或少与其他花哨的编辑器一样。
有关如何完成此任务的任何好的教程/指南
答案 0 :(得分:1)
There are no tutorials around this, generally however there are three approaches:
Mercurials command line interface is considered stable. That means that you can expect Mercurial without extensions to not change the output of a command. Using "-T json" for most commands will also result in an easily parsable Json output. This approach is robust and fairly easy to implement as you only have to call out to Mercurial and parse the json back. Most standard commands like commit
, log
, etc should be implementable using this
Mercurial is offering hglib. A library that is available in C and Python which allows you to interface with Mercurial via a local protocol. Mercurial will be started in server mode and you use the library to interact. This approach is also very stable, offers a better abstraction, but relies on the command server being available and implies potential API changes in the library. Note that you also have to take the license of the library into account as you are linking against them.
Python processes can embedd Mercurial directly by important the right modules. However the Mercurial API is internally not stable and subject to continuous change. This option offers you the most flexibility as you have access to everything, including low-level parsing of datastructures, exposing of hidden functionality such as obsolence markers. The drawbacks are: 1. you have to know what to do otherwise you might corrupt the repository 2. the api changes all the time 3. you are subject to the GPL license.