Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Version control 使用Mercurial将依赖项管理为嵌套存储库_Version Control_Mercurial - Fatal编程技术网

Version control 使用Mercurial将依赖项管理为嵌套存储库

Version control 使用Mercurial将依赖项管理为嵌套存储库,version-control,mercurial,Version Control,Mercurial,我希望能够在Mercurial中管理我的应用程序依赖项,以便在我的应用程序中有一个依赖项存储库的分支/克隆。我想在应用程序内对依赖项存储库进行更改并提交更改,但仍然要从依赖项的主存储库中提取和合并更改。推送我的应用程序应该推送依赖项存储库,但应用程序存储库不应该“跟踪”依赖项文件。这可能吗 目录结构: -- app -- .hg -- dependency -- .hg 当我提交到应用程序存储库时,提交依赖项存储库中的任何更改是可以的,但并不可取 # Make libr

我希望能够在Mercurial中管理我的应用程序依赖项,以便在我的应用程序中有一个依赖项存储库的分支/克隆。我想在应用程序内对依赖项存储库进行更改并提交更改,但仍然要从依赖项的主存储库中提取和合并更改。推送我的应用程序应该推送依赖项存储库,但应用程序存储库不应该“跟踪”依赖项文件。这可能吗

目录结构:

-- app
   -- .hg
   -- dependency
      -- .hg
当我提交到应用程序存储库时,提交依赖项存储库中的任何更改是可以的,但并不可取

# 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
当我推送我的应用程序存储库时,尝试推送依赖项存储库是不正确的

下面的课程将探讨尝试使用子回购的问题。该场景模拟了应用程序和库位于托管存储库(如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

注:如果有人能修改格式,我将不胜感激。

您能否先将其克隆到托管的
appOnGCode
repo中,并将其作为子repo添加到那里,而不是在本地克隆
libOnGCode
repo?然后,当您克隆
appOnGCode
repo时,您拥有的
libOnGCode
副本的
默认路径将指向谷歌代码上的
appOnGCode/lib
repo。基本上,这一顺序:

hg init libOnGCode
# Do stuff in libOnGCode
hg commit -m "Library is all set up"

hg init appOnGCode
# Do some stuff in appOnGCode
hg clone libOnGCode lib
echo lib = lib > .hgsub
hg add
hg commit -m "App is all set up"

# on your local system...
hg clone /path/to/appOnGCode app
cat app/lib/.hg/hgrc # Shows default is in appOnGCode/lib
# Do some stuff to app and/or lib
hg commit -m "Local stuff"
hg push  # Only goes to /appOnGCode.

如果您还需要从原始的
libOnGCode
repo中提取更改,您可以将其提取到
appOnGCode
repo中,或者直接提取到本地的repo中;无论哪种方式,所有内容都应该同步。

这是我迄今为止找到的最佳解决方案:

Rusty Klophaus编写了这个小脚本,将.hg目录重命名为.subhg,有效地诱使Mercurial认为没有嵌套的存储库。该脚本还将hg命令代理到真实的hg,将目录设置为.subhg,因此只要有他的subhg脚本,几乎所有内容都可以工作。您可以选择将.subhg目录添加到.hgignore,这样就不会拉/推所有子存储库的历史记录


这样做的缺点是,贡献者必须有subbg才能提交到嵌套存储库。我很想在Mercurial中看到这种功能。

我认为不可能将其克隆到Google代码中。