3

I am familiar with SVN and TFS for source control. One issue which I usually encounter is the same file is modified for different bugs (say bugP is fixed with revision/changeset (N), bugQ is fixed with revision(N+1) and bugR is fixed in revision/changeset(N+2)

Each revision/changeset work on different part of the same file and there is no overlap.

Stakeholders decide that it is important that we include the fix for bugR in the next build but exclude bugP and bugQ fixes.

I understand that this might be a very common scenario. If all the fixes were done in the same branch/trunk, is there a easy way to pull only those revisions which fix a particular bug ?

And does other source control systems like GIT/Mercurial (Hg- is the standard way to say that, I understand) to deal with these kind of issues ?

ram
  • 11,468
  • 16
  • 63
  • 89
  • Are you looking into switching source control systems, or are you trying to get the question answered how to do this in a certain system? What system do you need the solution for? – Sander Rijken Jan 11 '10 at 17:34
  • 1.Nope:I am not planning to switch version control now. I am using TFS and have also encountered the same problem with SVN earlier. 2. In future, if I was going to pick a source control, answers here would help me decide which one to pick – ram Jan 11 '10 at 17:43

5 Answers5

1

Git has the ability to pick out single commits which you want to integrate into your tree. Assuming the bug fixes were separate commits, you can pick and choose which ones you want to apply to your current tree. The command used it cherry-pick.

I presume this is what you've looking for?

I haven't used Mercurial but this answer discusses the issue.

Community
  • 1
  • 1
Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
1

Git also has the fantastically useful command rebase -i which allows you to select commits to keep or delete from a list. In your example, you should checkout the combined set of changes, and then use

git rebase -i OLDEST_COMMIT_IN_THE_SET^

and then in the following list:

pick 03315fa fix for feature A
pick 2935567 fix for feature B
pick 4d31103 more fixes for feature A
pick 875ca6d fix for feature C
pick f0289e6 undo some broken fixes for feature A
pick 1f84de2 more fixes for feature B

# Rebase 5c50390..1f84de2 onto 5c50390
#
# Commands:
#  p, pick = use commit
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#

simply delete the lines corresponding to the commits you don't want - i.e. all lines that don't contain the phrase feature A. Then save the file, quit the editor, and let git do all the work for you.

Alex Brown
  • 41,819
  • 10
  • 94
  • 108
  • 1
    Mercurial has this feature as well in the form of the Histedit Extension: http://mercurial.selenic.com/wiki/HisteditExtension – Steve Losh Jan 11 '10 at 18:52
0

TFS does allow selective merging (merging only certain changesets and/or only certain files within a changeset). When you merge, just choose "Selected changesets" on the first page in the Merge Wizard and then pick the changesets you want to include. To merge only certain files, you can either right click on the file you want to merge and select merge or you can merge a higher level and then undo your checkout of the files you don't want merged (these files will then be available next time you want to merge).

Chris Shaffer
  • 32,199
  • 5
  • 49
  • 61
0

You can cherry-pick in SVN too. For the scenario you describe,

bugP is fixed with revision/changeset (N), bugQ is fixed with revision(N+1) and bugR is fixed in revision/changeset(N+2)…we include the fix for bugR in the next build but exclude bugP and bugQ fixes.

in SVN you would do something like

svn copy svn://path/to/trunk svn://path/to/branch -r N+2 -m "Made a branch"
svn checkout svn://path/to/branch
# do a reverse merge (note negative revision numbers)
svn merge -c -N+1,-N svn://path/to/trunk

This would give you a working copy with the fix for bugR but not bugP or bugQ.

Michael Hackner
  • 8,605
  • 2
  • 27
  • 29
0

With SVN you would create a release branch based on some revision of trunk, and selectively merge in the changes you need there (with cherry picking merges). That also documents what (customer specific) release contains what fixes.

Sander Rijken
  • 21,376
  • 3
  • 61
  • 85