简体   繁体   English

如何在Mercurial中的hg日志中获取修改后的文件列表及其修订?

[英]How to get modified files list along with their revision in hg log in Mercurial?

My idea is, starting from a repo with multiple revs, to obtain the list of revisions, along with the {matching-file-patterns} that have changed in each of them. 我的想法是,从具有多个版本的仓库开始,获取版本列表以及每个版本中都已更改的{matching-file-patterns}。

The objective is, with that data, to obtain the number of times each .CPP and .H file has changed, and additional data as date, user who changed the file, ... to track more thoroughly the progress of the project. 目的是利用该数据来获取每个.CPP和.H文件已更改的次数,以及作为日期的其他数据(更改该文件的用户),以便更彻底地跟踪项目的进度。

hg log --template "revision:{rev}\nfiles:\n{files % '  {file}\n'}"

The above will accomplish partially my claim (along with piping the output to a .txt file and parsing it externally), but I still find interesting to pre-filter the results, this is, that the hg log only shows .CPP and .H files, for example. 上面的内容将部分满足我的要求(连同将输出传递到.txt文件并在外部进行解析),但是我仍然发现对结果进行预过滤很有趣,即hg日志仅显示.CPP和.H文件。

I have looked into it, and the option "set: * .cpp or * .h" would do, but 我已经研究过了,可以使用选项“ set:* .cpp或* .h”,但是

hg log "set: **.cpp or **.h" --template "revision:{rev}\nfiles:\n{files % '  {file}\n'}"

will not make filtering of any type. 不会进行任何类型的过滤。

Any advice/solution is welcome in this task, even in the main task which is to automate the report! 欢迎在此任务中提供任何建议/解决方案,即使是主要任务是使报告自动化! (I am totally sure there is an easier way to accomplish it) (我完全确定有一种更简单的方法可以完成此操作)

Thank you. 谢谢。

  1. Use revsets, not filesets in log command 在日志命令中使用修订集,而不是文件集
  2. Use simpler template: your template output nothing in my tests (after relevant editing of conditions), but --template "{rev} {author}\\n" show list of revisions 使用更简单的模板:您的模板在我的测试中(对条件的相关编辑后)不输出任何内容,但是--template "{rev} {author}\\n"显示修订列表

Revset will be -r "file('**.cpp') + file('**.h')" Revset将是-r "file('**.cpp') + file('**.h')"

Edit 编辑

Implemented log with fileset, for my repo and files 带有文件集的已实现日志,用于我的仓库和文件

>hg log "set: **.txt or **.png" --template "{rev}:{node|short} {author|user} {date|isodate}\n{files % '  {file}\n'"

For some reason construction \\nfiles:\\n{files % ' {file}\\n' didn't not work, but without static text can be used. 由于某些原因, \\nfiles:\\n{files % ' {file}\\n'无效,但可以使用没有静态文本的结构。

Output of log 日志输出

6:e0670b3704b4 lazybadger 2012-06-24 15:20 +0600
  functions.php
  readme.txt
  screenshot.png
  style.css
5:1c722f4facda lazybadger 2012-02-07 07:56 +0600
  readme.txt
  sidebar.php
  style.css
4:630f5c2e836a lazybadger 2012-01-09 22:33 +0600
  comments.php
  functions.php
  header.php
  readme.txt
  sidebar.php
  style.css
3:168c55fc758d lazybadger 2011-12-14 04:01 +0600
  footer.php
  functions.php
  header.php
  readme.txt
  search.php
  style.css
0:f4413f649a23 lazybadger 2011-08-06 01:13 +0600
  404.php
  archive.php
  archives.php
  comments.php
  footer.php
  functions.php
  header.php
  html5.js
  image.php
  index.php
  license.txt
  links.php
  page.php
  screenshot.png
  search.php
  sidebar.php
  single.php
  style.css

Pay attention to filelists for changesets - they include all types of files, not only needed types 注意变更集的文件列表-它们包括所有类型的文件,而不仅仅是所需的类型

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

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