Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git and Mercurial: what would be equivalent of Git workflow in Mercurial?

Tags:

git

mercurial

#lets get the latest
git pull

#lets switch to branch and do some work
git checkout -b makeSomeBugs

#do the work commit
git add .
git commit -am "introducing some bugs"

#push this for my lazy remote friend to see
git push origin makeSomeBugs

#uh .. changes on master
git pull origin master

#do some work..
git commit -am "introducing some more bugs"
git push origin makeSomeBugs

#lets switch back to master
git checkout master
git pull

#work is done, lets merge
git merge --no-ff makeSomeBugs
git push origin

#and remove the branch to never ever see it again
git push origin :makeSomeBugs
git branch -d makeSomeBugs

Various blog sources (but they are quite old) say that branching like this in mercurial is no-go, especially with permanent branch removal...

like image 412
gerasalus Avatar asked Apr 24 '12 17:04

gerasalus


1 Answers

I might have some bits wrong because I may have misunderstood the git, but assuming you're using a recent version of Mercurial or if not, the bookmarks extension is enabled...

# lets get the latest
# git pull

hg pull

# lets switch to branch and do some work
# git checkout -b makeSomeBugs

hg bookmark makeSomeBugs

# do the work commit
# git add .
# git commit -am "introducing some bugs"

hg commit -m "introducing some bugs"

# push this for my lazy remote friend to see
# git push origin makeSomeBugs

hg push -B makeSomeBugs

# uh .. changes on master
# git pull origin master

hg pull
hg merge

# do some work..
# git commit -am "introducing some more bugs"
# git push origin makeSomeBugs

hg commit -m "introducing some more bugs"
hg push -B makeSomeBugs

# lets switch back to master
# git checkout master
# git pull

hg pull
hg update -C <name of master rev>

# work is done, lets merge
# git merge --no-ff makeSomeBugs
# git push origin

hg merge makeSomeBugs
hg push

# and remove the branch to never ever see it again
# (I assume you mean the label not the changesets)
# git push origin :makeSomeBugs
# git branch -d makeSomeBugs

hg bookmark -d makeSomeBugs
hg push -B makeSomeBugs

There's a couple of "mental model" differences, but I think it's pretty close. Biggest one is when you delete the bookmark. You delete it locally and then push that it's deleted. Reversed order from what you did with git.

There's also the question of what you use to identify the "master" head. If there was a bookmark already on the server for it (called master for example) the first line would become hg pull -B master, the first merge hg merge master and the update hg update -C master. Once you've pulled a bookmark the first time any subsequent pulls or pushes should update it without needing to explicitly mention it.

like image 139
Paul S Avatar answered Sep 24 '22 21:09

Paul S