1

Assume that there is a file under hg version control. I have a particular version of that file, and I would like to find out in which revision this file was in this version.

I suspect that there are two possible ways to do this.

  1. Do hg update in a loop and diff the file against subsequent versions (sloooow, but should work).

  2. Make Mercurial put the rev number in a, say, comment in the second line of the file right before committing. From what I have read, a precommit hook might be of use. Then I don't have to compare anything, just look at the file itself (I'm assuming no-one will change this, of course, but this is rather safe assumption in my case).

My use case is a joint paper, written in LaTeX, with two coauthors who have no idea about version control at all, but I prefer to use it (for obvious reasons). We communicate by email, and there's effectively a human-based lock system ("I will not work on this file until you send me the next version, ok?"). The only problem that arises is that I'm sending version X to author B to proofread, then author C sends me a corrected version Y and I commit it into my repo, then author B sends his corrections Z (to version X) and I'm starting to get lost-but I can check the attachment in the email sent to B, and I only need to find out which revision it is.

So, my question is: which of the two ideas above would be better, or maybe there's yet another one to help me deal with this mess?

4

2 回答 2

6

hg archive未来工作的好方法,但我可以建议至少 3 种替代工作方式和 1 种修正 find-correct-version 和更新

未来的工作

  • 您可以为共同作者使用单独的命名分支,为合并结果使用默认分支,始终从他的分支发送共同作者,在得到更正后更新他的分支(您将永远知道,发送了)并将分支合并为默认

  • 一个分支,用书签标记的同事修订版,稍后您将其移至下一点

  • Mercurial关键字以某种方式被认为是“最后手段”,但在您的情况下,这是显而易见且可用的解决方案:只需在文件中添加带有哈希ID的关键字(默认扩展名而不是钩子 - 更容易和更可靠)

当前状态

要使用文件源查找变更集,您可以尝试使用bisect示例)并在 test-script、fe、文件的 CRC 中进行测试(您需要未版本化文件的 CRC,检查历史版本的文件)

于 2012-09-18T22:49:28.300 回答
1

如果您乐于找到您发送给审阅者的电子邮件,为什么不将修订哈希与文件一起包含在其中?

您可以通过使用 生成附件,以几乎零额外的工作量获得此hg archive文件,这将创建一个文件,其中包含 1) 供审查的文件,以及 2) .hg_archival.txt,并带有修订哈希。

尽管如果没有更优雅的方式我会感到惊讶,即使您的合作者坚决反对使用版本控制。

于 2012-09-18T20:56:42.257 回答