简体   繁体   中英

C# SharpSvn: merge specific revisions from one branch to another

I have a list of revisions I'd like to merge, but I'd also like to exclude every other revision between that's not in the list:

List<Revisions> revisions = new List<Revisions>();
revisions.Add(new Revisions { IssueNumber = "ISSUE-1", Revision = 41757 });
revisions.Add(new Revisions { IssueNumber = "ISSUE-2", Revision = 42145 });
//revisions.Add(new Revisions { IssueNumber = "ISSUE-3", Revision = 42192});
revisions.Add(new Revisions { IssueNumber = "ISSUE-4", Revision = 42891 });

The problem I'm having is that I'm only able to merge from the current working directory revision all the way to the last revision in the list. It still includes the commented out revision in the range.

SvnMergeArgs mergeArgs = new SvnMergeArgs();
mergeArgs.Depth = SvnDepth.Infinity;
SvnUriTarget MyTarget = new SvnUriTarget(new Uri(trunk.Url));
foreach (var item in revisions) 
{
    SvnRevisionRange svnRange = new SvnRevisionRange(statuses.LastChangeRevision, item.Revision);
    _svnClient.Merge(_workingdir, MyTarget, svnRange, mergeArgs);
}

Is there any way to exclude every other revision in the range that's not in the list?

You can try the below approach. Create the SvnRevisionRange object from "item.Revision - 1" to item.Revision. This will include only one revision in the Merge ie item.Revision.

SvnRevisionRange svnRange = new SvnRevisionRange(item.Revision - 1, item.Revision);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM