【发布时间】:2010-06-04 19:11:50
【问题描述】:
我希望能够在 Mercurial 中管理我的应用程序依赖项,以便在我的应用程序内部拥有依赖项存储库的 fork/clone。我想对应用程序内的依赖库进行更改并提交更改,但仍从依赖项的主存储库中提取和合并更改。推送我的应用程序应该与它一起推送依赖项存储库,但应用程序存储库不应“跟踪”依赖项文件。这可能吗?
目录结构:
-- app
-- .hg
-- dependency
-- .hg
当我提交到应用程序存储库时,可以但最好不要在依赖项存储库中提交任何更改。
当我推送我的应用存储库时,尝试推送依赖存储库是不行的。
下面的会话探讨了尝试使用子存储库的问题。该场景模拟了应用程序和库位于托管存储库(如 Google 代码)上的场景。我也尝试告诉 Mercurial 忽略子存储库,但没有成功。
# Make library on Google Code
mkdir libOnGCode
cd libOnGCode/
hg init
echo "this library is really complex" > libfile
hg add
hg ci -m "I'm so awesome..."
cd ..
# Make app on Google Code
mkdir appOnGCode
cd appOnGCode/
hg init
echo "my base app" > appfile
hg add
hg ci -m "Initial app commit"
cd ..
# Bring down local copy of app
hg clone appOnGCode appLocal
cd appLocal
hg clone ../libOnGCode/ lib
# abort: path 'lib/libfile' is inside repo 'lib'
echo "I'm gonna use a library" >> appfile
hg add lib
hg add lib/*
hg ci -m "Added a library"
hg push # It's not tracking lib
echo "Trying subrepos round 1..."
echo lib = lib > .hgsub
hg add .hgsub
hg ci -m "Adding subrepo"
# committing subrepository lib
hg push
# pushing to /workingdir/appOnGCode
# pushing subrepo lib
# abort: repository /workingdir/appOnGCode/lib not found!
echo "Trying subrepos round 2..."
echo lib = ../libOnGCode > .hgsub
hg ci -m "Adding subrepo"
hg push
# Cool, the subrepo worked, pulling app pulls lib
cd lib
echo "My addition to the lib" >> libfile
hg ci -m "Adding extra functionality"
cd ..
hg push
cd ../libOnGCode
hg update
echo "Argh, it updated the lib on google code"
echo "If I didn't have permission to push on the lib repo, pushing the app would fail"
cat libfile
echo "Removing those changes"
hg backout -m "Removing those changes" tip
cd ../appLocal/lib/
hg pull -u
echo "Trying to add extra functionality again" >> libfile
hg ci -m "Trying again"
cd .hg/
echo "Removing hgrc, which only has path info"
rm hgrc
cd ../../
hg push
cd ../appOnGCode
hg update
cat lib/libfile
# Tears hair out
PS。如果有人可以修复格式,我将不胜感激。
【问题讨论】: