-1

我最近将开发分支中的一个变更集移植到了默认分支中。之后,我的更改按需要默认。

但出乎意料的是,签入时发生了很多元数据级别的变更集更改。详细说明,

  • 仅在我的开发分支中而不在默认分支中存在的几个文件在默认情况下被标记为已删除。
  • 某些文件中仅存在于我的开发分支中而不存在于默认分支中的几行额外的行在默认情况下被标记为已删除。

Mercurial 已将默认中实际上不存在的某些文件和行标记为默认分支中已删除的文件和行。

因此,当我尝试再次与默认值合并时,mercurial 会将这些文件和行从默认值中删除,并尝试从我的分支中删除它们。

我尝试退出以单独恢复有问题的提交。不幸的是,回退只更改签入期间修改的源代码行,但不会删除删除不可用文件和行的元数据标记。

无论如何都可以撤消不希望发生的提交元数据级别的更改?非常感谢任何帮助。

谢谢。

4

1 回答 1

0

If you have a bad commit and just want to forget it ever happened, and that commit has no descendants, you can just do hg strip to remove it from history entirely (requires strip extension).

If the commit does have descendants, you can use hg histedit (requires histedit extension) to drop the changesets you don't want to keep.

Both these solutions involve editing history, which is risky if you've distributed the bad commit publicly. You will have to coordinate with everyone who may have pulled the bad commit or any of its descendants, which isn't always possible (e.g. in an open source environment). You will also need to redo these changes server-side, since Mercurial's push --force is not like Git's push --force.

If you don't want to edit history, you can graft the descendants of the bad commit onto the last known good ancestor (e.g. hg up good_ancestor; hg graft 'bad_commit:: - bad_commit'), then do hg commit --close-branch at the bad head(s). Be sure to leave an informative commit message on the close-branch commit, so that other developers will know where to rebase anything that descends from the bad commit.

于 2015-10-26T02:32:25.397 回答