Mercurialのサブリポジトリ。

最近はずっと Mercurial を使っているのですが、うかつにも CVS と同じような気持ちで、リポジトリツリーの下にリポジトリを作ってしまいました。言ってみれば、入れ子のリポジトリです。

ところが TortoiseHG の "View File Status" や Workbench の表示がうまくいきません。あるはずのファイルがリストに表示されなくなってしまいました。

Mercurial には入れ子のリポジトリである Subrepository という機能があるようです。ところがそのページには、"This is considered a feature of last resort." と書かれています。最後の行楽地(楽園?)という意味ではなくて、"last resort" は「最後の手段」というような意味になります。"a weapon of last resort" というのは「最終兵器」のことだそうで。ということで、「サブリポジトリというのは最後の手段なので、できるだけ使わないほうがいい」ということのようです。

ちなみに Mercurial で Last Resort と考えられているのは、"Subrepositories"、"largefiles"、"keywords"、"EOL translation"、"Static HTTP" の5つのようです。
These features are all at odds with Mercurial's core design, and will therefore always present some difficulties in terms of performance, ease of use, and integration. As such, when using them, you won't get the best possible Mercurial experience. Due to our compatibility rules, these features will continue to exist — but we want to make you aware that there are often better alternatives.

互換性の観点から機能としては存在し続けるけど、もっといい方法があるはずなのでそっちを検討して、ということのようです。subrepository については、
3. But I need to have managed subprojects!
Again, don't be so sure. Significant projects like Mozilla that have tons of dependencies do just fine without using subrepos. Most smaller projects will almost certainly be better off without using subrepos. This is not true for all projects, however, so we've made them available as an option. Be sure to follow our recommendations for best results.
Mozilla みたいな何十もの依存関係をもつ重要なプロジェクトでも、一つのリポジトリでうまくやってるし、ほとんどの小さいプロジェクトはサブリポジトリを使わないほうがうまくいくはずだし、すべてに当てはまるわけではないから機能としては利用できるようにするけど、推奨する方法も検討してみて、という感じ。

ということで、サブリポジトリは使えるけど、使わないほうがいいよということのようです。

参考までに引用しておくと、main リポジトリの下に nested リポジトリを作成する場合には、
$ hg init main
$ cd main
$ hg init nested
という構造にしておいて、次に nested を ".hgsub" ファイルに記述します。
$ echo nested = nested > .hgsub
$ hg add .hgsub
'=' の左側がワーキングディレクトリ、右側がソースの参照元(pull元)です。

それはさておき。
となると、入れ子に作ってしまったリポジトリを、変更履歴をそのままに親に統合する方法を探るのがよさそうです。探したら、StackOverflow で2つほど引っかかりました。How to combine two projects in Mercurial?Merge two mercurial repositories without breaking file history です。

これによれば、親リポジトリにて hg pull --force [subrepo] するということのようです。Mercurial Wikiにも説明がありました。MergingUnrelatedRepositories
これによれば、「つじつまの合わない履歴になる可能性があるから推奨はできないけど、以下のようにすればできるよ」ということで、
hg clone REPO1 work         # First pull from both repos...
 cd work
 hg pull -f REPO2
 hg merge                    # Then simply merge.
 hg commit
その一方で、
On the other hand, if you're doing this in order to stop using two separate repositories, just hg push REPO1 and you're finished.
ともあり、REPO2(子供)のほうから REPO1(親)に push するだけでいいよ、だそうです。

0 件のコメント:

コメントを投稿

AstroNvimでtelescope.nvimがエラーを吐いたとき。

Windowsの環境でAstroNvimをインストールして、Find Fileしたらtelescopeがエラーを吐いてきました。 メッセージは、 Failed to run `config` for telescope.nvim ...a/lazy/telescope.nvim/...