SVN: Track merges
Asked Answered
S

3

1

Is it possible in SVN 1.6 to track where a commit was merged. I'm especially interesting in UI based solution (Eclipse plugin will be great).

Sanasanabria answered 4/7, 2009 at 18:9 Comment(5)
You have to be a little more specific, because the notion of "merging a commit" doesn't work 100% in subversion.Siebert
I've a commit which have to be merged in couple branches. Later I wish to known in which branches (where and whom) the commit was merged. It works in opposite way (merged commit shows it's origin).Sanasanabria
The difficulty of merging and managing merges with SVN is the reason we switched to P4. I think your best bet may be to just grep for the changed line across the repo and see which branches it shows up in.Stylographic
svnbook.red-bean.com/nightly/en/svn.ref.svn.c.mergeinfo.htmlCorin
The best way to track merges in SVN I found was to use very descriptive commit messages.Weingartner
S
1

Thank you for all answered person (special thanks to derobert and Jim T). I write my own code using svnkit 1.2.x that do what I exactly need.

private static void showMergedRevision(String pFromUrl, String pToUrl) throws SVNException {
    List<String> folders= new ArrayList<String>();
    folders.add("Folder1");
    ...

    SVNRepositoryFactoryImpl.setup();

     String name="user";
     String password="password";

     ISVNOptions options = SVNWCUtil.createDefaultOptions( true );

     ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);

     SVNClientManager ourClientManager = SVNClientManager.newInstance( options , authManager );

     final Set<Long> mergedRevision = new HashSet<Long>();        
     for(String folder : folders){
         SVNURL svnFrom = SVNURL.parseURIDecoded(pFromUrl + "/" + folder);
         SVNURL svnTo = SVNURL.parseURIDecoded(pToUrl+ "/" + folder);
         ISVNLogEntryHandler mergedLogger = new ISVNLogEntryHandler() {
            public void handleLogEntry(SVNLogEntry pParamSVNLogEntry) throws SVNException {
                mergedRevision.add(pParamSVNLogEntry.getRevision());
            }
        };
        ourClientManager.getDiffClient().doGetLogMergedMergeInfo(svnTo, SVNRevision.HEAD, svnFrom, SVNRevision.HEAD, false, null, mergedLogger);
     }

     System.out.println(String.format("Tracking merges from [%s] to [%s].", pFromUrl, pToUrl));
     System.out.println("Comparing folders: " + folders);

     SVNURL svnUrlorg = SVNURL.parseURIDecoded(pFromUrl);
     ISVNLogEntryHandler histroyLogger= new ISVNLogEntryHandler() {
        public void handleLogEntry(SVNLogEntry pParamSVNLogEntry) throws SVNException {
            if (pParamSVNLogEntry.getRevision() < 0){
                // Sometimes got -1 null null null values. Skip them
                return;
            }
            final boolean merged = mergedRevision.contains(pParamSVNLogEntry.getRevision());
            System.out.println(String.format("%s %s: %s %s %s", merged ? "[+]": "[-]", 
                    pParamSVNLogEntry.getRevision(), 
                    pParamSVNLogEntry.getAuthor(), pParamSVNLogEntry.getDate(), 
                    pParamSVNLogEntry.getMessage()));
        }
    }; 
    ourClientManager.getLogClient().doLog(svnUrlorg, null, SVNRevision.HEAD, SVNRevision.create(0), SVNRevision.HEAD, true, false, false, -1, null, histroyLogger);
}

The output will be:

[-] 7210: boa 03.07.2009
[-] 7211: boa 03.07.2009
[+] 7215: boa 03.07.2009

[+] means merged revision, [-] - unmerged.

Sanasanabria answered 5/7, 2009 at 20:40 Comment(0)
T
9

I once wrote a quite web-page that kind of did this. I can't give you the page, unfortunately, but I can give you an idea of what I did.

First our development model - all development made to trunk, revisions then get merged into various release branches for different versions of products.

I set up a web page with a column for each version and a row for each trunk revision. By running svn mergeinfo for each column, I got back the list of trunk revisions that had been merged in to that version.

So we ended up with something very similar to those feature comparison lists you get - a table showing a black dot for each version that contained the corresponding trunk commit.

Looked a bit like this:

rev   |  ver1  |  ver1.1  |  ver2  | ver2.1  |
200   |        |          |        |    X    |
198   |        |    X     |        |    X    |
177   |        |          |        |    X    |
176   |        |          |   X    |    X    |
157   |   X    |    X     |   X    |    X    |
146   |   X    |    X     |   X    |    X    |
122   |   X    |    X     |   X    |    X    |
075   |   X    |    X     |   X    |    X    |

This let us see exactly what each version contained (useful for testing), as well as highlighting if any revisions were merged into one place but not another.

Theall answered 4/7, 2009 at 20:0 Comment(2)
+1 Very nice idea. Feature request for svn mergeinfotable -r 200:75 --source repo/branches , anyone?Siebert
+1 I just built something like this for our team and it's proven very useful. Thanks for sharing the idea.Readymade
T
2

If you want to use an Eclipse plugin, you could try Subclipse. It is really easy to use and has been very useful to me in merging conflicted files and branching, merging branches etc... Here are some screenshots.

Teerell answered 6/7, 2009 at 7:46 Comment(0)
S
1

Thank you for all answered person (special thanks to derobert and Jim T). I write my own code using svnkit 1.2.x that do what I exactly need.

private static void showMergedRevision(String pFromUrl, String pToUrl) throws SVNException {
    List<String> folders= new ArrayList<String>();
    folders.add("Folder1");
    ...

    SVNRepositoryFactoryImpl.setup();

     String name="user";
     String password="password";

     ISVNOptions options = SVNWCUtil.createDefaultOptions( true );

     ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);

     SVNClientManager ourClientManager = SVNClientManager.newInstance( options , authManager );

     final Set<Long> mergedRevision = new HashSet<Long>();        
     for(String folder : folders){
         SVNURL svnFrom = SVNURL.parseURIDecoded(pFromUrl + "/" + folder);
         SVNURL svnTo = SVNURL.parseURIDecoded(pToUrl+ "/" + folder);
         ISVNLogEntryHandler mergedLogger = new ISVNLogEntryHandler() {
            public void handleLogEntry(SVNLogEntry pParamSVNLogEntry) throws SVNException {
                mergedRevision.add(pParamSVNLogEntry.getRevision());
            }
        };
        ourClientManager.getDiffClient().doGetLogMergedMergeInfo(svnTo, SVNRevision.HEAD, svnFrom, SVNRevision.HEAD, false, null, mergedLogger);
     }

     System.out.println(String.format("Tracking merges from [%s] to [%s].", pFromUrl, pToUrl));
     System.out.println("Comparing folders: " + folders);

     SVNURL svnUrlorg = SVNURL.parseURIDecoded(pFromUrl);
     ISVNLogEntryHandler histroyLogger= new ISVNLogEntryHandler() {
        public void handleLogEntry(SVNLogEntry pParamSVNLogEntry) throws SVNException {
            if (pParamSVNLogEntry.getRevision() < 0){
                // Sometimes got -1 null null null values. Skip them
                return;
            }
            final boolean merged = mergedRevision.contains(pParamSVNLogEntry.getRevision());
            System.out.println(String.format("%s %s: %s %s %s", merged ? "[+]": "[-]", 
                    pParamSVNLogEntry.getRevision(), 
                    pParamSVNLogEntry.getAuthor(), pParamSVNLogEntry.getDate(), 
                    pParamSVNLogEntry.getMessage()));
        }
    }; 
    ourClientManager.getLogClient().doLog(svnUrlorg, null, SVNRevision.HEAD, SVNRevision.create(0), SVNRevision.HEAD, true, false, false, -1, null, histroyLogger);
}

The output will be:

[-] 7210: boa 03.07.2009
[-] 7211: boa 03.07.2009
[+] 7215: boa 03.07.2009

[+] means merged revision, [-] - unmerged.

Sanasanabria answered 5/7, 2009 at 20:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.