1

マーキュリアルで手付かずのチェックアウトを行うにはどうすればよいですか? Martin Geisler は、以下を使用して、既に Mercurial でコミットされたファイルを削除する方法について説明しています。

hg strip "outgoing()"

しかし、" " に入った追加ファイルを保持したい場合はどうすればよいでしょうかoutgoing()- 例:

2 人のユーザー a と b — 同じチェンジセットで開始

ユーザー a:

echo "A" > A.txt; hg ci -M -m ""; hg push

ユーザー b ( を実行するのを忘れたhg pull -u):

echo "B" > B.txt; hg ci -M -m "" B.txt;
echo "C" > C.txt; hg ci -M -m "" C.txt;

ユーザー b が実行さhg strip "outgoing()"れると、B.txt と C.txt が失われます。hg rollback2 つのコミットがあるため、オプションではありません。

ユーザー b を自分のファイルを「ローカルに追加 - 追跡なし」に戻してhg pull -uから、A.txt を取得し、後で B.txt と C.txt の追加/コミット/プッシュを処理できますか?

マーティン・ガイスラーは、前述のスレッドで以前にこれに答えました(私が削除してここに移動したコメント:

hg update "p1(min(outgoing()))"
hg revert --all --rev tip 
hg strip "outgoing()"
hg pull -u

これで、ユーザー c は新しいファイル B.txt と C.txt で自分の作業を完了し、それらを commit+push できます。

これを行う他の方法は?

4

2 に答える 2

2

You could but, by doing so, you are working against one of the biggest features of a DVCS like mercurial, that is, to easily and reliably handle the merging of multiple lines of development as in your case. If user b's goal is to have a line of development with all three changes applied, then the standard way to do that in hg would be to just go ahead and do an hg pull -u which will create a new head containing the change(s) from user a (and any other changes pushed to repo used for pulling) and then use hg merge to merge the two heads, the head containing user b's two change sets and the other containing user a's change set (as pulled). In a simple case like this one with no overlapping changes, hg should do all the right things by default.

$ hg pull -u
[...]
added 1 changesets with 1 changes to 1 files (+1 heads)
not updating: crosses branches (merge branches or update --check to force update)
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m "merge"

If there were conflicts between the two heads (i.e. both users committed changes to the same files), there might need to be conflict resolution editing as part of the merge; hg will tell you if that is the case.

于 2012-04-14T20:26:09.463 に答える
1

別のオプションはrebase拡張子です。あなたのシナリオで:

  1. AとBは同じ歴史から始まります。
  2. A が変更をコミットしてプッシュします。
  3. B は 2 つの変更をコミットしますが、A のコミットのためにプッシュできません。
  4. B は A の釣り銭を引き出します。
  5. Bは走っhg rebaseて押します。

リベース前:

Common ---------------------------- A (tip)
     \
      B1 - B2 (working parent)

後:

Common - A - B1 - B2 (tip, working parent)
于 2012-04-15T00:57:25.927 に答える