一个 Mercurial 存储库中的多个 Eclipse 项目

发布于 2024-10-13 11:07:48 字数 1139 浏览 3 评论 0原文

我有许多 Eclipse 项目,我想将它们放在两个单独的 hg 存储库中。

我已经成功地做到了这一点,首先使用 TortouiseHg 创建两个 hg 存储库,然后添加、提交我的项目到每个存储库。通过这样做,我现在有两个 hg 存储库,每个存储库中有两个项目。

接下来,我使用 MercurialEclipse 在 Eclipse 中克隆该存储库。这些项目在 Eclipse 中按预期显示。

示例 1:

Eclipse workspace
               |
               |--Project 1
               |--Project 2
               |--Project 3
               |--Project 4

但是如果我查看目录结构,它看起来像这样:

示例 2:

  c:-- 
     |
     |-workspace
               |
               hgRepository1
               |           |--.hg
               |           |--Project 1
               |           |--Project 2
               |
               |
               hgRepository2
                           |--.hg
                           |--Project 3
                           |--Project 4

当我希望它看起来像这样时。

示例 3:

  c:-- 
     |
     |-workspace
               |--.hg
               |--Project 1
               |--Project 2
               |--Project 3
               |--Project 4

是否可以拥有一个 Mercurial 存储库并以某种方式克隆它,并使项目直接出现在工作区目录下,而不是出现在子目录中?

I have a number of eclipse projects that I'd like to have in two separate hg repositories.

I've managed to do this by first creating the two hg repository using TortouiseHg and adding, committing my projects to each of the repositories first. By doing that I now have two hg repositories with two projects in each.

Next I clone that repositories in Eclipse using MercurialEclipse. The projects appear as expected in Eclipse.

Example 1:

Eclipse workspace
               |
               |--Project 1
               |--Project 2
               |--Project 3
               |--Project 4

But if I look in the directory structure it looks like this:

Example 2:

  c:-- 
     |
     |-workspace
               |
               hgRepository1
               |           |--.hg
               |           |--Project 1
               |           |--Project 2
               |
               |
               hgRepository2
                           |--.hg
                           |--Project 3
                           |--Project 4

when I want it to look like this.

Example 3:

  c:-- 
     |
     |-workspace
               |--.hg
               |--Project 1
               |--Project 2
               |--Project 3
               |--Project 4

Is it possible to have a single Mercurial repository and somehow clone it and have the projects appear directly under workspace directory, and not in a subdirectory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

誰ツ都不明白 2024-10-20 11:07:48

您不应从 Eclipse 工作区保存项目,也不应在 Eclipse 工作区中恢复它们。
这些项目(.project.classpath其他项目特定资源)应该位于 Eclipse 工作区之外的自己的目录中(然后导入到工作区)。

这样,任何目录结构都可以将不同的项目导入到新的 Eclipse 工作区中。

You shouldn't save project from an Eclipse workspace, or restore them in an Eclipse workspace.
Those projects (.project, .classpath, and other project specific resources) should be in their own directory, outside of the Eclipse workspace (and then imported into the workspace).

That way, any directory structure will be fine for importing the different project into a new Eclipse workspace.

一片旧的回忆 2024-10-20 11:07:48

我自己就遇到了这个问题,而且解决方案并不是立即显而易见的。这篇博客文章有分步说明,展示了如何实现您所追求的目标:工作流程:使用 HgEclipse (Mercurial) 创建并初始化多项目存储库

简而言之,您想要:

  • 打开 Mercurial View 并在 /path/to/workspace/projects-folder 创建一个新存储库
  • 创建您需要的任意数量的新项目,每个项目都应在 / 的(非默认)位置创建路径/到/工作区/项目文件夹/项目名称。

您会发现最终在 Eclipse 中得到了您想要的布局,并且所有项目都将共享位于项目文件夹中的存储库。

I ran into this exact problem myself, and the solution isn't immediately obvious. This blog post has step-by-step instructions showing how to achieve what you're after: workflow: create and init multi-project repositories with HgEclipse (Mercurial).

In short, you want to:

  • Open the Mercurial View and create a new repository at /path/to/workspace/projects-folder
  • Create however many new projects you need, each one should be created at the (non-default) location of /path/to/workspace/projects-folder/project name.

You'll find you end up with the layout you want in Eclipse and the projects will all share the repository located in projects-folder.

别念他 2024-10-20 11:07:48

我不太明白。您无法将存储库克隆到其自身内部。为什么不能直接制作 Project1 和 Project2 的硬拷贝,创建 3 和 4?

I don't quite understand. You cannot clone the repo to inside of itself. Why can't you just make a hard copy of Project1 and Project2, creating 3 and 4?

原来是傀儡 2024-10-20 11:07:48

我知道有些人不喜欢我的解决方案(而且我知道自从提出这个问题以来已经有一段时间了),但它是:

  1. 像往常一样创建工作区
  2. 从 Eclipse 退出(不确定是否有必要,但它不会造成伤害)执行此操作)
  3. 使用 hg 直接在创建的工作区目录中克隆 Mercurial 存储库(如果存储库的名称与工作区相同,这会有所帮助)
  4. 返回 Eclipse 并为每个子目录创建一个新项目(在您的示例中)可能是项目 1、项目 2,等等)。它会警告您该目录已经存在,但没关系。
  5. MercurialEclipse 应该将每个项目识别为 Mercurial 版本控制。

这已在 Linux 上的 Eclipse 的 CDT 中成功测试。我建议您将 Eclipse 创建的文件放入 .hgignore 中来管理您的项目。

我希望这有帮助。

I know some people wont like my solution (and I know that it's been some time since this question has been asked) but here it is:

  1. Create the workspace as usual
  2. Exit from Eclipse (not sure if it is necessary but it doesn't harm to do it)
  3. Clone your Mercurial repository directly in the created workspace directory with hg (it helps if the name of your repository is the same as the workspace)
  4. Go back to Eclipse and create a new project for each sub-directory (in your example it would be Project 1, Project 2, etc.). It will warn you that the directory already exists but it's ok.
  5. MercurialEclipse should recognize each project as being Mercurial version controlled

This has been tested successfully in CDT in Eclipse on linux. And I advise you to put in your .hgignore the files created by Eclipse to manage your projects.

I hope this helps.

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