If you have changesets A, B, C, D, E in your repo and you execute hg update -c D, how can you confirm that your repo is currently 'active' with changeset D? If we run hg tip or hg head, HG lists E and not D.
There are several ways to find this out:
hg summary
hg identify
hg log -r .
Note that hg update actually changes the revision of your working copy, so you definitely should not use that.
Related
I have 2 branches in my Mercurial repository. 'default' and 'other'
default branch A - B - C - D
other branch E - F
I need to move B changeset to other branch.
So it will look like this:
default branch A - C - D
other branch E - F - B
Is it possible?
Thanks in advance!
Graft-based solution
Graft (hg help graft) B to target branch
Remove (histed extension) B from source branch (graft only make copy of changeset, without removing original)
Rebase-based solution
Rebase B to other branch
Because rebase move also descendants of rebased changeset - rebase C back to default
The following solution doesn't require enabling any extensions. It does assume the existence of the patch utility, though.
On default:
$ hg diff -c B > diff.out
$ hg backout --merge -r B
$ hg merge
$ hg ci
On other branch:
$ patch -p1 < diff.out
$ hg ci
Is there any way to force merge branch A in branch B where all possible conflicts will be resolved in favor of branch B?
In any words how to push last branch B revision in branch A without vanity around conflicts?
You can decide to take all of one branch over another by using hg merge --tool internal:other or hg merge --tool internal:local
I'm not sure which way you want to merge but if you want to merge A into B taking all changes from B then you would do the following:
> hg update B
> hg merge A --tool internal:local
> hg commit -m "Merge"
The internal:local merge tool will take the changes in the current revision (which is B because of the hg update B) over the changes in the other revision, internal:other would take all changes from A.
For more info use the following commands: hg help merge and hg help merge-tools
hg update develop --clean
remote: conq: repository does not exist.
abort: no suitable response from remote hg!
I would like to be able to switch to my develop branch, to undo my last 2 commits and merge the develop branch with tip or close it!
OR
just close and rename the branch, but since I can not update to it I don't know what to do.
I would like to: overwrite branch x with branch y:
hg update x
hg commit --close-branch -m 'closing branch x, will be overwriten with branch y'
hg update y
hg branch -f x
hg ci
but i can't update to x. How to fix/force this?
I used the MQ extension:
hg qinit
hg qimport -r 4:tip
hg qpop -a
hg qdelete 4.diff
hg qpush -a
hg qfinish -a
That worked but after a pull the removed stuff was back in..
But, I just created a new Branch one from tip using -f with the same name.
that works good enough for me. Can't remove the 'wrong' branch it since it is 'out of the bottle' published.
I just merged branch A into B, and for some reason the merge did not go well. I want to revert B back to where it was before the merge and try again like it never happened before. I was thinking of just doing
hg clone myrepo newrepo -r A -r 12345
where 12345 is the revision number before B's bad merge commit
I think this works, but I have a lot of other branches (most of which are closed using commit --close-branch) and this puts those branches back to an inactive state.
Is there a way to clone everything except revision 123456 or something? (where 123456 is the bad commit on B)
Assuming you have not pushed the merge changeset to any public location, the easiest solution is to use the hg strip command that comes with the Mercurial Queues (i.e. mq) extension.
From the wiki:
hg strip rev removes the rev revision
and all its descendants from a
repository. To remove an unwanted
branch, you would specify the first
revision specific to that branch. By
default, hg strip will place a backup
in the .hg/strip-backup/ directory. If
strip turned out to be a bad idea, you
can restore with hg unbundle
.hg/strip-backup/filename.
It might not be as nice as hg rollback, but usually what I do is update to head A, merge in previous head B, check that I got it right this time, and then dummy-merge away the bad merge.
I hope I'm understanding your situation correctly. If I am you should be able to update to the revision of B before the merge, give that revision a new branch name, merge A in to it, and continue on. You'll probably want to mark the original B branch as closed.
$ hg up 12345 #12345 is the revision of B prior to the merge
$ hg branch B-take2
$ hg merge A
$ hg commit -m 'merge A in to B-take2'
$ hg up B
$ hg commit --close-branch -m 'mark original B branch as closed'
Is it too late to use the hg rollback command? If so, try the hg backout command.
I want to move a changeset from one branch to another. Basically, I currently have:
A -> B -> C -> D # default branch
And I want:
A # default branch
\-> B -> C -> D # some_new_branch
Where some_new_branch does not exist yet. I am used to git, so I guess there is a simple "mercurial" way I am missing.
One way is to export a patch for B,C,D; update to A; branch; apply patch:
hg export -o patch B C D
hg update A
hg branch branchname
hg import patch
To remove B,C,D from the default branch, use the mq extension's strip command.
Sounds a bit like a cherry-pick operation in git. The Transplant Extension may be what you're looking for.
With Mercurial Queue:
# mark revisions as draft in case they were already shared
#hg phase --draft --force B:D
# make changesets a patch queue commits
# (patches are stored .hg/patches)
hg qimport -r B:D
# pop changesets from current branch
hg qpop -a
#
hg branch some_new_branch
# push changesets to new branch
hg qpush -a
# and make them commits
hg qfinish -a
Without comments:
hg qimport -r B:D
hg qpop -a
hg branch some_new_branch
hg qpush -a
hg qfinish -a
Alternative to transplant or patch, you could use graft.
hg update A
hg branch branchname
hg graft -D "B:D"
hg strip B
Note that changing history is bad practice. You should strip only if you haven't pushed yet. Otherwise, you could still backout your changes.