How do I fix a bug in a previous release version v

2019-04-12 21:46发布

问题:

We are using mercurial in a single repository. We have a master branch and a develop branch (as well as feature branches, but they aren't germane to the issue at hand).

We tag the master branch with releases (5.1.0.102, etc). We do our development on develop.

But now we want to fix a bug in a previous version. There are a lot of questions here on SO about this issue, but none of them seem to explain what I want to do.

What I want to do is this:

  1. Update to the point where we released (say 6.1.1)
  2. Fix a number of bugs in that release
  3. Label that resulting code state as (6.1.2)
  4. Do a build of this new 6.1.2 codebase.
  5. Migrate those fixes into the develop branch
  6. Do this in such a way that I can go back to 6.1.2 and fix bugs there if need be.

I can't seem to do this via updating. I tried to update to the 6.1.1, create a branch, and go from there, but that brings in the tip of the master branch, including all subsequent changes.

Is there a standard way of doing this? Did I explain that correctly so you guys get what I need to do? It seems like this is a pretty common thing to do.

回答1:

You don't need to explicitly create a branch. The way I would do it is this:

  1. Update to the point where you released (6.1.1 in the master branch).
  2. Make changes and commit them.
  3. Tag the latest commit in master as 6.1.2.
  4. Pull those changes into the develop branch.
  5. Continue working.

If you need to make more changes, then simply repeat the above but using the 6.1.2 tag in the master branch.



回答2:

You really shouldn't need to create a named branch unless you truly want to have a full-out branch. What you probably want to do is:

  1. update to 6.1.1
  2. make the edits
  3. commit (will create a new un-named branch)
  4. tag that new revision as 6.1.2.
  5. You can then merge that edit into your develop branch

As long as you are updating to a revision earlier than the tip on the Master branch, the commit will make a new branch off of it.

This will leave the version tagged so you can easily get back to it.