I found "glog" (enabled by graphlog= under [extensions] in hgrc file)
to be useful to understand what was happening.
Resulting history of main repo:
c:\prj\hg\rebasetst\mainrepo>hg glog
@ changeset: 2:74a8f755828a
| tag: tip
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:20:21 2011 +0100
| summary: new feature added
|
o changeset: 1:79bc50abae62
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:22:42 2011 +0100
| summary: bugfix
|
o changeset: 0:70dd5255611d
user: Olof Bjarnason <olof.bj...@gmail.com>
date: Sat Nov 05 14:16:21 2011 +0100
summary: first commit
The "bugfix" commit was done on the main repo, while the "new feature
added" commit was on a fork repo. The fork's history looks the same:
c:\prj\hg\rebasetst\fork>hg glog
@ changeset: 2:74a8f755828a
| tag: tip
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:20:21 2011 +0100
| summary: new feature added
|
o changeset: 1:79bc50abae62
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:22:42 2011 +0100
| summary: bugfix
|
o changeset: 0:70dd5255611d
user: Olof Bjarnason <olof.bj...@gmail.com>
date: Sat Nov 05 14:16:21 2011 +0100
summary: first commit
Now I want to add branches to the mix.
2011/11/5 Samuel Ytterbrink <nep...@gmail.com>:
Scenario: I'm working on a big feature in a branch called "some_issue"
on a repo i call "fork-temp3" locally. I want to get the latest bug
fix from "mainrepo", and I want to rebase my feature branch on it.
Here's the glog before doing the rebase:
c:\prj\hg\rebasetst\fork-temp3>hg glog
o changeset: 5:c9087541446b
| tag: tip
| parent: 2:74a8f755828a
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:44:36 2011 +0100
| summary: bugfix 2
|
| @ changeset: 4:331c15bca358
| | branch: some_issue
| | user: Olof Bjarnason <olof.bj...@gmail.com>
| | date: Sat Nov 05 14:45:44 2011 +0100
| | summary: Fixed the issue
| |
| o changeset: 3:62b9651ab02b
|/ branch: some_issue
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:41:49 2011 +0100
| summary: fixing some issue on this branch
|
o changeset: 2:74a8f755828a
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:20:21 2011 +0100
| summary: new feature added
|
o changeset: 1:79bc50abae62
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:22:42 2011 +0100
| summary: bugfix
|
o changeset: 0:70dd5255611d
user: Olof Bjarnason <olof.bj...@gmail.com>
date: Sat Nov 05 14:16:21 2011 +0100
summary: first commit
As you can see, bugfix 2 has been pulled (ordinary hg pull from main
repo) into my fork-temp3 repo. Also notice the some_issue branch, the
one to the right above.
Now I want to move changeset 3 and 4 (my feature branch) "on top of"
5, the bug fix, so that it is applied "before" my feature branch in
time (and changeset history).
I have to specify what changeset I want "rebased" -- that's the first
changeset of my feature branch, namely 3. This is called the "source"
of the rebase. Figuratively, where to make the "cut" in the graphical
log tree.
Then I have to specify what changeset to placed this "cut off branch".
That is the bugfix2 changeset, named 5 in the glog.
So the full command to do the rebase when working with branches in hg is:
hg rebase -s 3 -d 5 --keepbranches
(the last flag if to keep the named branches, which we want to do
since we're not finished with our some_issue feature branch just yet).
Graphlog after this command:
c:\prj\hg\rebasetst\fork-temp3>hg glog
@ changeset: 4:fa2fbf021264
| branch: some_issue
| tag: tip
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:45:44 2011 +0100
| summary: Fixed the issue
|
o changeset: 3:c9087541446b
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:44:36 2011 +0100
| summary: bugfix 2
|
o changeset: 2:74a8f755828a
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:20:21 2011 +0100
| summary: new feature added
|
o changeset: 1:79bc50abae62
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:22:42 2011 +0100
| summary: bugfix
|
o changeset: 0:70dd5255611d
user: Olof Bjarnason <olof.bj...@gmail.com>
date: Sat Nov 05 14:16:21 2011 +0100
summary: first commit
Notice that it's one changeset less than previously; the changeset
that disappered was the "I have built a new branch and have to
commit"-changeset.
This is the first time I've done a rebase operation, but it sure isn't
the easiest thing to grasp in the DVCS world. I guess git does this
more "naturally" than hg?
2011/11/5 Olof Bjarnason <olof.bj...@gmail.com>:
It doesn't show in the glog, since some_issue is based on it and there
is no newer changeset than those of some_issue.
So after adding a file in main repo, and pulling it into fork-temp3, I
got it visibly back again:
c:\prj\tmp\rebasetst\fork-temp3>hg glog
o changeset: 5:b4b6a7d3221e
| tag: tip
| parent: 3:c9087541446b
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sun Nov 06 07:32:40 2011 +0100
| summary: New file
|
| @ changeset: 4:fa2fbf021264
|/ branch: some_issue
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:45:44 2011 +0100
| summary: Fixed the issue
|
o changeset: 3:c9087541446b
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:44:36 2011 +0100
| summary: bugfix 2
|
o changeset: 2:74a8f755828a
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:20:21 2011 +0100
| summary: new feature added
|
o changeset: 1:79bc50abae62
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:22:42 2011 +0100
| summary: bugfix
|
o changeset: 0:70dd5255611d
user: Olof Bjarnason <olof.bj...@gmail.com>
date: Sat Nov 05 14:16:21 2011 +0100
summary: first commit
hg rebase -s 4 -d 5 --keepbranches got me:
c:\prj\tmp\rebasetst\fork-temp3>hg glog
@ changeset: 5:27279a77a025
| branch: some_issue
| tag: tip
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:45:44 2011 +0100
| summary: Fixed the issue
|
o changeset: 4:b4b6a7d3221e
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sun Nov 06 07:32:40 2011 +0100
| summary: New file
|
o changeset: 3:c9087541446b
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:44:36 2011 +0100
| summary: bugfix 2
|
o changeset: 2:74a8f755828a
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:20:21 2011 +0100
| summary: new feature added
|
o changeset: 1:79bc50abae62
| user: Olof Bjarnason <olof.bj...@gmail.com>
| date: Sat Nov 05 14:22:42 2011 +0100
| summary: bugfix
|
o changeset: 0:70dd5255611d
user: Olof Bjarnason <olof.bj...@gmail.com>
date: Sat Nov 05 14:16:21 2011 +0100
summary: first commit
> and what i did wich dident work was when i needed to rebase to 2 different
> issues then merge 1 and rebase teh other..
I guess you would do one after the other?
A comment about the rebase: If the branch has a lot of commits, it
might be inconvenient to find the number of the first commit (with
glog for example). But rebase has a convenience version of "source"
called "base" (-b). With -b it is enough to specify any one of the
commits' numbers on the branch (for example, the latest), and then
rebase will look up the first commit on that branch automatically, and
make the cut there.
Remember to add the --keepbranches flag (not the first time hg forces
us to add flags which seem to be the default, I remember something
similar going on when closing a branch).