0

我们有一个位于单独服务器上的主存储库。我最初克隆了默认分支并在本地进行了更改。我已经在本地提交了这些更改。但是,在主存储库上创建了一个分支,我想将更改推送到。以下是我尝试完成此任务的描述。

我已经克隆了分支。我正在尝试从本地默认值导出我的更改,如下所示:

C:\hg\default>hg export -g -o mypatch -r tip

当尝试将它们导入新分支的克隆时,我得到以下信息:

C:\hg\newBranch>hg import C:\hg\default\mypatch
applying C:\hg\Fill1\mypatch
patching file .hgignore
Hunk #1 FAILED at 11
1 out of 1 hunks FAILED -- saving rejects to file .hgignore.rej
abort: patch failed to apply

我可以手动修复 .hgingore.rej 文件就好了。问题是补丁还包含被移动的文件。运行时我得到以下内容,而不是显示为已移动的文件hg status

C:\hg\newBranch>hg status -C
M someOtherFilesThatLookAsExpected.txt
! originalLocaion\fileA.txt
? newLocation\fileA.txt

此缺失和新状态适用于在包含应用补丁的提交中移动的所有文件。难道我做错了什么?应用补丁时是否总是需要手动移动文件?有没有更简单的方法来完成这个分支转移?

4

1 回答 1

1

That's a bit difficult to answer without knowing more about your repository structure, but here's how I'd go about it without knowing more. I'm assuming that the reason for the conflict is that there are conflicting changes in the same branch of the repository.

First, get the contents of the newBranch repository:

cd c:\hg\default
hg pull c:\hg\newBranch

Then, either merge or rebase your changes on top. If you are working on the same branch, then just using

hg pull --rebase c:\hg\newBranch

in lieu of the regular pull should do (assuming you have rebasing enabled). Otherwise, do an explicit merge or rebase of the two heads that you need to reconcile. Finally, do:

hg push -r tip c:\hg\newBranch

in order to get your (now reconciled) changes back into newBranch.

Unless you have very specific and unusual requirements, push and pull should be your normal way to sync repositories or part of them (note that using -r will only push/pull the respective branch). Export/import are rather low-level mechanisms that may not give you the benefits of the standard machinery that handles renames, three-way merging logic, etc.

于 2013-05-03T16:15:12.150 回答