获取Mercurial中文件列表中每个文件的最后提交 [英] Get last commit for every file of a file list in Mercurial

查看:59
本文介绍了获取Mercurial中文件列表中每个文件的最后提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个hg信息库,我想知道sources/php/dracca/endpoint/wiki/**/Wiki*.php

I have an hg repository and I would like to know the last commit date of every file in sources/php/dracca/endpoint/wiki/**/Wiki*.php

到目前为止,我有这支班轮:

So far, I have this one liner:

find sources/php/dracca/endpoint/wiki/ -name "Wiki*.php" -exec hg log --limit 1 --template "{date|shortdate}" {} \; -exec echo {} \;

但是,这似乎非常慢,因为(我想)find每个文件进行1次hg调用,从而导致15秒的计算时间(例如,我在其中的约40个文件)...

But this seems utterly slow as (I suppose) find makes 1 hg call per file, leading to 15seconds of computation for the (say) ~40 files I have in there...

有更快的方法吗?

此命令的输出如下:

2019-09-20 sources/php/dracca/endpoint/wiki/characters/colmarr/WikiCharactersColmarrEndpoint.php
2019-09-20 sources/php/dracca/endpoint/wiki/characters/dracquints/allgroup/WikiCharactersDracquintsAllgroupEndpoint.php
...

如果需要,它可能会有所更改(例如,我不介意先设置1个日期,然后再更改该日期的文件列表,或者类似的内容)

It might be changed a bit if needed (I won't mind having, say, 1 date and then the list of files changed for that date, or whatever like this)

推荐答案

  1. 即使使用find + exec,您也可以使用修改后的模板{date|shortdate}\n缩短(最后一个exec)链.
  2. 您可以从 2012年的代码现在将无法正常工作
  1. Even with find+exec you can have shorter (by one last exec) chain with modified template {date|shortdate}\n
  2. You can use (accepted) perl-ism from this question or ask anybody to update mentioned lof extension to current Mercurial (code from 2012 will not work now)

替代品(肮脏的丑陋骇客)

在任何情况下,您只能调用一次hg并对结果进行一些后处理.

In any case, you can|have to call hg only once and perform some post-processing of results.

在使用这些技巧之前,请先阅读hg help filesets并为您的文件获得一个通用文件集(我想,可以是,只是set:sources/php/dracca/endpoint/wiki/**/Wiki*.php却是TBT!)

Before these trick, read hg help filesets and get one common fileset for your files (I suppose, it can be just set:sources/php/dracca/endpoint/wiki/**/Wiki*.php but TBT!)

之后,您可以:

  • 像这样执行汞日志

  • Perform hg log like this

hg日志设置.* --template"{files%'{file} {rev} {date | shortdate} \ n'}"

hg log setup.* --template "{files % '{file} {rev} {date|shortdate}\n'}"

(我使用了简单的模式进行测试,您必须拥有自己的文件集)

(I used simple pattern for test, you have to have own fileset)

以这种形式获取输出

setup.py 1163 2018-11-07
README.md 1162 2018-11-07
setup.py 1162 2018-11-07
hggit/git_handler.py 1124 2018-05-01
setup.py 1124 2018-05-01
setup.cfg 1118 2017-11-27
setup.py 1117 2017-11-27
hggit/git2hg.py 1111 2017-11-27
hggit/overlay.py 1111 2017-11-27
setup.py 1111 2017-11-27
…

(有一些不需要的意外文件,因为我修订了所有文件,这会影响感兴趣的文件,而没有过滤器).您只需要grep需要的文件,按cols 1 + 2排序,并使用每个文件的最新修订日期

(there are some unwanted unexpected files, because I out all files in revision, which affect file in interest, without filter). You have to grep only needed files, sort by cols 1+2 and use date of latest revision of each file

  • 使用hg grep.对于上述测试模式

hg grep. -I设置.* --files-with-matches -d -q

hg grep "." -I setup.* --files-with-matches -d -q

(查找所有更改,仅输出文件名和修订版,短日期)

(find any changes, output only filename+revision, short date)

您会得到类似

setup.py:1163:2018-11-07
setup.cfg:1118:2017-11-27

第3栏将是您所需的文件最后修改日期

and 3-rd column will be your needed last modification date of file

这篇关于获取Mercurial中文件列表中每个文件的最后提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆