在vc操作后恢复修改时间 [英] Restore modification times after vc operations

查看:148
本文介绍了在vc操作后恢复修改时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

制造纯粹是时间戳导向的:如果一个源比它的目标更早,目标就会被重建。这可能会导致在大型应用程序中进行长时间的重新编译,如果有人执行一些主要的版本控制绕行。



让我给你一个例子。假设我有一个尚未合并的旧功能分支,我想看看它是如何实现的。因此,从master开始,我将检出该分支,然后将master合并到该分支中,然后进行编译。一切都很好,如果功能很小,那么与主控的差异也应该很小。除了如果特性分支真的老了,我还没解决,然后在文件系统中重新进行了很多修改。



作为第二个例子,您可以想象将大部分的代码,同时寻找一些超出git pickaxe但不需要重新编译代码的复杂条件。当我找到我要找的东西后,我应该回到我的主分支。但是在两者之间,如果二等分窗口足够大,许多文件可能已被修改。



所以我想知道的是:是否有某种工具会允许我预先记录修改时间的快照,并为通过这些操作恢复内容的文件恢复m次。当然,我必须明确地告诉它完成时间,因为整个过程中文件可能会发生变化。



我猜我我正在寻找一种与git集成的工具,因为对于一个通用工具,拍摄大型源代码树的快照也需要相当长的时间,所以它必须能够跟踪文件在被修改时的情况,例如使用一些钩子。另一方面,如果 git status 也必须检查每个文件的内容,那么通用工具的成本可能并不高。



是否有这样的工具,或者我必须自己写一个工具?

请注意用原始创建/修改时间戳来检出旧文件看起来并不是我想要的,并且在任何情况下都会花费太长时间。

解决方案

找不到合适的工具,我写了我自己的工具。事实证明,这比我想象的要难,主要是因为散列所有这些文件的内容比我想象的要便宜,至少在热文件系统缓存中是这样。


Make is purely timestamp-oriented: if a source is older than its target, the target gets rebuilt. This can cause long recompilations in big applications if one does some major version control detour.

Let me give you an example. Suppose I have an old feature branch which didn't get merged yet, and I want to see how it's doing. So starting from master, I would checkout that branch, then merge master into it, then compile. All very fine, and if the feature was small, then differences vs. master should be small as well. Except that if the feature branch was really old, I undid and then redid a lot of modifications in the file system.

As a second example, you might imagine bisecting large portions of code while looking for some complicated condition which is beyond git pickaxe but which does not require recompiling the code. After I found what I was looking for, I should be back at my master branch. But in between, many files might have been modified if the bisection window was large enough.

So what I'd like to know is this: is there some tool which would allow me to take a snapshot of modification times up front, and restore the mtimes for those files whose content was restored by these operations. Of course I'd have to tell it explicitely when I'm done, since the whole point of this is that the files may get changed in between.

I guess I'm looking for a tool which integrates with git, because for a generic tool, taking snapshots of a big source tree would also take considerable time, so it would have to be something which can keep track of files as they get modified, e.g. using some hook. On the other hand, if git status has to check the content of every file as well, then maybe the cost of a generic tool isn't that high.

Is there such a tool, or would I have to write one myself?

Note that Checking out old file WITH original create/modified timestamps does not seem exactly what I want, and would take too long in any case.

解决方案

Finding no suitable tool, I ended up writing my own tool. It turned out to be less difficult than I thought, mostly because hashing the content of all these files was less expensive than I thought, at least with hot file system caches.

这篇关于在vc操作后恢复修改时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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