hg标签和hg书签有什么区别?

发布于 2024-10-25 12:21:22 字数 264 浏览 1 评论 0原文

标签标签 之间有什么区别? 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苦行僧 2024-11-01 12:21:22

让我们将您的存储库视为“选择您自己的冒险书籍”,具有不同的观点。

  • 标签就像编辑在您的手稿上盖上的印章,表示“好吧,我们会保留您当前工作的痕迹,以防发生糟糕的情况。”
  • 一个命名分支将是一个章节。你必须在某一时刻选择你要写哪一章,而它们就会留下来。有些会合并回来,有些会结束(抱歉,你死了。)
  • 书签就是一个书签。当您阅读(提交)这本书时,它会跟随您。它可以帮助您记录“您当时正在阅读的内容”,以便您可以删除它们,将它们移动到不同的“章节”。当您共享图书(推送)时,您通常不会共享您的书签,除非您明确想要这样做。因此,您通常在匿名分支上使用它们,因为它们的生命周期比命名分支短。

Lets consider your repository as a "choose your own adventure books", with different points of view.

  • A tag is like a stamp that the editor put on your manuscript to say "ok, we keep a trace of your current work, in case shit happens."
  • A named branch would be a chapter. You have to choose at one point which chapter you'll have to write, and they are there to stay. Some will merge back, some will end (sorry, you died.)
  • A bookmark is, well, a bookmark. It follows you while you're reading (committing) the book. It helps you to keep tracks of "what you were reading at that time", so you can remove them, move them to a different "chapter". When you share the book (push), you usually don't share your bookmarks, unless you explicitly want to. So you usually use them on anonymous branches because their life cycle is shorter than named branches.
谎言月老 2024-11-01 12:21:22

当您需要助记符 (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.

逆光下的微笑 2024-11-01 12:21:22

实际上有五个概念可以使用:

  • 标签
  • 本地标签
  • 书签
  • 轻量级分支
  • 命名分支

轻量级分支是如果您只使用 Mercurial 就会发生的情况。当您更改内容并移动历史记录时,您的存储库历史记录会分叉,有时会合并。

其他四种是注释轻量级分支和组成它们的变更集的方法。

命名分支和标签是仅限 Mercurial 的概念,其中分支名称和标签实际上是通过对存储库进行更多提交来记录在存储库中的。它们往往会以不一定明显的方式传播到其他存储库。

本地标签和书签更像 git 所说的标签和分支。它们是元数据,而不是与版本化对象混合在一起。因此它们不代表存储库历史记录的一部分。它们往往位于您的存储库本地,并且不会传播,除非您故意传播它们。

至少我认为它们都是这样工作的。在每天使用 Mercurial 大约十二个月后,我还没有真正掌握它的模型。如果有人比我更了解,请随时编辑此答案,使其正确。


我在实践中如何实际使用这些东西。

我正在与大约 20 个人一起开发一个共享存储库。我在自己的私有存储库中进行了许多实验和轻量级分支,这些分支从未被推送到我们的主中央存储库。有时,一旦实验成功,我就会修改主线并将变更集推送到中央存储库,从中它会找到通往其他人的机器的方式。

如果同事对 Mercurial 的工作原理感到满意,我偶尔会向他们推送一些变更集。但有些人有点害怕它,并且更喜欢我向他们发送差异,以便他们可以应用补丁。

对于我希望是短暂且私密的实验,我只是让轻量级分支在可能的地方发生,并记住发生了什么。如果我感觉自己的记忆在某个已经存在了一段时间的树枝上消失了,我就会把它加入书签。

我使用本地标签来标记我可能想有一天返回的修订。它们使有趣的过去状态更容易找到。

我自己几乎从不制作非本地标签或命名分支(除非偶然,如果这样做我就会销毁它们)。但我们的发布人员却这么做了。我们发布的主要版本都有自己的主线命名分支,次要版本在这些分支上有标签。这确保了这些重要的分支和标签对每个人来说都是一样的。

再说一次,我不知道这是否是人们应该使用 Mercurial 的方式,但它似乎是一个适合我们团队规模的模型。

如果我们三四个人想要合作进行一项实验,那么这可能值得一个命名分支,我们可能会在我们之间共享该分支,但不会推送到中央存储库。我不知道效果如何!

There are actually five concepts to play with:

  • tags
  • local tags
  • bookmarks
  • lightweight branches
  • named branches

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!

许一世地老天荒 2024-11-01 12:21:22

最大的区别是,当您提交时,书签会自动向前移动。下面是一个示例:

hg init
..edit a file..
hg commit -m 'my commit' # creates revision 0
hg tag -r 0 mytag     # creates revision 1
hg bookmark -r 0 mybookmark   # doesn't create a revision
hg update 0   # get back to r0
..edit a file..
hg commit -m 'another commit'  # creates revision 2

此时 mytag 仍然指向修订版 0,而 mybookmark 现在指向修订版 2。此外,标记创建了变更集,而书签则没有。

当然,书签还创建了修订版

The biggest difference is that a bookmark is automatically moved forward when you commit. Here's an example:

hg init
..edit a file..
hg commit -m 'my commit' # creates revision 0
hg tag -r 0 mytag     # creates revision 1
hg bookmark -r 0 mybookmark   # doesn't create a revision
hg update 0   # get back to r0
..edit a file..
hg commit -m 'another commit'  # creates revision 2

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文