How to go back to a tag in darcs?

こ雲淡風輕ζ 提交于 2019-12-11 12:13:18

问题


I'd like to checkout an older tagged state in the current darcs repo (its working dir).

I don't want to clone to another directory (because I have setup a cabal sandbox in the current directory).

I have already pushed all new changes to a remote repo, so I don't really care whether the changes are completely lost locally. (But still: can't I keep the patches saved, but still checkout an older state?)

How to do this?

Attempts

I tried

darcs obliterate --from-tag=TAG

but that gave not exactly the result I wanted. This obliterated the tag, too!

So, to get TAG back, I had to darcs pull and select the first patch in the row (TAG), and press d to skip all other patches.

Well, darcs obliterate --from-tag=TAG did ask interactively what to obliterate, so I could theoretically leave TAG, but it starts asking from the most recent patch, so I had to go through many recent patches, before I could inform darcs of my decision to leave TAG.


回答1:


You can use the --reverse option to obliterate to ask about the tag first, say n to that and then a to unpull all the rest.

In fact obliterate --from-tag won't necessarily select everything not covered by the tag, as its behaviour depends on the specific order patches and tags are currently in the repository.

So after the first obliterate, I would do another one without the --from-tag and without --reverse. This time the tag will be offered first (as everything after it will be gone), you can say n to that, and then a to everything else - only patches that aren't covered by the tag will be offered after the tag is rejected.

In the relatively unlikely event that a lot of patches including another tag are caught by this, you may need to repeat this until it stops offering more patches.

On the topic of how to keep hold of the patches while moving back to an older state, the -o and -O options to obliterate allow you to save the patches that are removed to disk. You can then restore them later with 'darcs apply'. However you do need to be careful not to then amend any patches left in your local repository, or to obliterate other patches without keeping them, as that could make the saved patches inapplicable.



来源:https://stackoverflow.com/questions/29288356/how-to-go-back-to-a-tag-in-darcs

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