Fixing my branches
Paul Moore
p.f.moore at gmail.com
Thu Mar 3 16:42:35 UTC 2016
Hi,
I'm doing some work on a repository hosted on bitbucket and using
Mercurial, and I think I've set up a pull request wrongly (I use git
and github most of the time these days, so I'm pretty rusty with
mercurial...) What's the best way of tidying things up?
What I did was as follows. I forked the source repository on bitbucket
and cloned my fork onto my PC. Then I did some work, committed it, and
created a PR from it. I later made a few more changes and pushed them
to my fork, and they turned up in the PR. That wasn't what I'd
intended, but in this case was OK. I presume that's because I was
working on the default branch in my repo and the PR was between my
default and upstream default.
However, I now want to make some new changes for another PR. My first
PR hasn't been accepted yet, so I don't want to put the new changes on
top of what I have. But I've no longer got a "default" branch that is
tracking upstream, so I can't make changes against that (at least, not
easily - I know I can look up the changeset ID and update to that, but
that's a bit fiddly). What I guess I should have done was create a new
named branch for my first PR, so that "default" remained tracking
upstream and my new branch lived separately. Can I now fix that, so
"default" refers to where upstream is, and I have a new branch with
what's in my PR (ideally, doing this without having to recreate my
PR)? I'll then create my new PR as a second branch from default, and
we're OK again.
However, the reasons this seems like it might be a bad idea to me are:
1. I thought named branches were not intended to be used quite as
freely as I use them in git, for short-lived changes like this.
2. As named branches are permanent, I guess I can't reuse names? In
git, I create a branch "test_fixes", make a PR, then delete the branch
once it's merged. I can then use "test_fixes" as a branch name when I
next fix up a test. I'm not sure how I'd do the same in Mercurial.
I know people recommend bookmarks for this situation, but I'm not sure
how they would work. What should I have done at the start to tag
"what's tracking upstream" as my default bookmark? And how would
Mercurial know that pulls from upstream are added to that bookmark?
For my PR changes, do I name them (with a bookmark, again) *after*
I've created them, rather than saying "create a bookmark test_fixes,
then add some commits to it" as I would with a branch (in git or
mercurial)? And how do I create my PR to say that it's between this
bookmark and upstream? There's no option in bitbucket that I can see
to create a PR from a bookmark rather than from a branch.
I apologise if this is all a bit basic. I tried searching the web for
how to manage this sort of workflow, but I couldn't find much (which
surprised me a bit, as surely pull requests on bitbucket are a pretty
common thing?)
Thanks for any help,
Paul
More information about the Mercurial
mailing list