Intro
There are a lot of strange things in the project which I am working at.
One of it is Mercurial as VCS in 2016, and a lot of hooks.
Some rules:
1. You should install on you PC Postgres, python, etc.
2. To do single commit on local PC you will be faced with local commit hooks, that will download new Postgres database, check your permissions, and allow or not your current changes to saved.. (Of course, all hooks are disabled for people who set it up!) Single commit can be 10min waiting. Pull/push 5-30min.
3. Not enough? any merge between branches is not allowed. Only to/from default, no shelve, nothing, only 2 commands commit and merge to/from default.
4. Made mistake in commit template - you will not be able to save your changes for current branch... you should create the new one branch and committing one by one move all changes...
So, What can we do with this shit?
Convert Mercurial to Git, and use git at least on local PC!
One of it is Mercurial as VCS in 2016, and a lot of hooks.
Some rules:
1. You should install on you PC Postgres, python, etc.
2. To do single commit on local PC you will be faced with local commit hooks, that will download new Postgres database, check your permissions, and allow or not your current changes to saved.. (Of course, all hooks are disabled for people who set it up!) Single commit can be 10min waiting. Pull/push 5-30min.
3. Not enough? any merge between branches is not allowed. Only to/from default, no shelve, nothing, only 2 commands commit and merge to/from default.
4. Made mistake in commit template - you will not be able to save your changes for current branch... you should create the new one branch and committing one by one move all changes...
So, What can we do with this shit?
Convert Mercurial to Git, and use git at least on local PC!
Short project overview that can be used for converting from Mercurial to Git
0. git-remote-hg
My winner. It adds git plugin, so you can work with a git repository, and mercurial is "remote" repository.
Push/Pull works. Also, fast-forward should be disabled because mercurial so stupid.
https://github.com/felipec/git-remote-hg
1. fast-export
Convert mercurial repository to git. Really nice tool.
https://github.com/frej/fast-export
2. git-hg
Use git like commands to work with a mercurial repository. Wrapper for fast-export.
Does not work with my git workflow.
https://github.com/offbytwo/git-hg
3. gitifyhg
Better then prev one, you can use git commands.
It keeps a local copy of a mercurial repository and does same commands to both repositories.
Have problems with fast-forward commits.
https://github.com/buchuki/gitifyhg
4. Others
https://github.com/glandium/git-cinnabar
https://github.com/git/git/tree/8d530c4d64ffcc853889f7b385f554d53db375ed/contrib/remote-helpers
https://github.com/cosmin/git-hg
https://github.com/abourget/git-hg-again
https://github.com/rfk/git-remote-hg
https://github.com/nwgh/git-hg
https://github.com/msysgit/msysgit/wiki/Guide-to-git-remote-hg
About "git-remote-hg" set up in my project
1. install tools
wget https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg -O ~/bin/git-remote-hg chmod +x ~/bin/git-remote-hg
2. clone repository
git clone "hg::ssh://user@example.com/Project"
3. configure git
project/.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = hg::ssh://user@example.com/Proejct
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = user.name
email = unknown
[merge]
ff = false
project/.git/hooks/commit-msg
#!/bin/sh
NAME=$(git branch | grep '*' | sed 's/* //' | grep -o '[0-9]\+')
echo "\n\nrefs #$NAME\n`cat $1`\n" > "$1"
project/.git/hooks/prepare-commit-msg
#!/bin/sh
addMyBranchName() {
# Get name of current branch
NAME=$(git branch | grep '*' | sed 's/* //' | grep -o '[0-9]\+')
# First blank line is title, second is break for body, third is start of body
BODY=`cut -d \| -f 6 $1 | grep -v -E .\+ -n | cut -d ':' -f1 | sed '3q;d'`
# Put in string "(branch_name/): " at start of commit message body.
# For templates with commit bodies
if test ! -z $BODY; then
awk 'NR=='$BODY'{$0="refs #'$NAME'"}1;' $1 > tmp_msg && mv tmp_msg "$1"
else
echo "\n\nrefs #$NAME\n`cat $1`\n" > "$1"
fi
}
# You might need to consider squashes
case "$2,$3" in
# Commits that already have a message
commit,?*)
;;
# Messages are one line messages you decide how to handle
message,)
;;
# Merge commits
merge,)
# Comments out the "Conflicts:" part of a merge commit.
perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1"
;;
# Non-merges with no prior messages
*)
addMyBranchName $1
;;
esac
Комментариев нет:
Отправить комментарий