标签: mercurial-extension

使用Mercurial API获取给定变更集对存储库的更改

如何使用Mercurial API确定每个变更集对存储库所做的更改?我可以获得与特定修订版相关的文件列表,但是我无法弄清楚如何知道该文件发生了什么。

我如何回答变更集中每个文件的这些问题:

  • 是否添加了?
  • 它被删除了吗?
  • 修改了吗?

文件上下文中是否有一个属性可以告诉我(如果是这样,我找不到它),或者有其他方法可以解决这个问题?

这是我的代码:

def index(request):
    u = ui.ui()
    repo = hg.repository(ui.ui(), '/path/to/repo')
    changes = repo.changelog
    changesets = []

    for change in changes:
        ctx = repo.changectx(change)
        fileCtxs = []
        for aFile in ctx.files():
            if aFile in ctx:
                for status in repo.status(None, ctx.node()):
                    # I'm hoping this could return A, M, D, ? etc
                    fileCtxs.append(status)

        changeset = {
            'files':ctx.files(),
            'rev':str(ctx.rev()),
            'desc':ctx.description(),
            'user':ctx.user(),
            'filectxs':fileCtxs,
        }
        changesets.append(changeset)

    c = Context({
        'changesets': changesets,
    })

    tmplt = loader.get_template('web/index.html')
    return HttpResponse(tmplt.render(c))
Run Code Online (Sandbox Code Playgroud)

python mercurial dvcs changeset mercurial-extension

5
推荐指数
1
解决办法
3155
查看次数

Mercurial Extension没有/默认选项

说我想要一个我可以按如下方式执行的扩展: hg sayhi

我尝试了以下内容,但它告诉我有无效的参数:

def sayhi(ui, repo, node, **opts):    
  """Says Hello"""
  ui.write("hi")

cmdtable = {                     
    "sayhi":  (sayhi, [], '')
}
Run Code Online (Sandbox Code Playgroud)

似乎无论我做什么,我都需要给它一个选项hg sayhi s.反正有没有这样做?

python mercurial-extension

5
推荐指数
1
解决办法
252
查看次数

如何配置Mercurial不提交特定的配置文件?

我的团队正在转向Mercurial.我们的项目都有一个配置文件(web.config或app.config,以及一些bat文件 - 我们是一个C#商店).这些文件必须是存储库的一部分.当开发人员克隆存储库时,需要对其配置文件进行本地更改才能使其正常工作.例如,项目的配置文件可能需要连接字符串到开发人员的数据库,或其他特定于环境的信息.我们不希望这些更改最终存储在存储库中.我们不时会对这些需要进入存储库并分发给团队并最终分发给客户的配置进行更改.

我们配置或使用Mercurial的最简单方法是什么,以便这些文件不会被意外提交?我希望被迫明确提交这些文件,但是来自repo的合并会自动降级到更新中.

这必须是其他人面临的问题,但作为Mercurial的新手,我们都不知道最好的解决方案.

编辑:

一个类似的问题,可能会分享一些常见的解决方案,但与此问题不同,可以在以下位置找到:条件Mercurial忽略文件

如果其他问题可能提供您正在寻找的答案,我会将此包括在内.

mercurial mercurial-extension

5
推荐指数
1
解决办法
832
查看次数

如何为Merkins作为Jenkins的一部分指定身份验证信息?(mercurial_keyring)

我在Mercurial存储库中获得了代码(使用自签名证书保护),我正在尝试设置Jenkins以使用它.

我已经在Jenkins中安装了Mercurial插件(指向在Jenkins服务器/从服务器上安装TortoiseHg)并且Jenkins Job已正确配置为从存储库中获取源代码.

当我手动构建(即通过Web界面)时,一切都按预期工作.

但是,看起来存储库的轮询不成功,因为我得到类似于以下的输出:

Started on Apr 27, 2012 1:07:41 PM
[<jobname>] $ hg pull --rev default
warning: <MercurialServerIP> certificate with fingerprint e3:5f:5e:ea:4f:da:ef:a4:0b:4a:bb:00:e8:31:59:de:ce:d0:28:94 not verified (check hostfingerprints or web.cacerts config setting)
abort: mercurial_keyring: http authorization required but program used in non-interactive mode
[<jobname>] $ hg log --style <workspace>\<jobname>\tmp688470509422797505style --branch default --no-merges --prune 65d180b20a1e625841c8385709c86b83c3e10421
Done. Took 1.9 sec
No changes
Run Code Online (Sandbox Code Playgroud)

我之前已经完成了存储库的手动克隆,以便我能够输入用户的密码来使用Mercurial密钥环扩展来进行授权,但是根据错误输出,它似乎并没有被应用.

如何配置Jenkins或运行构建的计算机成功进行轮询?

mercurial mercurial-extension jenkins

5
推荐指数
1
解决办法
4839
查看次数

使用Python编写Mercurial(hg)扩展性能测试的方法

我为Mercurial编写了一个扩展,例如hg dosomthing --rev 5,我想知道编写性能测试用例的正确方法是什么,以便从执行到结束时监视扩展的性能!

钽:)

mercurial python-2.7 mercurial-extension

5
推荐指数
1
解决办法
76
查看次数

如何将“hg amend”与 HgGit 一起使用以避免“未知修订”错误

每当我使用hg amend或其他更改历史记录的命令(例如hg rebase -s ... -d ...)时,某些命令(包括hg push开始)会失败并出现abort: unknown revision错误:

$ hg push -B my-branch
pushing to git+ssh://git@github.com:...
searching for changes
abort: unknown revision 'xxxxx'!
Run Code Online (Sandbox Code Playgroud)

git mercurial rebase mercurial-extension mercurial-amend

5
推荐指数
1
解决办法
55
查看次数

在mercurial中,如何只查看一组修订的标签而不是全部?

hg tags 总是显示所有标签,那么我怎样才能获得指向特定修订及其所有祖先的标签?

真实世界的用例是,如果我使用本地标签来指定变更集上的功能(或错误修复),我需要找出累积的功能/错误直到特定的转速.

一种解决方案是添加一个将"-r"添加到的包装器命令tags.那么实现它的最佳方法是什么?使用revsets获取所有祖先转速并过滤标签?

mercurial mercurial-extension

4
推荐指数
1
解决办法
271
查看次数

如何从mercurial存储库中安全地禁用/删除largefiles目录?

在过去,我一直在使用mercurial中的largefiles扩展来将数据与我一直在处理的代码一起保存.我认为这是一个错误,我想删除"largefiles"目录(8GB).我们的网络用户目录限制为10 GB,我需要空间.我很久没有使用任何大文件了.当他们永远消失时,我不会想念他们.

所以我的问题是

  1. 我可以删除.hg下的largefiles目录而不损坏repo吗?
  2. 如果我这样做,即使丢失了一些大型数据文件,我能否查看旧代码?
  3. 我应该从该repo的所有克隆中删除这些文件,以避免再次使用来自另一个克隆的largefiles污染所有repos吗?

version-control mercurial large-files mercurial-extension

4
推荐指数
1
解决办法
3128
查看次数

在Hg扩展中重载pull命令

我正在尝试调试Mercurial扩展.此扩展添加了一些应在执行时执行的代码pull.原作者通过更改存储库对象的类来设置此挂钩.

这是相关代码(实际上是一个有效的Mercurial扩展):

def reposetup(ui, repo):
    class myrepo(repo.__class__):
        def pull(self, remote, heads=None, force=False):
            print "pull called"
            return super(myrepo, self).pull(remote, heads, force)

    print "reposetup called"
    if repo.local():
        print "repo is local"
        repo.__class__ = myrepo
Run Code Online (Sandbox Code Playgroud)

hg pull启用此扩展时执行a 时,输出如下:

# hg pull
reposetup called
repo is local
pulling from ssh://hgbox/myrepo
reposetup called
searching for changes
no changes found
Run Code Online (Sandbox Code Playgroud)

这是在pull命令中注入扩展代码的合理方法吗?为什么从未达到"拉叫"声明?

我在Windows 7上使用Mercurial 3.4.1和python 2.7.5.

python mercurial mercurial-extension

4
推荐指数
1
解决办法
205
查看次数

3
推荐指数
1
解决办法
189
查看次数