【发布时间】:2023-03-27 23:00:03
【问题描述】:
这应该很简单,但有些地方不太对劲。这是我的场景,然后我将简要概述我正在使用的命令。知道我们有 3 个特定的开发区,Live、Staging,当然还有我们自己的本地开发区会有所帮助。
我在我的网站上开发了一个新的“测试版”区域,该区域已经上线并进行了适当的测试。现在我准备将它从 beta 目录移动到它真正应该在的位置并移出旧目录。当我在本地执行此操作时,似乎很好,但是当我尝试将本地分支合并到暂存分支时,它似乎没有正确映射文件,并给了我一堆use (c)hanged version, (d)elete, or leave (u)nresolved? 提示。当我的旧目录包含与 beta 目录相同名称的文件(例如 index.php)时,问题就出现了。这是我的意思的一个简单示例:
currentDir/index.php
currentDir/update.php
currentDir/another_file.php
currentDir-beta/index.php
currentDir-beta/update.php
currentDir-beta/a_new_file.php
currentDir-beta/another_new_file.php
这是我的过程。
# creates a new branch from the live branch
hg branch new-branch-name
# move the current directory somewhere else
hg mv currentDir/* currentDir-old/
# commit...
hg com -m "moved current to -old"
# everything is fine up to this point
# move the beta directory to where the old one was
hg mv currentDir-beta/* currentDir/
# when I run hg st, it only shows that files are being removed from the -beta directory and added to the new/old directory
# commit
hg com -m "moved -beta to currentDir"
# when this commits is when the problems start happening.
# At this point when I run this next command, it shows that
# currentDir/index.php and other common files are now "modified" instead of "added"
hg st --rev "max(ancestors('new-branch-name') and branch(live)):'new-branch-name'"
# then try to merge to staging
hg up staging
hg merge new-branch-name
# errors happen with "common" file names like index.php. It treats them as though they were only modified instead of added.
即使我忽略了上述“修改”的怪癖,当我将这个新分支与程序员所做的其他更改合并到暂存分支时,它也会抱怨“本地已远程删除了这个”。我真的不在乎其中的大部分内容,因为我可以直接把它扔掉,然后任何新的分支都会有这个变化。我关心的是,在 currentDir-beta 文件夹中对其他程序员的那些“通用”文件所做的任何工作都将不再映射到新位置。我可以复制/粘贴代码并提交它,但这基本上意味着这些分支已被冲洗掉,因为它与保留其他程序员对这些公共文件所做的更改有关。举个例子来说明我的意思,当我合并并输入 hg st 时,它可能看起来像这样。
M currentDir/index.php
M currentDir/update.php
M currentDir/a_new_file.php # why is this M? It should be A right?
M currentDir/another_new_file.php # why is this M? It should be A right?
M currentDir-old/another_file.php # why is this M? It should be A right?
R currentDir/another_file.php
R currentDir-beta/index.php
R currentDir-beta/update.php
R currentDir-beta/a_new_file.php
R currentDir-beta/another_new_file.php
关于如何解决这个问题的任何建议?我的目标是让 currentDir-beta 中发生的现有代码更改“转发”到暂存环境中的 currentDir/。映射了所有其他“不常见”的文件更改,而不是这些常见文件。
更新
忘了提一下,我在 macOS Sierra 上使用 Mercurial 3.9。
【问题讨论】:
标签: merge mercurial branch rename