public static List <SvnMergesEligibleEventArgs> GetMissingRevisions(IInputOutputHelper io, CommandLineParameters commandLineParameters) { var res = new List <SvnMergesEligibleEventArgs>(); var branchFirstRevision = SubversionHelper.GetFirstRevision(io, commandLineParameters.SourceRepository); if (!branchFirstRevision.HasValue) { io.WriteLine("No branch revisions found."); } else { io.WriteLine("Source branch was created in rev: " + branchFirstRevision.Value); var tasks = new List <Task>(); io.WriteLine("Getting revision information from source branch..."); var mergesEligible = new List <SvnMergesEligibleEventArgs>(); tasks.Add(Task.Factory.StartNew(delegate { var client = GetSvnClient(); var args = new SvnMergesEligibleArgs { Range = new SvnRevisionRange(new SvnRevision(branchFirstRevision.Value), new SvnRevision(SvnRevisionType.Head)), RetrieveChangedPaths = true, }; var list = client.ListMergesEligible(new Uri(commandLineParameters.TargetRepository), new Uri(commandLineParameters.SourceRepository), args, delegate(object sender, SvnMergesEligibleEventArgs e) { e.Detach(); mergesEligible.Add(e); }); })); io.WriteLine("Getting merged ranges in the target branch..."); var mergesMerged = new List <SvnMergesMergedEventArgs>(); tasks.Add(Task.Factory.StartNew(delegate { var client = GetSvnClient(); var args = new SvnMergesMergedArgs { Range = new SvnRevisionRange(new SvnRevision(branchFirstRevision.Value), new SvnRevision(SvnRevisionType.Head)), RetrieveChangedPaths = false, }; var list = client.ListMergesMerged(new Uri(commandLineParameters.TargetRepository), new Uri(commandLineParameters.SourceRepository), args, delegate(object sender, SvnMergesMergedEventArgs e) { e.Detach(); mergesMerged.Add(e); }); })); io.WriteLine("Please wait..."); Task.WaitAll(tasks.ToArray()); var missingRevisions = mergesEligible.Where(a => !mergesMerged.Any(b => b.Revision == a.Revision)).ToList(); res.AddRange(missingRevisions); } return(res); }
public LogRequest(SvnMergesMergedArgs args, EventHandler <SvnLoggingEventArgs> receivedItem) : this(args) { args.MergesMerged += ReceiveItem; ReceivedItem += receivedItem; }
void DoFetch(SvnLogArgs args) { LogRequest rq = _currentRequest = null; ShowBusyIndicator(); try { using (SvnClient client = _context.GetService <ISvnClientPool>().GetClient()) { SvnOrigin single = EnumTools.GetSingle(LogSource.Targets); if (single != null) { // TODO: Use peg information } List <Uri> uris = new List <Uri>(); foreach (SvnOrigin o in LogSource.Targets) { uris.Add(o.Uri); } switch (_mode) { case LogMode.Log: SvnLogArgs la = new SvnLogArgs(); la.AddExpectedError( SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES, // File not there, prevent exception SvnErrorCode.SVN_ERR_UNSUPPORTED_FEATURE); // Merge info from 1.4 server la.Start = args.Start; la.End = args.End; la.Limit = args.Limit; la.StrictNodeHistory = args.StrictNodeHistory; la.RetrieveMergedRevisions = args.RetrieveMergedRevisions; _currentRequest = rq = new LogRequest(la, OnReceivedItem); client.Log(uris, la, null); break; case LogMode.MergesEligible: SvnMergesEligibleArgs meArgs = new SvnMergesEligibleArgs(); meArgs.AddExpectedError( SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES, // File not there, prevent exception SvnErrorCode.SVN_ERR_UNSUPPORTED_FEATURE); // Merge info from 1.4 server meArgs.RetrieveChangedPaths = true; _currentRequest = rq = new LogRequest(meArgs, OnReceivedItem); client.ListMergesEligible(LogSource.MergeTarget.Target, single.Target, meArgs, null); break; case LogMode.MergesMerged: SvnMergesMergedArgs mmArgs = new SvnMergesMergedArgs(); mmArgs.AddExpectedError( SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES, // File not there, prevent exception SvnErrorCode.SVN_ERR_UNSUPPORTED_FEATURE); // Merge info from 1.4 server mmArgs.RetrieveChangedPaths = true; _currentRequest = rq = new LogRequest(mmArgs, OnReceivedItem); client.ListMergesMerged(LogSource.MergeTarget.Target, single.Target, mmArgs, null); break; } } } finally { // Don't lock here, we can be called from within a lock if (rq == _currentRequest) { _running = false; OnBatchDone(rq); } HideBusyIndicator(); } }