如何获取Mercurial存储库中每个文件的最新修订号列表? [英] How to get a list of the latest revision number for each file in a Mercurial repository?

查看:96
本文介绍了如何获取Mercurial存储库中每个文件的最新修订号列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的Web应用程序制作了一个构建系统,该系统正在重写所有资源url,以包括文件的修订号(以改善客户端缓存).从今天起,我为每个文件运行此命令以获取修订号:

I have made a build system for my web application that's rewriting all resource url's to include the file's revision number (to improve client caching). As of today I'm running this command for each file to get the revision number:

hg log --template '{rev}\n' path-to-file

对每个文件执行hg是非常耗时的.有没有一种快速的方法来列出存储库中具有最新修订号的所有文件?

Executing hg for each file is really time consuming. Is there a fast way to list all files in a repository with the latest revision number?

推荐答案

可以做到这一点,但是请参见上面我的评论,为什么在工作流中的任何地方都使用它可能不是一个好主意.在清单上,您应该使用修订哈希而不是数字,因为在克隆上该数字不会改变.同样,这并不是非常有效,但是至少只有两个进程实例化,而不是每个文件一个:

This will do it, but please see my comment above as to why using this anywhere in your workflow is probably a bad idea. At the very list you should be using the revision hash not the number, since that doesn't change on clone. Also this isn't terribly efficient, but at least it's only two process instantiations instead of one per file:

hg grep --all '.' | perl -na -F: -e 'next unless ($F[2] eq "+"); print "$F[0] $F[1]\n" unless ($prev eq $F[0]); $prev = $F[0]'

示例:

that 3
file 1

这篇关于如何获取Mercurial存储库中每个文件的最新修订号列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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