当包名称不同时,如何在分支之间进行合并?

发布于 2024-12-21 01:00:39 字数 1004 浏览 0 评论 0原文

我想知道是否有一种简单的方法可以在包名称(以及目录名称)不同的同一 Android 项目的分支之间进行合并。由于我将有许多分支,并且所有分支都需要保持最新,因此我正在寻找有效地进行这些合并的最佳方法。

我们的Android项目的目录树如下所示

\assets
\libs\...
\res\...
\src\com\mycompany\mainproject
AndroidManifest.xml
build.xml
myproject.iml
myproject.ipr

当我们为客户端制作定制版本时,我会更改包名称,例如client1app或client2app。如果它们要作为不同客户端的不同应用程序存在于 Android Market 中,则需要不同的包名称。因此,我创建了单独的分支,其中包含相同的文件名和目录结构,但 src 文件夹名称除外,必须更改该名称以匹配包名称。因此 client1app 或 client2app 将具有以下目录结构:

\src\com\mycompany\client1app
\src\com\mycompany\client2app

这些文件夹下的文件名仍然与 mainproject 相同。只是目录名称不同而已。 (除了 package 子句外,文件内容基本相同。)

我们使用 SVN 进行源代码控制。因此,当我从 mainproject 挑选合并到 client1app 时,我想我必须首先合并顶级文件和其他目录,然后手动将 src\com\mycompany\mainproject 合并到 src\com\mycompany\client1app。这是五个不同的合并(对于顶级目录和四个子目录)。如果不是目录名称不同,这将是一个简单的单步合并,我知道如何做到这一点。

问题 1:是否有任何配置可以告诉 SVN \src\com\mycompany\mainproject 和 \src\com\mycompany\client1app 在合并时包含相同的文件名?或者有其他方法可以在两个分支之间轻松合并?

问题 2:Git 会更适合这个吗?

I'm wondering if there is a easy way to merge between branches of the same Android project where the package name (and thus directory names) are different. Since I will have many branches and all of them need to be kept up to date, I am looking at the best way to do these merges efficiently.

The directory tree of our Android project looks like this

\assets
\libs\...
\res\...
\src\com\mycompany\mainproject
AndroidManifest.xml
build.xml
myproject.iml
myproject.ipr

When we make a customized version for a client, I would change the package name, such as client1app or client2app. You need different package names if they are to exist in the Android Market as different apps for different clients. So I make separate branches which contains identical filenames and directory structure, except for the src folder name which must be changed to match the package name. So client1app or client2app will have the following directory structure:

\src\com\mycompany\client1app
\src\com\mycompany\client2app

The filesnames under those folders are still identical to mainproject. It's just that the directory name is different. (The file content is mostly identical except for the package clause.)

We use SVN for source control. So when I cherrypick merge from mainproject to client1app, I think I would have to merge the top level files and other directories first, and then perform a merge manually for src\com\mycompany\mainproject to src\com\mycompany\client1app. That's five different merges, (for top level and four subdirectories). If it weren't for the directory names being different, this would be a easy single step merge, and I know how to do that.

Question 1: Is there any configuration I could to tell SVN that \src\com\mycompany\mainproject and \src\com\mycompany\client1app contain the same filenames when merging? Or some other way to cherrypick merge easily between the two branches?

Question 2: Would Git be a better fit for this?

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

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

发布评论

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

评论(2

披肩女神 2024-12-28 01:00:39

具有通用代码的 Android 库项目 会对您有最大帮助有了这个。那么你就根本不需要进行任何合并。

An Android Library project with the common code would help you the most with this. Then you wouldn't have to do any merging at all.

李白 2024-12-28 01:00:39

是否有任何配置可以告诉 SVN \src\com\mycompany\mainproject 和 \src\com\mycompany\client1app 在合并时包含相同的文件名?

不。SVN 确实不会跟踪重命名重命名,重命名更改的文件的合并会生成错误“树冲突”(我想/未测试/,会出现相同的效果关于目录重命名)

Git 会更适合这个吗?

是的,Git、Mercurial 或 Bazaar 具有重命名跟踪和更简单的合并路径。就我个人而言,我更喜欢 Mercurial 风格的手动选择,而不是 Git 启发式,但口味可能不同

Is there any configuration I could to tell SVN that \src\com\mycompany\mainproject and \src\com\mycompany\client1app contain the same filenames when merging?

No. SVN really doesn't track renames as renames, merges of renamed and changed files generate errors "Tree conflict" (I suppose /not tested/, same effect will appear on dir renames)

Would Git be a better fit for this?

Yes, Git or Mercurial or Bazaar have rename-tracking and more easy merge-path as result. I, personally, prefer more Mercurial style of manual selection than Git heuristic, but tastes can differ

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