projects
/
hvutilities.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b1c95e2
)
git-hg-sub-import: Ajout support subpaths (enlevé HG_REPO fixe)
author
Hugo Villeneuve
<hugo@hugovil.com>
Fri, 28 Jun 2013 18:20:06 +0000
(14:20 -0400)
committer
Hugo Villeneuve
<hugo@hugovil.com>
Wed, 31 Jul 2013 18:05:17 +0000
(14:05 -0400)
scripts/git-hg-sub-import
patch
|
blob
|
history
diff --git
a/scripts/git-hg-sub-import
b/scripts/git-hg-sub-import
index
6d18dc3
..
ecd7757
100755
(executable)
--- a/
scripts/git-hg-sub-import
+++ b/
scripts/git-hg-sub-import
@@
-1,13
+1,11
@@
#!/bin/bash
set -o errexit
#!/bin/bash
set -o errexit
-# Uncomment to have verboswe debug output
-#debug=1
-
# for use with git-remote-hg:
# http://felipec.wordpress.com/2012/11/13/git-remote-hg-bzr-2/
# for use with git-remote-hg:
# http://felipec.wordpress.com/2012/11/13/git-remote-hg-bzr-2/
-LSI_SRV=/mnt/server/research/Projects/HG_Repo
+# Uncomment to have verbose debug output
+#debug=1
print_usage()
{
print_usage()
{
@@
-15,6
+13,22
@@
print_usage()
echo "Usage: $(basename $0) [OPTIONS...]"
}
echo "Usage: $(basename $0) [OPTIONS...]"
}
+# git-remote-hg doesn't work with Mercurial subpaths extension,
+# so use it manually
+hg_subpaths_config() {
+ subpaths=$(hg showconfig | grep "subpaths")
+
+ if [ -n ${subpaths} ]; then
+ sp_src=${subpaths//subpaths./}
+ sp_src=${sp_src//=*/}
+ sp_src=${sp_src//\\/} # Remove windows separator (LSI)
+ sp_dst=${subpaths//*=/}
+
+ echo "sp_src = $sp_src"
+ echo "sp_dst = $sp_dst"
+ fi
+}
+
# Map a revision to a branch name in HG subrepository
# Use hg log (in original repo) to get branch name corresponding to that
# revision.
# Map a revision to a branch name in HG subrepository
# Use hg log (in original repo) to get branch name corresponding to that
# revision.
@@
-27,7
+41,7
@@
subrepo_find_branch() {
local id="${2}"
local rev="${3}"
local id="${2}"
local rev="${3}"
- pushd "${
LSI_SRV}/${
src}"
+ pushd "${src}"
branch=$(hg log -r ${rev} | grep "branch:" | sed "s/branch:\ *//")
branch=$(hg log -r ${rev} | grep "branch:" | sed "s/branch:\ *//")
@@
-58,6
+72,8
@@
if [ ! -f .gitignore ]; then
echo ".gitignore" > .gitignore
fi
echo ".gitignore" > .gitignore
fi
+hg_subpaths_config
+
# Read lines from .hgsub
while read sub; do
# Remove CR (DOS)
# Read lines from .hgsub
while read sub; do
# Remove CR (DOS)
@@
-65,13
+81,16
@@
while read sub; do
if [ "${sub}" != "" ]; then
# Get subrepository URL
if [ "${sub}" != "" ]; then
# Get subrepository URL
- src="${sub//*\/HG_REPO/}"
+ src="${sub//*= /}"
+
+ # Replace using subpaths extension content
+ src=${src/${sp_src}/${sp_dst}}
# Get subrepository local alias or label
dest="${sub// =*}"
# Get project ID (example: S0289)
# Get subrepository local alias or label
dest="${sub// =*}"
# Get project ID (example: S0289)
- id=$(echo ${sub} | sed "s/.*
HG_REPO
\(S[0-9][0-9][0-9][0-9]\).*/\1/")
+ id=$(echo ${sub} | sed "s/.*\(S[0-9][0-9][0-9][0-9]\).*/\1/")
# Get revision of subrepository (remove CR from .hgsubstate)
rev=$(cat .hgsubstate | tr -d '\r' | grep "${id}" | sed "s/ .*//")
# Get revision of subrepository (remove CR from .hgsubstate)
rev=$(cat .hgsubstate | tr -d '\r' | grep "${id}" | sed "s/ .*//")
@@
-80,6
+99,7
@@
while read sub; do
echo "repo: ${src}"
echo " id: ${id}"
echo " rev: ${rev}"
echo "repo: ${src}"
echo " id: ${id}"
echo " rev: ${rev}"
+ echo " src: ${src}"
echo " dest: ${dest}"
fi
echo " dest: ${dest}"
fi
@@
-92,11
+112,16
@@
while read sub; do
# "BRANCH___-___NAME"
branch="${branch// /___}"
# "BRANCH___-___NAME"
branch="${branch// /___}"
- git clone "hg::${
LSI_SRV}/${
src}" "${dest}"
+ git clone "hg::${src}" "${dest}"
if [ "x${branch}" != "xdefault" ]; then
cd "${dest}"
git checkout "branches/${branch}"
if [ "x${branch}" != "xdefault" ]; then
cd "${dest}"
git checkout "branches/${branch}"
+
+ # This does not work: the SHA from hg and git
+ # are not the same...
+ #git reset --hard ${rev}
+
cd ..
fi
cd ..
fi