views:

463

answers:

11

Is there any way of easily deciphering (i.e. at a glance) whether or not a branch has already previously been merged with the another branch or the trunk? The nearest I've been able to figure out is by looking at the commit notes and displaying the merged commit notes. The disadvantage with this seems to be that unless you know which branch the commit notes are imported from, there's no way to decipher which branches have already been merged or not.

Edit: Is Mercurial or Git any more intuitive than SVN for this?

A: 

If you have access to TortoiseSVN and the repo is version 1.5 or later, you could look at repository graph it generates. However SVN in general makes it a pain to track merges.

chotchki
So true, tracking merges can be hard. Unless you use hook scripts on the server but I'd rather have that by default.
RedGlyph
+2  A: 

If you have a version of the server which is at least 1.5 as mentioned by chotchki, and your repository has been created with such a version or upgraded, the property svn:mergeinfo is added to any directory in which a merge has occurred.

Let's say you have reintegrated two branches in the trunk, you can check with (replace with your URL):

svn propget svn:mergeinfo svn://localhost/Test/trunk

which branches have been merged and which revisions they modified. Example of output:

/branches/dev/1:35-36
/branches/dev/2:38-39

With a GUI client like TortoiseSVN, check at the graph or look at the properties of the target directory in the repo-browser.

RedGlyph
I'm not particulary averse at using the command line, but what's with the resurgence of the love affair with the command line when it comes to version control systems? Aren't there any pretty visual tools for this?
BobTheBuilder
TortoiseSVN is the one if you're using Windows, for Linux I'm not really up-to-date, so I'm using the command-line. I suppose people love to give the command-line version for those who love scripts, or are Linux users ;-)
RedGlyph
Jim T
+1  A: 

This isn't entirely relevant to the question, but I thought it might be useful in your ongiong quest for version control systems: http://versioncontrolblog.com/comparison/Git/Mercurial/Subversion/Visual%20SourceSafe/index.html

BenAlabaster
A: 

You can use svnmerge.py to manage the branches. It tells you which branches have already been merged and it only merges new revisions.

fernyb
A: 

You could try to execute the merge with the --dry-run option and examine the output (i.e. see if it wants to do the merge or not).

Personally, when I merge one branch with another I record the exact range of revision numbers in the commit message.

Ether
+10  A: 

Is Mercurial or Git any more intuitive than SVN for this?

Yes, very much so:

sjl at ecgtheow in ~/src/hg-review on webui at tip
[10] $ hg glog
@  changeset: 113:c5debb475273 Steve Losh tip webui
|  summary:   Add file folding.
|
o  changeset: 112:a3ad66636756 Steve Losh  webui
|  summary:   Show skipped-line comments.
|
o  changeset: 111:2e65351af702 Steve Losh  webui
|  summary:   Rough cut of line-level comments.
|
| o  changeset: 110:b599ca22418d Steve Losh  
|/|  summary:   Merge the bug fix.
| |
o |  changeset: 109:e2ddb8631463 Steve Losh  webui
| |  summary:   Fix the event not defined bug.
| |
| o  changeset: 108:001f5ecfd9bc Steve Losh  
|/|  summary:   Merge the webui skipped line counts -- too important to leave in the
| |             branch.
| |
o |  changeset: 107:1cc8e18b1b43 Steve Losh  webui
| |  summary:   Add skipped line counts to diffs.
| |

EDIT: Git has a git log --graph option that's pretty much the same as Mercurial's, except without the helpful you-are-here @ character.

Steve Losh
+8  A: 

On git, you can use git log to ask if one branch includes another:

git log topic ^master # list all commits in branch 'topic', but not in 'master'

If nothing is returned, topic has been merged.

bdonlan
+3  A: 

Type:

svn help mergeinfo

And you get:

mergeinfo: Display merge-related information.
usage: mergeinfo SOURCE[@REV] [TARGET[@REV]]

  Display information related to merges (or potential merges) between
  SOURCE and TARGET (default: '.').  If the --show-revs option
  is not provided, display revisions which have been merged from
  SOURCE to TARGET; otherwise, display the type of information
  specified by the --show-revs option.

Valid options:
  -r [--revision] ARG      : ARG (some commands also take ARG1:ARG2 range)
                             A revision argument can be one of:
                                NUMBER       revision number
                                '{' DATE '}' revision at start of the date
                                'HEAD'       latest in repository
                                'BASE'       base rev of item's working copy
                                'COMMITTED'  last commit at or before BASE
                                'PREV'       revision just before COMMITTED
  --show-revs ARG          : specify which collection of revisions to display
                             ('merged', 'eligible')
Bert Huijben
+2  A: 

In Git, you can use git branch --merged <commit>, which lists all branches which are reachable from given commit (<commit> defaults to HEAD, which means that git branch --merged would list all branches merged into current commit).

Or you can use git show-branch branch1 branch2 or git log --graph --oneline branch1 branch2 to see history graphically (or use some graphical history browser like gitk, QGit, Giggle, GitX, etc.).

Jakub Narębski
+4  A: 

In git, you can use --contains to list branches that contain other branches:

git branch -a --contains feature

will show all branches (with -a, that includes remote branches) that have merged the given feature.

git show-branch will show lots of details of the relationships between branches. It takes a bit of time to learn to read it effectively, but it's very valuable and will show you a lot in a small amount of space.

Dustin
+1  A: 

To just see which branches are merged or not with a particular branch, I found Jakub's reply most useful, and the related command:

git branch --no-merged

From git help:

With --no-merged only branches not merged into the named commit will be listed.

Alison