hg标签和hg书签有什么区别?
标签 和 标签 之间有什么区别? Mercurial-scm.org/wiki/BookmarksExtension" rel="noreferrer">书签 在 Mercurial 中?我似乎找不到任何关于两者有何不同的讨论。
What's the difference between a tag and a bookmark in Mercurial? I can't seem to find any discussion of how the two differ.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
让我们将您的存储库视为“选择您自己的冒险书籍”,具有不同的观点。
Lets consider your repository as a "choose your own adventure books", with different points of view.
当您需要助记符 (foo_feature) 来指向随着工作进展而变化的提交 ID 时,可以使用书签。它们比常规的 Mercurial 分支更轻量级,并且有点类似于 git 分支的工作方式。
标签通常指向固定的提交 ID。可以手动重新分配它们,但不鼓励这样做。
Bookmarks are used when you want a mnemonic (foo_feature) that points to a changing commit id as your work progresses. They're more light-weight that regular Mercurial branches, and somewhat similar to the way git branches work.
Tags generally point to fixed commit ids. They can be reassigned manually, but this is discouraged.
实际上有五个概念可以使用:
轻量级分支是如果您只使用 Mercurial 就会发生的情况。当您更改内容并移动历史记录时,您的存储库历史记录会分叉,有时会合并。
其他四种是注释轻量级分支和组成它们的变更集的方法。
命名分支和标签是仅限 Mercurial 的概念,其中分支名称和标签实际上是通过对存储库进行更多提交来记录在存储库中的。它们往往会以不一定明显的方式传播到其他存储库。
本地标签和书签更像 git 所说的标签和分支。它们是元数据,而不是与版本化对象混合在一起。因此它们不代表存储库历史记录的一部分。它们往往位于您的存储库本地,并且不会传播,除非您故意传播它们。
至少我认为它们都是这样工作的。在每天使用 Mercurial 大约十二个月后,我还没有真正掌握它的模型。如果有人比我更了解,请随时编辑此答案,使其正确。
我在实践中如何实际使用这些东西。
我正在与大约 20 个人一起开发一个共享存储库。我在自己的私有存储库中进行了许多实验和轻量级分支,这些分支从未被推送到我们的主中央存储库。有时,一旦实验成功,我就会修改主线并将变更集推送到中央存储库,从中它会找到通往其他人的机器的方式。
如果同事对 Mercurial 的工作原理感到满意,我偶尔会向他们推送一些变更集。但有些人有点害怕它,并且更喜欢我向他们发送差异,以便他们可以应用补丁。
对于我希望是短暂且私密的实验,我只是让轻量级分支在可能的地方发生,并记住发生了什么。如果我感觉自己的记忆在某个已经存在了一段时间的树枝上消失了,我就会把它加入书签。
我使用本地标签来标记我可能想有一天返回的修订。它们使有趣的过去状态更容易找到。
我自己几乎从不制作非本地标签或命名分支(除非偶然,如果这样做我就会销毁它们)。但我们的发布人员却这么做了。我们发布的主要版本都有自己的主线命名分支,次要版本在这些分支上有标签。这确保了这些重要的分支和标签对每个人来说都是一样的。
再说一次,我不知道这是否是人们应该使用 Mercurial 的方式,但它似乎是一个适合我们团队规模的模型。
如果我们三四个人想要合作进行一项实验,那么这可能值得一个命名分支,我们可能会在我们之间共享该分支,但不会推送到中央存储库。我不知道效果如何!
There are actually five concepts to play with:
Lightweight branches are what happens if you just use mercurial. Your repository history forks and sometimes merges as you change things and move around your history.
The other four are ways of annotating lightweight branches and the changesets that make them up.
named branches and tags are mercurial-only concepts where the branch names and tags actually get recorded in the repository by making more commits to the repository. They'll tend to propagate to other repositories in ways which are not necessarily obvious.
local tags and bookmarks are much more like what git calls tags and branches. They're metadata rather than being mixed in with the versioned objects. So they're not represented as part of the repository history. They tend to be local to your repository, and won't propagate unless you propagate them deliberately.
At least I think that's how they all work. After about twelve months of using mercurial daily I haven't really got to grips with its model(s). If anyone knows better than me then feel free to edit this answer so it's correct.
How I actually use these things in practice.
I'm working on a single shared repository with about 20 other people. I make many experiments and lightweight branches in my own private repository, which never get pushed to our main central repository. Occasionally once an experiment has worked out I'll modify the main line and push a changeset into the central repository, from which it will find its way to everyone else's machine.
I'll occasionally push some changesets to a co-worker if they're one of the people who's comfy with how mercurial works. But several people are a bit scared of it and prefer if I send them diffs that they can apply with patch.
For experiments I expect to be short lived and private, I just let lightweight branches happen where they may, and remember what's going on. If I feel my memory slipping about a twig that's been around for a bit, I bookmark it.
I use local tags to mark revisions I might like to come back to one day. They make interesting past states easier to find.
I myself almost never make non-local tags or named branches (except by accident, and I destroy them if I do). But our release people do. Our released major versions all have their own named branches off from the main line, and minor versions have tags on those branches. That ensures that these important branches and tags look the same to everyone.
Again, I've no idea whether this is how one's supposed to use mercurial, but it seems to be a model that works well for our size of team.
If three or four of us wanted to collaborate on an experiment, that would probably be worth a named branch, which we'd probably share between ourselves but not push to the central repo. I don't know how well that would work out!
最大的区别是,当您提交时,书签会自动向前移动。下面是一个示例:
此时 mytag 仍然指向修订版 0,而 mybookmark 现在指向修订版 2。此外,标记创建了变更集,而书签则没有。
当然,书签还创建了修订版
The biggest difference is that a bookmark is automatically moved forward when you commit. Here's an example:
At that point mytag is still pointing to revision 0 and mybookmark is now pointing at revision 2. Also the tagging created a changeset and the bookmark didn't.
Also, of course, the bookmark created a revisio