私は水銀にかなり慣れていません。このテーマに関する多くのトピックを読みましたが、自分がやろうとしていることを達成できるかどうかはまだわかりません。
基本的に、メイン リポジトリとそのサブリポジトリからブランチの現在のリビジョンを 1 つのコマンド (メイン リポジトリに作用する) で複製することに興味があります。私はすぐにそれをよりよく説明しようとします。
コードをモジュールに分割したとしましょう (以下の例では 1 つのモジュールのみ)。各モジュールを独自のリポジトリに配置し、マスター リポジトリ (.hgsub を含むリポジトリ) を接着剤として使用して、すべてのサブリポジトリを所定の位置に保持したいと考えています。マスター リポジトリには .hgsub と、(1)hg archive
事前定義されたディレクトリ内の各サブリポジトリと (2) コードのソース外ビルドを実行するスクリプトが含まれています。すべての開発、コミット、プッシュ、プル、マージは、個々のサブリポジトリで行われます。
# create a module (subrepo of the master)
hg init subrepo
cd subrepo/
echo "a file" > aFile.c
echo "another file" > anotherFile.txt
hg add
hg ci -m "initial rev of subrepo"
# create the main (master) repo & add the reference to subrepo
cd ../
hg init main
cd main
hg clone ../subrepo subrepo
echo subrepo = ../subrepo > .hgsub
echo hg archive and out-of-source build > build.script
hg add
hg ci -m "initial rev of main repo"
ここまでは順調ですね。hg clone main
予想どおり、サブレポのデフォルトブランチの現在のリビジョンを取得した場合。
しかし、私のコードを 1.0.0 というリリースに出荷する準備ができたとしましょう。私は次のようにします。
# create the branch 1.0 to manage the bug fixes to 1.0.0 and furthers
cd ../subrepo/
hg branch 1.0
hg ci -m "creating the branch 1.0"
# backstep to the main line to carry on the development of new features
hg up default
echo "working in the main line" > aNewFeature.c
hg add
hg ci -m "carrying on the development in the main line (a new feature)"
hg glog
@ changeset: 2:c499329c2729
| tag: tip
| parent: 0:50d4522a99ea
| user: XXXX
| date: Tue Dec 07 16:13:28 2010 +0100
| summary: carrying on the development in the main line (a new feature)
|
| o changeset: 1:0a81043e6e8a
|/ branch: 1.0
| user: XXXX
| date: Tue Dec 07 16:12:02 2010 +0100
| summary: creating the branch 1.0
|
o changeset: 0:50d4522a99ea
user: XXXX
date: Tue Dec 07 15:52:57 2010 +0100
summary: initial rev of subrepo
そして、ここで問題が発生します。マスターリポジトリを変更して、実行時にデフォルトの現在のリビジョン、または最終的にはサブリポジトリの 1.0 ブランチを取得するにはどうすればよいhg clone
ですか?
私はこれがうまくいったと言ったでしょう。
# replicate the branch structure also in the main repo
cd ../main/
hg branch 1.0
echo subrepo = ../subrepo -r 1.0 > .hgsub
hg ci -m "adding -r 1.0 to .hgsub"
hg up default
echo subrepo = ../subrepo -r default > .hgsub
hg ci -m "adding -r default to .hgsub"
hg glog
@ changeset: 2:f97c90a31a21
| tag: tip
| parent: 0:1fd6b5d528b4
| user: XXXX
| date: Tue Dec 07 16:22:05 2010 +0100
| summary: adding -r default to .hgsub
|
| o changeset: 1:3d9ed2f8b026
|/ branch: 1.0
| user: XXXX
| date: Tue Dec 07 16:21:32 2010 +0100
| summary: adding -r 1.0 to .hgsub
|
o changeset: 0:1fd6b5d528b4
user: XXXX
date: Tue Dec 07 15:55:53 2010 +0100
summary: initial rev of main repo
しかし、私hg clone
がメインレポになると、
cd /a/directory
hg clone /path/to/main -r 1.0 main
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 3 changes to 2 files
updating to branch 1.0
pulling subrepo subrepo
abort: HTTP Error 404: Not Found
私がやりたいことを達成する方法はありますか?
ありがとう。
クイック アップデート: 質問を投稿してからわずか 1 分後に、今まで見たことのない回答を見つけました。そこでは、次の構文を使用することをお勧めします
http://[user[:pass]@]host[:port]/[path][#revision]
#branchname
の代わりに使用して#revision
。したがって、私の例では、次のように動作するはずです (ブランチ 1.0 の場合)。
echo subrepo = ../subrepo#1.0 > .hgsub
しかし、私hg clone
がマスターレポを取得すると、次のようになります。
pulling subrepo subrepo
abort: unsupported URL component: "1.0"
Exception AttributeError: "'httprepository' object has no attribute 'urlopener'" in <bound method httprepository.__del__ of <mercurial.httprepo.httprepository object at 0x871332c>> ignored
私はUbuntu 10.04、mercurial 1.4.3-1に取り組んでいます。提案?
-- ディラン