简体   繁体   English

如何将DVCS集成到python应用程序中

[英]How to integrate DVCS in a python application

Hi I have a simple pyQt text editor, 嗨,我有一个简单的pyQt文本编辑器,

Essentially I want to add mercurial support 本质上我想增加支持

I have seen in various other editors the ability to support a number of DVCS (Mercurial, GIT,Bazaar, etc), and they give the user the ability to perform functions like commit,update, etc 我在其他各种编辑器中都看到了支持许多DVCS(Mercurial,GIT,Bazaar等)的能力,并且它们使用户能够执行诸如commit,update等功能。

I really want to know what/how I can integrate mercurial in my pyQt text editor, so that it behaves more or less like other fancy Editors. 我真的很想知道我可以/如何在我的pyQt文本编辑器中集成mercurial,以便它或多或少像其他高级编辑器一样工作。

Any good tutorials/guides on how to get this done 有关如何完成此操作的任何好的教程/指南

There are no tutorials around this, generally however there are three approaches: 没有关于此的教程,但是通常有三种方法:

Command line interface 命令行界面

Mercurials command line interface is considered stable. Mercurials命令行界面被认为是稳定的。 That means that you can expect Mercurial without extensions to not change the output of a command. 这意味着您可以预期不带扩展名的Mercurial不会更改命令的输出。 Using "-T json" for most commands will also result in an easily parsable Json output. 对于大多数命令使用“ -T json”也将导致易于解析的Json输出。 This approach is robust and fairly easy to implement as you only have to call out to Mercurial and parse the json back. 这种方法是健壮的,并且相当容易实现,因为您只需调用Mercurial并解析回json。 Most standard commands like commit , log , etc should be implementable using this 大多数标准命令(例如commitlog等)都可以使用此命令实现

hglib hglib

Mercurial is offering hglib. Mercurial提供了hglib。 A library that is available in C and Python which allows you to interface with Mercurial via a local protocol. CPython中提供了一个库,该库允许您通过本地协议与Mercurial交互。 Mercurial will be started in server mode and you use the library to interact. Mercurial将在服务器模式下启动,并且您可以使用库进行交互。 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. 这种方法也非常稳定,提供了更好的抽象,但是依赖于可用的命令服务器,并且暗示了库中可能的API更改。 Note that you also have to take the license of the library into account as you are linking against them. 请注意,与它们链接时,还必须考虑库的许可证。

Embedding Mercurial 嵌入水银

Python processes can embedd Mercurial directly by important the right modules. Python进程可以通过重要的正确模块直接嵌入Mercurial。 However the Mercurial API is internally not stable and subject to continuous change. 但是,Mercurial API在内部不稳定,并且会不断变化。 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. 缺点是:1.您必须知道该怎么做,否则您可能会破坏存储库2. API一直在更改3.您必须遵守GPL许可证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM