Refer to a mercurial revision relative to a named revision

空扰寡人 提交于 2019-12-06 22:56:54

问题


In git, you can do refer to revisions by something like master^^, meaning two revisions before master. Can you do the same in Mercurial in some way (or with some extension)? For example, if I want to do "the revision before tip", something like tip^.

edit: Rafa mentions hg parents which works for 1 level deep. How do I do it for arbitrary levels deep.


回答1:


For commands that have options to specify a revision, use -r -2 for the revision prior to the tip, -r -3 for the revision before that, etc.

From hg help revs:

A plain integer is treated as a revision number. Negative integers are treated as sequential offsets from the tip, with -1 denoting the tip, -2 denoting the revision prior to the tip, and so forth.

There is also the ParentrevspecExtension that allows you use syntax like: tip^ for the parent of tip, tip^^ for its parent, etc.




回答2:


As mentionned by Niall C., when the revisions are linear, it is possible to use the negative specification to go back starting at tip (only works with linear history, obviously).

Starting with Mercurial 1.6, there is something similar to Parentrevspec, but in core to designate complex revision specification: revsets.

For example, "p1(tip)" is the first parent of "tip", etc.




回答3:


You can do "hg parents -r revision"



来源:https://stackoverflow.com/questions/3547274/refer-to-a-mercurial-revision-relative-to-a-named-revision

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