2016-11-10 71 views
1

我在几个月前从默认创建分支br1。从那以后,我一直在致力于br1的改变。时不时地,拉动从默认的变化如下:在两个分支之间创建更改提交

hg up br1 
hg merge default 
// create a commit, push 

我想创造的我做出BR1在过去几个月的所有更改的提交信息。分支br1和default在我的工作空间中是干净的,也就是说没有未提交的更改,没有未推入的提交。此时,br1在1周内与默认值不同步。我做了以下步骤:

hg up default 
hg merge br1 
// At this point, "hg stat" shows files that I did not modify in br1. :(
// So, if I created a commit message at this point, it would be no good. 
// I am not sure why these addition file modifications showed up. 

我觉得这个问题可能是因为br1与默认的一周不同步。我执行了以下一系列的步骤在干净的工作区:

hg up br1 
hg merge default 
// created a commit -**ch1**, but did **NOT push** 
hg up default 
hg merge br1 
// At this point, "hg stat" shows the same additional files as my pervious 
// attempt. :(

问: - 是否“汞合并”无视提交未推? - 我需要推ch1为这些额外的文件不显示?这是“hg merge br1”何时显示额外文件的原因吗? - 有没有一种方法可以告诉hg在从br1进行合并时考虑到ch1。

谢谢, 艾哈迈德。

回答

1

好了,因为你没有提供一个工作的例子,我要建立一个从头开始,所以请原谅我在结束下方

解释了一堆命令行,因为才有意义,如果你效仿的榜样步骤

准备阶段

# create a new dir an initialize the repository 
mkdir hgtrial 
cd hgtrial 
hg init 

# create an empty file and make first commit on default branch 
echo . > dummy.txt 
hg add dummy.txt 
hg commit -m "1st commit" 

# add info and make a second commmit also on default branch 
echo abc >> dummy.txt 
hg commit -m "2nd commit" 

# create a new branch and make an empty commit on it 
hg branch br1 
hg commit -m "my new branch" 

# work on br1 
echo def >> dummy.txt 
hg commit -m "def on br1" 

# work on default (make br1 out of sync) 
hg up default 
echo ghi >> dummy.txt 
hg commit -m "ghi on default" 
echo jkl >> dummy.txt 
hg commit -m "jkl on default" 

# sync br1 by pulling default 
hg up br1 
hg merge default 
# solve merge conflicts (abc def ghi jkl) 
hg commit -m "br1 <- default" 

# continue working on br1 (without touching dummy.txt) 
echo 123 > another.txt 
hg add another.txt 
hg commit -m "another file" 
echo 456 >> another.txt 
hg commit -m "456" 

# work on default (make br1 out of sync) 
hg up default 
echo yes-yes > one-more.txt 
hg add one-more.txt 
hg commit -m "yes-yes, on default" 
echo no-no >> one-more.txt 
hg commit -m "no-no, on default" 

现在的问题(通知我们站在default BR anch)

# now the problem (scenario 1) 
hg merge br1 
hg stat 
# dummy.txt is modified, trying to bring "def" from br1 into default 
# abort 

# checkout clean br1 (drop merge in progress) 
hg up -C br1 
hg merge default 
hg commit -m "br1 <- default" 

# the problem again (scenario 2) 
hg up default 
hg merge br1 
hg stat 
# dummy.txt is modified, trying to bring "def" from br1 into default 
# SAME THING! 

为什么? 因为在某些时候"def"变化在br1制成,default从来不知道这件事,所以即使你没有在很长一段时间摸dummy.txt,你已经同步defaultbr1,但没有倒过来,因此default有很多赶上

编辑:在TortoiseHg 这个场景的截图添加TortoiseHg merge in progress

+0

非常感谢你的解释,工作示例。问题是,对于场景1,我猜测hg stat会像“dummy.txt被修改,试图从br1带来”def“,并且存在新文件another.txt。这正是我想要的。这两项是br1所做更改的完整列表。 –

+0

什么是一个好的推荐工作流程,以获得只有bri到bri的变化列表,这将是“def”到dummy.txt,并创建新文件another.txt。有推荐的工作流程吗? –

+0

为更好的可视化和理解发生了什么我会推荐你​​TortoiseHg(GUI),同时你可以参考http:// stackoverflow。com/questions/25238277/mercurial-show-diff-against-2-parents-or-base-merge- – arhak

相关问题