简体   繁体   English

Mercurial合并分支机构? (abort:push创建新的远程分支)

[英]Mercurial merge branches? (abort: push creates new remote branches)

I'm new to Mercurial, and I made the mistake of making different changes on different systems before the main repository was up to date. 我是Mercurial的新手,我错误地在主存储库是最新的之前在不同的系统上进行了不同的更改。 (I understand this is what Mercurial is built for, but my thick brain is struggling to resolve the issue.) (我明白这就是Mercurial的目的,但是我的大脑正在努力解决这个问题。)

Now on my primary development server, everything is up to date and committed. 现在在我的主开发服务器上,一切都是最新的并且已经提交。 However... 然而...

$ hg push
abort: push creates new remote branches: 4f2672f039d7!
(use 'hg push --new-branch' to create new remote branches)

I don't really want a new branch. 我真的不想要一个新的分支。 I just want all the changes to be merged. 我只想要合并所有的更改。

$ hg heads
changeset:   459:ff5f94e44aba
branch:      4f2672f039d7
tag:         tip
parent:      458:e63d02baf4cf
parent:      455:267abda62069
user:        mike@...
date:        Tue Sep 13 14:25:16 2011 -0400
summary:     Images from prof

changeset:   455:267abda62069
parent:      453:a74757e26357
user:        mike@localhost.localdomain
date:        Tue Sep 13 09:08:12 2011 -0400
summary:     images for FLC

Point me in the right direction? 指出我正确的方向?

EDIT: (adding detail) 编辑:(添加细节)

When I try to merge, I get the following result: 当我尝试合并时,我得到以下结果:

$ hg merge
abort: branch '4f2672f039d7' has one head - please merge with an explicit rev
(run 'hg heads' to see all heads)

I have tried hg merge ff5f94e44aba , and all of the revs listed above, and each one returns the same result: 我试过hg merge ff5f94e44aba ,以及上面列出的所有转速,每一个都返回相同的结果:

$ hg merge 267abda62069
abort: merging with a working directory ancestor has no effect

Pull from remote and then update / merge / commit first. 从远程拉,然后首先更新/合并/提交。 Then you won't make new branches. 那你就不会建立新的分支了。

It looks like you've accidentally created a branch with a silly name. 看起来你不小心创建了一个愚蠢名称的分支。 What you most likely want to do is reapply your changes with a branch name that makes better sense. 您最有可能想要做的是使用更有意义的分支名称重新应用您的更改。 There's no totally automatic way of doing this, but you can extract each changeset as a patch, revert to the point where you messed up and reapply those changes on the proper branch. 没有完全自动的方法,但你可以将每个变更集提取为补丁,恢复到你搞砸的地步,并在适当的分支上重新应用这些变化。

Basically what you need to do is look at the changelog; 基本上你需要做的是查看更改日志; probably by running hg out to see what's missing from the central repository. 可能是通过运行hg out来查看中央存储库中缺少的内容。 Make a note of each of the revs that you want to keep. 记下要保留的每个转速。

Next update to the last good revision. 下次更新到最后一个好的修订版。 Make sure that you are on the branch you wanted your commits to be on. 确保您在希望提交的分支上。

Now you will apply each of the changes you made and commit each one. 现在,您将应用您所做的每个更改并提交每个更改。 You can automate this process something like this: 您可以像这样自动执行此过程:

BADREVS="123 124 125 126"

recommit() { hg di -c $1 | patch -p1;  hg ci -m "$(hg log -r $1 --template '{desc}')";}
for rev in $BADREVS; do
    recommit $rev
done

Now you've got your changes in your local repository twice; 现在,您已在本地存储库中进行了两次更改; once as the commits on the weird branch and again on the right branch. 一次作为奇怪分支的提交,再一次作为右分支的提交。 You can push those changes to the central repo using hg push -b GOODBRANCH so that only the changes to the right branch go up; 你可以使用hg push -b GOODBRANCH将这些更改推送到中央hg push -b GOODBRANCH这样只有对右分支的更改才会上升; Alternatively, you can install the strip extension to remove the changes you didn't want from the local repo and then you can push as normal. 或者,您可以安装条带扩展以从本地存储库中删除您不想要的更改,然后您可以正常推送。

By the sound of it; 听到它的声音; you will still have to deal with the changes made to the central repository before you can push, since you pushed changes from another repo. 在推送之前,您仍然必须处理对中央存储库所做的更改,因为您从另一个仓库推送了更改。 You probably want to do this merging after you clean up the change history in the local repo. 清理本地存储库中的更改历史记录后,您可能希望进行此合并。

I've had this happen when I missed a merge. 当我错过合并时,我已经发生了这种情况。 I like the TortoiseHg workbench for this because it can be a little easier to find what you missed through visualization. 我喜欢TortoiseHg工作台,因为通过可视化可以更容易地找到您错过的内容。

A good way to avoid this in the future, how I stopped getting this error, is the fetch extension. 今后避免这种情况的好方法是如何停止获取此错误,这是fetch扩展。 Set your post pull to fetch and it will automatically merge for you, which is very nice. 将你的帖子设置为fetch,它将自动为你合并,这非常好。 If there's a conflict it brings up whatever conflict resolver you use. 如果存在冲突,则会出现您使用的任何冲突解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM