在 Team Foundation Server 中实际使用 Mercurial?
我的店使用TFS &除了缺乏本地存储库提交/恢复之外,总体上对它感到满意。我开始自己在本地使用 Mercurial 来帮助管理较小的更改块,然后将它们发布到 TFS。我看到 Subversion 有一个“桥接”组件,如果中央 VCS 是 Subversion,它可以自动启用此功能。我还没有找到适合团队系统的。这让我感到鼓舞,因为其他人已经走上了将 DVCS 与 CVCS 系统集成的道路。
(1) 有谁知道吗?我有点怀疑(快速搜索没有找到任何东西)。
(2) 有人这样使用Mercurial/TFS吗?如果有,能否分享一下您的经验。我特别希望了解在通过 Mercurial 进行重大活动后提交 TFS 时可能会出现哪些不明显的问题。
到目前为止,这似乎是一个完全的双赢,只有我使用 if 几天——但我知道足够多的信息,认为这就是那么简单。
My shop uses TFS & is generally happy with it with the exception of the lack of local repository commits/reverts. I'm starting to use Mercurial locally myself to help manage smaller chunks of changes, then posting them to TFS. I see that Subversion has a 'bridge' component to automagically enable this if the central VCS is Subversion. I have not found one for Team System. This encourages me that other folks have gone down this path with integrating DVCS with CVCS systems.
(1) Does anyone know of one? I'm sort of doubting it (quick search didn't find anything).
(2) Is anyone using Mercurial/TFS in this manner? If so, can you share your experiences. I'm particularly looking for any insights into what issues might come up that aren't obvious regarding commits to TFS after significant activity via Mercurial.
It seems like a total win-win so far with just me using if for a few days--but I know enough then to think it's just that easy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我做了很好的尝试让它发挥作用。我可以让 Git 和 TFS 一起使用 (链接)通过 svnbridge,但我无法通过 svnbridge 让 Mercurial 工作,这让我沮丧不已。如果你设法让它工作,请告诉我,因为我个人更喜欢 Mercurial 而不是 git (尽管两者都很棒)
I had a good try at getting it working. I could get Git and TFS playing together (link) via svnbridge, but I couldn't get mercurial to work via svnbridge which frustrated me no end. If you manage to get it working let me know, because I personally prefer mercurial over git (though both are great)
不确定这是否是您还不知道的事情,但我已经在本地使用 Mercurial 一段时间了,到目前为止,我认为其好处超过了管理两个源代码控制系统的额外开销。以下是我一直在做的事情:
我将我的 TFS 签出到了 HG 存储库,我认为它是我的“主人”。我从 TFS 获取更新并将它们提交到此存储库,因此这包含来自 TFS 的项目的最新状态。这里重要的是,没有任何独立于 TFS 更新或 Hg 合并(这是第 2 部分)的更改
任何时候我需要进行更改,我都会克隆我的“主”存储库并完成我的工作那里。我发现每个功能或故事的克隆实际上非常容易管理,而且感觉非常干净。一旦我完成了一项功能,我就会将 Hg 合并回“主”存储库,该存储库已应用所有 TFS 更新。这使我能够使用 Mercurials 合并功能,该功能远远优于 TFS,以至于让人质疑 TFS 如何声称可以合并代码。合并完成后,我将其提交到 Hg 中,然后将这些更改签入 TFS。最好的部分是,当我签入 TFS 时,我不必合并任何内容。非常非常好。
现在,以下是我使用此方法发现的问题:
最大的问题是 TFS 在查找更改方面很糟糕。有一个 make writable 插件,您可以使用它来使修改后的文件可写由 Mercurial 更新/合并。我为此找到了两种选择。您可以强制 TFS 脱机,此时它将假定需要检入任何可写的内容,或者您可以使用源代码管理工具中的比较工具并选择已更改的文件并单独检出它们。在我看来,两者都很糟糕
即使您从 hg 存储库中排除 TFS 源代码控制文件(您应该这样做),源代码控制绑定仍然存在于项目级别。在您将文件添加到解决方案之前,这一点并不完全明显,此时它会尝试将其添加到源代码管理中。您可以“撤消挂起的更改”并摆脱源代码控制添加,但这确实很烦人。
好消息是,我使用这种方法完成了相当大规模的合并,我认为如果我被迫使用 TFS 工具来完成此操作,我认为这会导致我转向某种形式的硬性药物。
我尚未将其应用于更新 TFS 中的分支,但我的猜测是,它会比为您在 TFS 中合并提供的选项要好得多。与此相关的是,由于您可以一次签入大量工作功能,因此使用 TFS 合并的问题会更少,因为一项功能所需的所有更改都将集中在一个位置。
我没有尝试解决的一件事是在整个团队中分享这一点。部分原因是这并不一定是整个团队的事情。我远程工作,因此拥有本地存储库非常重要,并且可以节省大量时间。我的开发团队的其他成员可能会也可能不会从这种方法中获得相同的好处,但我发现我可以在不影响他们工作方式的情况下非常酷。
更新
一段时间以来,我一直想根据评论和我使用大型 TFS 存储库的一些经验来更新此回复,并提供更多信息。
首先,正如 @Eric Hexter 在评论中指出的,您可以利用 rebase 扩展,以更好地将工作存储库中的提交集成到主 TFS 存储库中。不过,根据您希望提交在 TFS 中显示的方式,您可能需要使用折叠扩展< /a> 将您的更改压缩为单个提交(这可以使 TFS 中的回滚更容易)。还有来自 TFS PowerTools 的“在线”命令可以使让 TFS 知道发生了什么变化的工作变得更容易(再次感谢 Eric 在他的 博客文章)
现在,当我最初写这篇文章时,我是我正在开发一个项目,该项目只有一个供开发人员使用的 TFS 分支,而且规模相当小,因此克隆存储库并不是什么大问题。后来我发现自己正在从事一个项目,该项目的存储库在签出后大约有 1.5GB,在构建后更大,并且经常涉及在 TFS 中的分支之间切换。显然,这种方法不太适合这种环境(特别是因为在某一时刻不可能在任意目录中构建解决方案。
大小问题最好通过利用类似于 git 主题分支的技术来解决,而不是将存储库克隆到新的我认为最好的选择实际上是使用 书签扩展< /a> 并创建主题“书签”而不是主题分支。您也可以使用命名分支,但它们有一个轻微的缺点,即它是永久性的,并且可以与您可能做的任何克隆一起旅行(如果您想分享您漂亮的 TFS-)。 Hg 与同事混合)书签位于您的存储库本地,并有效地指向提交并与头部一起旅行,以便它们可以在 Hg 期望修订的任何地方使用(因此合并、更新、您可以使用它们创建一个 TFS 书签作为您的主要“分支”,该“分支”仅从 TFS 获取更新,并从主题工作合并,每个书签都有自己的书签,一旦您提交回,您就可以将其删除。 TFS。如果您更愿意使用命名分支,那么您可以应用完全相同的技术,这很方便。
现在,多分支问题更加棘手,特别是因为 TFS“分支”实际上是原始分支中每个文件的副本,这意味着每次从 TFS 拉入分支时,您的存储库都会变得更大。处理此问题的一种可能方法是使用命名的 Hg 分支和书签的组合,以便每个 TFS 分支都有一个分支,然后为这些分支的工作创建书签。这些场景中真正令人头痛的实际上是通过所有这些来处理 TFS 工作区。您可以删除工作区中的映射并走得很远,但是一旦您映射回工作目录,您就必须小心 TFS 对文件的破坏(这实际上是 TF PowerTools 派上用场的地方)。当你切换分支时,试图保持工作区的连接会很快变得丑陋。您的工具箱中最好有几个工具,包括 Hg 清除扩展 和TF PowerTools“烧焦”命令。两者都可以有效地删除不在版本控制中的文件(从技术上讲,“焦化”确保 TFS 和您的本地工作目录匹配,因此它也可以更新文件)。
但对我来说,这个过程变得相当繁重并且容易出错。我最近转而使用 git 和 git-tfs,因为它为我管理 TFS 工作区,并消除了与该方相关的很多负担。遗憾的是,似乎没有任何地方有“hg-tfs”,否则我可能会选择它。
Not sure if this is anything you don't already know, but I've been using mercurial locally for a little while now, and so far I think the benefits are outweighing the added overhead of managing the two source control systems. Here is how I've been doing things:
I made my TFS checkout an HG repository which I consider my "master". I get updates from TFS and commit them to this repo, so this contains the most current state of the project from TFS. The important thing here is that there are no changes to this made independent of a TFS update or an Hg merge (which is part 2)
Anytime I need to make a change, I clone my "master" repo and do my work there. I've found that a clone per feature or story is actually pretty easy to manage, and feels pretty clean. Once I complete a feature, I do an Hg merge back to the "master" repo, which has had all of the TFS updates applied. This allows me to use Mercurials merge capabilities, which are so far superior to TFS as to call into question how TFS can claim to merge code at all. Once the merge is complete, I commit it in Hg, and then check those changes into TFS. The best part of this is that when I do the checkin to TFS, I do not have to merge anything. Very, very nice.
Now, here are the issues I've found with this approach:
The biggest is the fact that TFS is lousy at finding changes. There is a make writable plugin which you can use to make the modified files writable when they are updated/merged by Mercurial. There are two options I have found for this. You can either force TFS to go offline, at which point it will assume anything writable needs to be checked in, or you can use the compare tool in the source control tool and select the changed files and individually check them out. Both are crappy IMO
The source control bindings are still there at the project level, even if you exclude the TFS source control files from your hg repository (which you should do). This isn't entirly obvious until you add a file to the solution, at which point it tries adding it to source control. You can "Undo Pending Changes" and get rid of the source control add, but it's really annoying.
The good news is that I used this approach to work through a rather massive merge which I think would have caused me to turn to some form of hard drugs had I been forced to use the TFS tools to do it.
I have not yet applied this to updating branches within TFS, but my guess would be that it would be much much better than the options you are given for merging in TFS. On a related note, since you can check in chunks of working functionality at one time, using the TFS merge would be less problematic just because all changes needed for a feature would be together in one place.
One thing I have not tried to tackle is sharing this across the entire team. Part of the reason is that it really doesn't have to be a team-wide thing. I work remotely, so having a local repository is a big deal, and saves a lot of time. The other members of my dev team may or may not get the same benefit from this approach, but I find it pretty cool that I can without effecting the way they work.
Update
I've been wanting to update this response for a while with additional info based on comments and some of my experiences working with large TFS repositories.
First as @Eric Hexter points out in the comments, you can utilize the rebase extension to better integrate commits from your work repositories into your main TFS repository. Though, depending on how you want your commits to appear to TFS you may want to use the collapse extension to squash your changes into a single commit (this can make rollbacks in TFS easier). There is also the "online" command from TFS PowerTools which can make the work of letting TFS know what has changed easier (thanks again to Eric for mentioning that in his blog post)
Now, when I originally wrote this I was working on a project that had only one TFS branch that developers were using, and was fairly small, so cloning repositories was no big deal. I later found myself working on a project that had a repo that was about 1.5GB after checkout, and much bigger after the build, and involved switching between branches in TFS quite often. Clearly this approach is not well suited to this environment (particularly since at one point it was impossible to build the solutions in an arbitrary directory.
The size problem is best handled by utilizing a technique similar to gits topic branches rather than cloning the repositories to new directories. There are a couple options for this. I think the best is actually to use the bookmark extension and create topic "bookmarks" rather than topic branches. You can use named branches as well, but they have the slight disadvantage of being permanent, and traveling with any clones you may do (if you want to share your nifty TFS-Hg hybrid with a colleague). Bookmarks are local to your repo, and effectively point to a commit and travel with the head. They are implemented so that they can be used in any place where Hg is expecting a revision (so merges, updates, etc). You can use these to create a TFS bookmark as your primary "branch" that only gets updates from TFS, and merges from the topic work, which would each have their own bookmarks, and you could delete once you have committed back to TFS. If you would rather use named branches, then you can apply exactly the same techniques, which is handy.
Now, the multiple branch problem is trickier, especially since TFS "branches" are actually copies of every file from the original branch, which means that each time you pull in branches from TFS, your repo is going to get that much bigger. One possible way to deal with this is use a combination of named Hg branches, and bookmarks, so that you have a branch for each TFS branch, and then create bookmarks for your work off of those branches. The real headache in these scenarios is actually dealing with TFS workspaces through all of this. You can remove the mappings in your workspaces and get pretty far, but once you map back to your working directory you've got to be careful of TFS stomping on files (this is actually where the TF PowerTools come in handy). Trying to leave the workspace attached while your switching branches around gets ugly quick. A couple tools that are nice to have in your toolbelt are the Hg purge extension and the TF PowerTools "scorch" command. Both effectivly remove files that are not in version control (technically "scorch" ensure TFS and your local working directory match, so it could update files as well).
For me, though, this process became quite burdensome and error prone. I've recently switched to useing git with git-tfs, since it manages TFS Workspaces for me, and removes a lot of the burden associated with that side. Sadly there does not appear to be an "hg-tfs" out there anywhere, or I would probably have chosen that.
如果您不沉迷于 Mercurial,我一直在使用一个很棒的 git/tfs 集成项目,称为 git-tfs。它与 git-svn 非常相似,但从 TFS 推送/拉取。请访问 http://github.com/spraints/git-tfs
If you're not stuck on mercurial, there is a sweet git/tfs integration project that I've been using called git-tfs. It's very similar to git-svn, but pushes/pulls from TFS instead. Check it out at http://github.com/spraints/git-tfs
@Eric,您的帖子 lostechies 非常有帮助。使用 VS2010,我必须将选项 /diff 和 /deletes 添加到推送脚本中的 tftp online 命令中,以更改和删除文件签入 TFS。最初,当文件被删除(从工作中)时,我收到推送错误,hg update 是
“无法删除FileXyz:访问被拒绝”。
我安装了 MakeWritable.py 扩展,但仅在打开文件而不是删除文件时才有效。因此,我添加了对 attrib 的调用,以从项目中的所有文件中删除只读,然后恢复它(不包括 .hg 文件夹)我还添加了 /diff 选项,以便通过 MD5 校验和来检测差异,而不是依赖于 READ-ONLY 属性。现在似乎工作正常。
我对以前从未使用过的 PowerShell 脚本有一些学习曲线。对于像我这样的其他人来说,脚本是使用如下快捷方式运行的:
我将推拉快捷方式放在任务栏上,因此只需单击一下即可将推拉快捷方式推入 TFS 或从 TFS 拉出
@Eric, your post at lostechies was most helpful. With VS2010 I had to add options /diff and /deletes to the tftp online command in the push script to get changed and deleted files to be checked in to TFS. Initially I was getting an error from push when a file has been deleted (from -working) that hg update is
"unable to remove FileXyz : access is denied".
I installed the MakeWritable.py extension but that only works when files are opened not deleted. So I added a call to attrib to remove the READ-ONLY from all files in the project and then restore it afterwards (excluding the .hg folder) I also added the /diff option so that differences are detected by MD5 checksum instead of depending on the READ-ONLY attribute. Seems to be working fine now.
I had a bit of a learning curve with PowerShell scripts which I hadn't used before. For others like me the scripts are run with a shortcut like this:
I put push and pull shortcuts on my task bar so push/pull to/from TFS is a single click
我知道有些人已经将 hgsubversion 与 Subversion 桥一起使用。我不知道它的效果如何,而且我从来没有使用过 TFS。
据我所知,没有比使用 TFS 更“原生”的桥了 ->颠覆桥 -> hgsubversion,但我也听说它工作得相当好。我对 TFS 的理解极其有限,表明它的内部模型应该与 Subversion 足够相似,这样 hgsubversion 之类的东西才能很好地工作。
I know that some people have used hgsubversion with the Subversion bridge. I don't know how well it worked, and I've never had to use TFS.
As far as I'm aware, there's no "more native" bridge than using TFS -> Subversion Bridge -> hgsubversion, but I've also heard that it works fairly well. My extremely limited understanding of TFS suggests that its internal model should be similar enough to Subversion for things like hgsubversion to work really well.
如果您希望能够使用 DVCS 和 TFS,我相信最好的方法是安装 SVNBridge 对于 TFS,并使用 Bazaar,据我所知,这是唯一可以轻松与 SVN 集成的 DVCS ,并且由于您的 TFS 现在看起来像 SVN,因此您神奇地获得了 Bazaar/TFS 集成
If you want to be able to work with a DVCS and TFS, I believe the best way is to install the SVNBridge for TFS, and the use Bazaar, which is, AFAIK the only DVCS that easily integrates with SVN, and since your TFS now looks like a SVN, you magically get Bazaar/TFS integration
这是我一直用来处理 TFS 和 TFS 的 powershell 脚本。汞。要使用,您需要在 TFS 文件夹中创建一个 hg 存储库(将 TFS 中的文件提交到其中),克隆此存储库并使用新存储库。一旦满意,您可以运行“hgtfs.ps1 Push”将更改从 Mercurial 存储库推送回 TFS。
hgtfs.ps1:
Here's a powershell script I've been using to work with TFS & hg. To use you'll need to create a hg repository in your TFS folder (commit the files from TFS into it), clone this repository and work on the new repository. Once happy you can run "hgtfs.ps1 push" to push the changes back into TFS from your mercurial repository.
hgtfs.ps1:
我只是组装了一个小工具,HgTfs,它试图实现同步 Mercurial 和 TFS 存储库的目标。它非常简单,只有三个命令:克隆、拉取和推送。这是我的 Bitbucket 存储库:
https://bitbucket.org/thepretender/hgtfs
还有一篇博客文章描述工作流程和使用场景(实际上,wiki 页面只是此博客条目的一部分):
http://www.olegtarasov.me/Post/2013/07/Mercurial-to-TFS-bridge-(hgtfs)
代码很hacky,但似乎得到工作完成了。我真的很感激任何反馈或叉子:)
I'he just put together a small tool, HgTfs, which tries to accomplish the goal of syncing Mercurial and TFS repositories. It's really simple and and has only three commands: clone, pull and push. Here is my Bitbucket repo:
https://bitbucket.org/thepretender/hgtfs
There is also a blog post describing the workflow and usage scenarios (actually, wiki pages are just parts of this blog entry):
http://www.olegtarasov.me/Post/2013/07/Mercurial-to-TFS-bridge-(hgtfs)
The code is hacky, but it seems to get the job done. I would really appreciate any feedback or forks :)