Mercurial - determine where file was removed?

£可爱£侵袭症+ 提交于 2020-01-12 03:10:08

问题


If you do hg log myfile -v you see a list of changesets that the file was modified in.

In our case, in the most recent changeset, the file was removed. But you can't tell this by looking at the verbose (-v) output of hg log. Is there an easy Mercurial command you can use to determine if and when a file has been removed from the repo?


Update: Note that this is on a Windows client, and we are using Mercurial v 1.4.3

Update 2: Appears the answers below would work with a more recent version of Mercurial, however an upgrade isn't in the cards right now. Any other ideas for v 1.4.3 ???


回答1:


You can check which revision deleted a file (any many other interesting features) using revsets:

hg log -r 'removes(<myfile>)'

Some examples:

hg log -r 'removes(build.xml)' // where build.xml used to be in the current directory

hg log -r 'removes("**/build.xml")' // where build.xml may have been in sub directories

See hg help revsets for details.




回答2:


The --removed flag should get you what you are looking for:

hg log myfile -v --removed

From the help for hg log:

    --removed              include revisions where files were removed



回答3:


This is what I use to list all the deleted files in my repository:

hg log --template "{rev}: {file_dels}\n" | grep -v ':\s*$'


来源:https://stackoverflow.com/questions/5419668/mercurial-determine-where-file-was-removed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!