简体   繁体   中英

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.

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.

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.

I have looked into it, and the option "set: * .cpp or * .h" would do, but

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

Revset will be -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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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