中的“ui”参数是什么hgnested.nclone公司()?

2024-10-03 21:26:03 发布

您现在位置:Python中文网/ 问答频道 /正文

import hgnested

sour = "C:\Users\ADMIN\Documents\mercurial\hgserver"

desti = "D:\Work"
hgnested.nclone(source = sour, dest = desti)

在这里,我试图克隆一个嵌套的存储库“hgserver”,其中还有5个存储库。但我有一个错误

TypeError: nclone() takes at least 2 arguments (2 given)

然后,我在link处查看了python的hgnested包的源代码,发现nclone()方法接受了一个参数“ui”,我不知道该传递什么。你知道吗

def nclone(ui, source, dest=None, **opts):

有人能帮我吗。你知道吗

注:由于我的声誉低,我无法添加这个问题的相关标签。例如:hgnested,nclone


Tags: importuisourceadmin错误usersmercurialdocuments
2条回答
import hgnested
from mercurial import ui
sour = "C:\Users\ADMIN\Documents\mercurial\hgserver"

desti = "D:\Work"
hgnested.nclone(ui.ui(), source = sour, dest = desti)

正如@abccd所回答的,我只需将我的方法调用更改为上线,克隆就成功了。你知道吗

如果要将文件从本地驱动器克隆到本地驱动器或从本地驱动器克隆到本地驱动器,则这不是您想要的。当我阅读他们的“文档”时,几行没什么,这只是Mercurial的一个小扩展。如果您只想复制一个目录,您应该这样做:

import shutil 
shutil.copytree(sour, desti) # copy dirs 
# use shutil.copy() to copy files

为了回答您最初的问题,ui是Mercurial的用户界面类。你知道吗

Here, ui and repo are the user interface and repository arguments passed into an extension function as standard (see WritingExtensions for more details). If you are not calling the Mercurial command functions from an extension, you will need to create suitable ui and repo objects yourself. The ui object can be instantiated from the ui class in mercurial.ui; the repo object can either be a localrepository, a httprepository, an sshrepository or a statichttprepository (each defined in their own modules), though it will most often be a localrepository.

相关问题 更多 >