private bool CheckForRemoteRevision(ConflictData item) { if (!string.IsNullOrEmpty(item.Remote.Filename)) { return(true); } string caption = string.Format(fileModifiedLocallyAndDelededRemotelyLong.Text, item.Filename, GetLocalSideString(), GetRemoteSideString()); using (var frm = new FormModifiedDeletedCreated(string.Format(keepModifiedButtonText.Text + " ({0})", GetLocalSideString()), string.Format(deleteFileButtonText.Text + " ({0})", GetRemoteSideString()), keepBaseButtonText.Text, caption)) { frm.ShowDialog(this); if (frm.KeepBase) //base { ChooseBaseOnConflict(item.Filename); } if (frm.KeepLocal) //delete { ChooseLocalOnConflict(item.Filename); } if (frm.KeepRemote) //remote { Module.RunGitCmd("rm -- \"" + item.Filename + "\""); } } return(false); }
/// <summary> /// Returns all <see cref="ConflictData"/>s for a set of new <see cref="AccessPoint"/> candidates. /// </summary> /// <param name="accessPoints">The set of <see cref="AccessPoint"/>s candidates to build the list for.</param> /// <param name="appEntry">The <see cref="AppEntry"/> the <paramref name="accessPoints"/> are intended for.</param> /// <returns>A dictionary of <see cref="AccessPoint.GetConflictIDs"/> mapping to the according <see cref="ConflictData"/>.</returns> /// <exception cref="ConflictException">There are inner conflicts within <paramref name="accessPoints"/>.</exception> /// <seealso cref="AccessPoint.GetConflictIDs"/> public static IDictionary <string, ConflictData> GetConflictData(this IEnumerable <AccessPoint> accessPoints, AppEntry appEntry) { #region Sanity checks if (accessPoints == null) { throw new ArgumentNullException(nameof(accessPoints)); } if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var newConflictIDs = new Dictionary <string, ConflictData>(); foreach (var accessPoint in accessPoints) { foreach (string conflictID in accessPoint.GetConflictIDs(appEntry)) { var conflictData = new ConflictData(accessPoint, appEntry); try { newConflictIDs.Add(conflictID, conflictData); } #region Error handling catch (ArgumentException) { throw ConflictException.InnerConflict(conflictData, newConflictIDs[conflictID]); } #endregion } } return(newConflictIDs); }
private bool CheckForBaseRevision(ConflictData item) { if (!string.IsNullOrEmpty(item.Base.Filename)) return true; string caption = string.Format(fileCreatedLocallyAndRemotelyLong.Text, item.Filename, GetLocalSideString(), GetRemoteSideString()); using (var frm = new FormModifiedDeletedCreated(string.Format(chooseLocalButtonText.Text + " ({0})", GetLocalSideString()), string.Format(chooseRemoteButtonText.Text + " ({0})", GetRemoteSideString()), deleteFileButtonText.Text, caption)) { frm.ShowDialog(this); if (frm.KeepBase) // delete Module.RunGitCmd("rm -- \"" + item.Filename + "\""); if (frm.KeepLocal) // local ChooseLocalOnConflict(item.Filename); if (frm.KeepRemote) // remote ChooseRemoteOnConflict(item.Filename); } return false; }
private void BinairyFilesChooseLocalBaseRemote(ConflictData item) { string caption = string.Format(_fileBinairyChooseLocalBaseRemote.Text, item.Local.Filename, GetLocalSideString(), GetRemoteSideString()); using (var frm = new FormModifiedDeletedCreated(string.Format(_chooseLocalButtonText.Text + " ({0})", GetLocalSideString()), string.Format(_chooseRemoteButtonText.Text + " ({0})", GetRemoteSideString()), _keepBaseButtonText.Text, caption)) { frm.ShowDialog(this); if (frm.KeepBase) { // base ChooseBaseOnConflict(item.Filename); } if (frm.KeepLocal) { // local ChooseLocalOnConflict(item.Filename); } if (frm.KeepRemote) { // remote ChooseRemoteOnConflict(item.Filename); } } }
public static List <ConflictData> MipsConflictLines_RAW(string[] mipsInput) { List <ConflictData> conflictDatas = new List <ConflictData>(); for (int i = 0; i < mipsInput.Length; i++) { if (MipsIsWrite(mipsInput[i])) { string[] splitedCommand = Helper.RemoveExtraSpaces(mipsInput[i]).Split(DELIMITERS); ConflictData conflict = new ConflictData(i); bool conflicted = false; if (i + 1 < mipsInput.Length) { List <string> splitedCommandNext = Helper.RemoveDecimals(Helper.RemoveExtraSpaces(mipsInput[i + 1])).Split(DELIMITERS).ToList(); splitedCommandNext.RemoveAt(0); if (MipsIsWrite(mipsInput[i + 1])) { if (!mipsInput[i + 1].Contains("(")) { splitedCommandNext.RemoveAt(0); } } if (splitedCommandNext.Any(x => x.ToUpper().Contains(splitedCommand[1].ToUpper()))) { //Read After Write - Se a proxima linha conter leitura e a linha anterior for escrita = conflito conflict.AddConflictWith(i + 1); conflicted = true; } } if (i + 2 < mipsInput.Length) { List <string> splitedCommandNext = Helper.RemoveDecimals(Helper.RemoveExtraSpaces(mipsInput[i + 2])).Split(DELIMITERS).ToList(); splitedCommandNext.RemoveAt(0); if (MipsIsWrite(mipsInput[i + 2])) { if (!mipsInput[i + 2].Contains("(")) { splitedCommandNext.RemoveAt(0); } } if (splitedCommandNext.Any(x => x.ToUpper().Contains(splitedCommand[1].ToUpper()))) { //Read After Write - Se a proxima linha conter leitura e a linha anterior for escrita = conflito conflict.AddConflictWith(i + 2); conflicted = true; } } if (conflicted) { conflictDatas.Add(conflict); } } } return(conflictDatas); }
internal void UpdateWithLocalInfo(ConflictHandling conflictHandling, Guid correlationId) { Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) Name={0}, LocalFolder={1}, Type={2}", Name, LocalFolder, Type); if (Type == ItemType.File) { var mod = File.GetLastWriteTimeUtc(Path.Combine(LocalFolder, Name)); if (mod == LastModified) { // means something went wrong on initial sync, so reset status to updatedlocal if (SharePointId == -1) { Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) Possibly error: LastWriteTime=LastModified but SharePointId=-1"); Status = ItemStatus.UpdatedLocal; } else { Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) Nothing to do"); } return; } if (mod > LastModified) { Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) File is greater than metadata LastModified. Status={0}", Status); if (Status == ItemStatus.UpdatedRemote || Status == ItemStatus.Conflict) { switch (conflictHandling) { case ConflictHandling.ManualConflictHandling: ConflictData = new ConflictData() { LocalLastModified = mod, RemoteLastModified = LastModified }; Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) Set status to 'Conflict'"); Status = ItemStatus.Conflict; return; case ConflictHandling.OverwriteLocalChanges: Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) Set status to 'UpdatedRemote'"); Status = ItemStatus.UpdatedRemote; return; case ConflictHandling.OverwriteRemoteChanges: break; } } Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) Set status to 'UpdatedLocal' and LastModified to {0}", mod); LastModified = mod; Status = ItemStatus.UpdatedLocal; } else { Logger.LogDebug(correlationId, Id, "(UpdateWithLocalInfo) File is older than metadata LastModified. Status set to 'UpdatedRemote'"); Status = ItemStatus.UpdatedRemote; } } }
/// <summary> /// Returns all <see cref="ConflictData"/>s for a set of new <see cref="AccessPoint"/> candidates. /// </summary> /// <param name="accessPoints">The set of <see cref="AccessPoint"/>s candidates to build the list for.</param> /// <param name="appEntry">The <see cref="AppEntry"/> the <paramref name="accessPoints"/> are intended for.</param> /// <returns>A dictionary of <see cref="AccessPoint.GetConflictIDs"/> mapping to the according <see cref="ConflictData"/>.</returns> /// <exception cref="ConflictException">There are inner conflicts within <paramref name="accessPoints"/>.</exception> /// <seealso cref="AccessPoint.GetConflictIDs"/> public static IDictionary<string, ConflictData> GetConflictData([NotNull, ItemNotNull, InstantHandle] this IEnumerable<AccessPoint> accessPoints, [NotNull] AppEntry appEntry) { #region Sanity checks if (accessPoints == null) throw new ArgumentNullException(nameof(accessPoints)); if (appEntry == null) throw new ArgumentNullException(nameof(appEntry)); #endregion var newConflictIDs = new Dictionary<string, ConflictData>(); foreach (var accessPoint in accessPoints) { foreach (string conflictID in accessPoint.GetConflictIDs(appEntry)) { var conflictData = new ConflictData(accessPoint, appEntry); try { newConflictIDs.Add(conflictID, conflictData); } #region Error handling catch (ArgumentException) { throw ConflictException.InnerConflict(conflictData, newConflictIDs[conflictID]); } #endregion } } return newConflictIDs; }
void OnGUI() { if (conflicts.Count > 0) { foreach (string key in conflicts.Keys) { ConflictData conflict = conflicts[key]; GUILayout.BeginHorizontal(); GUILayout.Label(conflict.fileName); conflict.useMine = EditorGUILayout.Popup(conflict.useMine ? 0 : 1, resolveUsing) == 0; if (GUILayout.Button("Diff")) { conflict.diffWindow = GitDiffWindow.Init(GitSystem.RunGitCmd("diff --word-diff=porcelain " + conflict.fileName)); } if (GUILayout.Button("Resolve")) { GitSystem.ResolveConflict(conflict.fileName, conflict.useMine); if (conflict.diffWindow != null) { conflict.diffWindow.Close(); } conflicts.Remove(key); return; } GUILayout.EndHorizontal(); foreach (string code in conflict.locationCodes) { // Is it ours? if (code == "2") { // GUILayout.Label(GitSystem.RunGitCmd("diff -" + code + " " + conflict.fileName)); // GUILayout.Label(GitSystem.RunGitCmd("diff --ours " + conflict.fileName)); } // Is it theirs? if (code == "3") { // GUILayout.Label(GitSystem.RunGitCmd("diff -theirs " + conflict.fileName)); } } } } else { GUILayout.Label("No conflicts found."); } }
private void ResolveItemConflict(ConflictData item) { var itemType = GetItemType(item.Filename); if (itemType == ItemType.Submodule) { var form = new FormMergeSubmodule(UICommands, item.Filename); if (form.ShowDialog() == DialogResult.OK) { StageFile(item.Filename); } } else if (itemType == ItemType.File) { ResolveFilesConflict(item); } }
public void DependsOn( string name, int minMajorVersion, int minMinorVersion, int maxMajorVersion, int maxMinorVersion, string comment, bool regex) { Utils.Script($"{MethodBase.GetCurrentMethod().Name} got called"); var cd = new ConflictData { File = name, Comment = comment, MinMajorVersion = minMajorVersion, MinMinorVersion = minMinorVersion, MaxMajorVersion = maxMajorVersion, MaxMinorVersion = maxMinorVersion, Partial = regex }; _srd.DependsOn.Add(cd); }
private int ResolveMappingConflict(Resource input, ExportInputAssignment[] conflictingAssignments) { // Ask the input Resource which importer it would prefer if (input != null && input.AssetInfo != null && input.AssetInfo.ImporterId != null) { for (int i = 0; i < conflictingAssignments.Length; i++) { // If we have a match with the preferred importer, this is definitely the correct assignment to handle this. if (conflictingAssignments[i].Importer.Id == input.AssetInfo.ImporterId) { return(i); } } } // By default, fall back on simply prefering the highest-priority importer int keepIndex = -1; int highestPrio = int.MinValue; for (int i = 0; i < conflictingAssignments.Length; i++) { if (conflictingAssignments[i].Importer.Priority > highestPrio) { highestPrio = conflictingAssignments[i].Importer.Priority; keepIndex = i; } } // If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it. if (this.conflictHandler != null) { ConflictData data = new ConflictData(input, conflictingAssignments, keepIndex); IAssetImporter selectedImporter = this.conflictHandler(data); int selectedIndex = conflictingAssignments.IndexOfFirst(item => item.Importer == selectedImporter); return(selectedIndex); } return(keepIndex); }
/// <summary> /// Returns all <see cref="ConflictData"/>s for a set of existing <see cref="AppEntry"/>s. /// </summary> /// <param name="appEntries">The <see cref="AppEntry"/>s to build the list for.</param> /// <returns>A dictionary of <see cref="AccessPoint.GetConflictIDs"/> mapping to the according <see cref="ConflictData"/>.</returns> /// <exception cref="ConflictException">There are preexisting conflicts within <paramref name="appEntries"/>.</exception> /// <seealso cref="AccessPoint.GetConflictIDs"/> public static IDictionary <string, ConflictData> GetConflictData(this IEnumerable <AppEntry> appEntries) { #region Sanity checks if (appEntries == null) { throw new ArgumentNullException(nameof(appEntries)); } #endregion var conflictIDs = new Dictionary <string, ConflictData>(); foreach (var appEntry in appEntries) { if (appEntry.AccessPoints == null) { continue; } foreach (var accessPoint in appEntry.AccessPoints.Entries) { foreach (string conflictID in accessPoint.GetConflictIDs(appEntry)) { var conflictData = new ConflictData(accessPoint, appEntry); try { conflictIDs.Add(conflictID, conflictData); } #region Error handling catch (ArgumentException) { throw ConflictException.ExistingConflict(conflictIDs[conflictID], conflictData); } #endregion } } } return(conflictIDs); }
private int ResolveMappingConflict(ImportInputAssignment[] conflictingAssignments) { // Determine the preferred importer based on existing output Resources string preferredImporterId = null; { // Check each importer assignment individually, as each one represents a conflicting import operation for (int i = 0; i < conflictingAssignments.Length; i++) { preferredImporterId = null; // Find out whether all output Resources of this importer assignment exist and share the same preferred importer AssetImportOutput[] output = conflictingAssignments[i].ExpectedOutput; for (int j = 0; j < output.Length; j++) { Resource existingRes = output[j].Resource.Res; if (existingRes == null) { preferredImporterId = null; break; } // If at least one Resource doesn't have a preference, that's ambiuous. Cancel it. string resImporterPref = existingRes.AssetInfo != null ? existingRes.AssetInfo.ImporterId : null; if (resImporterPref == null) { preferredImporterId = null; break; } // Set up the shared importer preference if (preferredImporterId == null) { preferredImporterId = resImporterPref; } // If different outputs from this mapping report different preferred importers, that's ambiguous. Cancel it. else if (preferredImporterId != resImporterPref) { preferredImporterId = null; break; } } // If this importer assignment's Resources have full confidence in a preferred importer, we have a match if (preferredImporterId != null) { break; } } } // If we have a preferred ID, see if it's an option if (preferredImporterId != null) { for (int i = 0; i < conflictingAssignments.Length; i++) { // If we have a match with the preferred importer, this is definitely the correct assignment to handle this. if (conflictingAssignments[i].Importer.Id == preferredImporterId) return i; } } // By default, fall back on simply prefering the highest-priority importer int keepIndex = -1; int highestPrio = int.MinValue; for (int i = 0; i < conflictingAssignments.Length; i++) { if (conflictingAssignments[i].Importer.Priority > highestPrio) { highestPrio = conflictingAssignments[i].Importer.Priority; keepIndex = i; } } // If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it. if (this.conflictHandler != null) { ConflictData data = new ConflictData(conflictingAssignments, keepIndex); IAssetImporter selectedImporter = this.conflictHandler(data); int selectedIndex = conflictingAssignments.IndexOfFirst(assignment => assignment.Importer == selectedImporter); return selectedIndex; } return keepIndex; }
private int ResolveMappingConflict(Resource input, ExportInputAssignment[] conflictingAssignments) { // Ask the input Resource which importer it would prefer if (input != null && input.AssetInfo != null && input.AssetInfo.ImporterId != null) { for (int i = 0; i < conflictingAssignments.Length; i++) { // If we have a match with the preferred importer, this is definitely the correct assignment to handle this. if (conflictingAssignments[i].Importer.Id == input.AssetInfo.ImporterId) return i; } } // By default, fall back on simply prefering the highest-priority importer int keepIndex = -1; int highestPrio = int.MinValue; for (int i = 0; i < conflictingAssignments.Length; i++) { if (conflictingAssignments[i].Importer.Priority > highestPrio) { highestPrio = conflictingAssignments[i].Importer.Priority; keepIndex = i; } } // If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it. if (this.conflictHandler != null) { ConflictData data = new ConflictData(input, conflictingAssignments, keepIndex); IAssetImporter selectedImporter = this.conflictHandler(data); int selectedIndex = conflictingAssignments.IndexOfFirst(item => item.Importer == selectedImporter); return selectedIndex; } return keepIndex; }
/// <summary> /// Creates an exception indicating a new desktop integration conflict. /// </summary> /// <param name="existingEntry">The existing entry that is preventing <paramref name="newEntry"/> from being applied.</param> /// <param name="newEntry">The new entry that is in conflict with <paramref name="existingEntry"/>.</param> public static ConflictException NewConflict(ConflictData existingEntry, ConflictData newEntry) { string message = string.Format(Resources.AccessPointNewConflict, existingEntry, newEntry); return new ConflictException(message) {Entries = new[] {existingEntry, newEntry}}; }
private int ResolveMappingConflict(ImportInputAssignment[] conflictingAssignments) { // Determine the preferred importer based on existing output Resources string preferredImporterId = null; { // Check each importer assignment individually, as each one represents a conflicting import operation for (int i = 0; i < conflictingAssignments.Length; i++) { preferredImporterId = null; // Find out whether all output Resources of this importer assignment exist and share the same preferred importer AssetImportOutput[] output = conflictingAssignments[i].ExpectedOutput; for (int j = 0; j < output.Length; j++) { Resource existingRes = output[j].Resource.Res; if (existingRes == null) { preferredImporterId = null; break; } // If at least one Resource doesn't have a preference, that's ambiuous. Cancel it. string resImporterPref = existingRes.AssetInfo != null ? existingRes.AssetInfo.ImporterId : null; if (resImporterPref == null) { preferredImporterId = null; break; } // Set up the shared importer preference if (preferredImporterId == null) { preferredImporterId = resImporterPref; } // If different outputs from this mapping report different preferred importers, that's ambiguous. Cancel it. else if (preferredImporterId != resImporterPref) { preferredImporterId = null; break; } } // If this importer assignment's Resources have full confidence in a preferred importer, we have a match if (preferredImporterId != null) { break; } } } // If we have a preferred ID, see if it's an option if (preferredImporterId != null) { for (int i = 0; i < conflictingAssignments.Length; i++) { // If we have a match with the preferred importer, this is definitely the correct assignment to handle this. if (conflictingAssignments[i].Importer.Id == preferredImporterId) { return(i); } } } // By default, fall back on simply prefering the highest-priority importer int keepIndex = -1; int highestPrio = int.MinValue; for (int i = 0; i < conflictingAssignments.Length; i++) { if (conflictingAssignments[i].Importer.Priority > highestPrio) { highestPrio = conflictingAssignments[i].Importer.Priority; keepIndex = i; } } // If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it. if (this.conflictHandler != null) { ConflictData data = new ConflictData(conflictingAssignments, keepIndex); IAssetImporter selectedImporter = this.conflictHandler(data); int selectedIndex = conflictingAssignments.IndexOfFirst(assignment => assignment.Importer == selectedImporter); return(selectedIndex); } return(keepIndex); }
private void ResolveFilesConflict(ConflictData item) { string[] filenames = Module.CheckoutConflictedFiles(item); try { if (CheckForLocalRevision(item) && CheckForRemoteRevision(item)) { if (TryMergeWithScript(item.Filename, filenames[0], filenames[1], filenames[2])) { Cursor.Current = Cursors.Default; return; } if (FileHelper.IsBinaryFile(Module, item.Local.Filename)) { if (MessageBox.Show(this, string.Format(_fileIsBinary.Text, _mergetool), _binaryFileWarningCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { BinairyFilesChooseLocalBaseRemote(item); return; } } string arguments = _mergetoolCmd; // Check if there is a base file. If not, ask user to fall back to 2-way merge. // git doesn't support 2-way merge, but we can try to adjust attributes to fix this. // For kdiff3 this is easy; just remove the 3rd file from the arguments. Since the // filenames are quoted, this takes a little extra effort. We need to remove these // quotes also. For tortoise and araxis a little bit more magic is needed. if (item.Base.Filename == null) { var text = string.Format(_noBaseRevision.Text, item.Filename); DialogResult result = MessageBox.Show(this, text, _noBaseFileMergeCaption.Text, MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { Use2WayMerge(ref arguments); } if (result == DialogResult.Cancel) { return; } } arguments = arguments.Replace("$BASE", filenames[0]); arguments = arguments.Replace("$LOCAL", filenames[1]); arguments = arguments.Replace("$REMOTE", filenames[2]); arguments = arguments.Replace("$MERGED", item.Filename); // get timestamp of file before merge. This is an extra check to verify if merge was successful DateTime lastWriteTimeBeforeMerge = DateTime.Now; if (File.Exists(_fullPathResolver.Resolve(item.Filename))) { lastWriteTimeBeforeMerge = File.GetLastWriteTime(_fullPathResolver.Resolve(item.Filename)); } var res = Module.RunCmdResult(_mergetoolPath, "" + arguments + ""); DateTime lastWriteTimeAfterMerge = lastWriteTimeBeforeMerge; if (File.Exists(_fullPathResolver.Resolve(item.Filename))) { lastWriteTimeAfterMerge = File.GetLastWriteTime(_fullPathResolver.Resolve(item.Filename)); } // Check exitcode AND timestamp of the file. If exitcode is success and // time timestamp is changed, we are pretty sure the merge was done. if (res.ExitCode == 0 && lastWriteTimeBeforeMerge != lastWriteTimeAfterMerge) { StageFile(item.Filename); } // If the exitcode is 1, but the file is changed, ask if the merge conflict is solved. // If the exitcode is 0, but the file is not changed, ask if the merge conflict is solved. if ((res.ExitCode == 1 && lastWriteTimeBeforeMerge != lastWriteTimeAfterMerge) || (res.ExitCode == 0 && lastWriteTimeBeforeMerge == lastWriteTimeAfterMerge)) { if (MessageBox.Show(this, _askMergeConflictSolved.Text, _askMergeConflictSolvedCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { StageFile(item.Filename); } } } } finally { DeleteTemporaryFiles(filenames); } }
/// <summary> /// Returns all <see cref="ConflictData"/>s for a set of existing <see cref="AppEntry"/>s. /// </summary> /// <param name="appEntries">The <see cref="AppEntry"/>s to build the list for.</param> /// <returns>A dictionary of <see cref="AccessPoint.GetConflictIDs"/> mapping to the according <see cref="ConflictData"/>.</returns> /// <exception cref="ConflictException">There are preexisting conflicts within <paramref name="appEntries"/>.</exception> /// <seealso cref="AccessPoint.GetConflictIDs"/> public static IDictionary<string, ConflictData> GetConflictData([NotNull] this IEnumerable<AppEntry> appEntries) { #region Sanity checks if (appEntries == null) throw new ArgumentNullException("appEntries"); #endregion var conflictIDs = new Dictionary<string, ConflictData>(); foreach (var appEntry in appEntries) { if (appEntry.AccessPoints == null) continue; foreach (var accessPoint in appEntry.AccessPoints.Entries) { foreach (string conflictID in accessPoint.GetConflictIDs(appEntry)) { var conflictData = new ConflictData(accessPoint, appEntry); try { conflictIDs.Add(conflictID, conflictData); } #region Error handling catch (ArgumentException) { throw ConflictException.ExistingConflict(conflictIDs[conflictID], conflictData); } #endregion } } } return conflictIDs; }
/// <summary> /// Creates an exception indicating a new desktop integration conflict. /// </summary> /// <param name="existingEntry">The existing entry that is preventing <paramref name="newEntry"/> from being applied.</param> /// <param name="newEntry">The new entry that is in conflict with <paramref name="existingEntry"/>.</param> public static ConflictException NewConflict(ConflictData existingEntry, ConflictData newEntry) => new(string.Format(Resources.AccessPointNewConflict, existingEntry, newEntry))
internal void UpdateWithRemoteInfo(int sharePointId, int etag, DateTime lastModified, ConflictHandling conflictHandling, Guid correlationId) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) SharePointId={0}, ETag={1}, Name={2}, LocalFolder={3}, Type={4}, CurrentStatus={5}", sharePointId, etag, Name, LocalFolder, Type, Status); if (Type == ItemType.File) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) SharePointId old={0}, SharePointId new={1}", SharePointId, sharePointId); SharePointId = sharePointId; if (ETag == -1) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Current ETag=-1, new ETag={0}", etag); ETag = etag; if (lastModified > LastModified) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) RemoteLastModified is greater than current LastModified. Status={0}", Status); if (Status == ItemStatus.UpdatedLocal || Status == ItemStatus.Conflict) { switch (conflictHandling) { case ConflictHandling.ManualConflictHandling: ConflictData = new ConflictData() { LocalLastModified = LastModified, RemoteLastModified = lastModified }; Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Set status to 'Conflict'"); Status = ItemStatus.Conflict; return; case ConflictHandling.OverwriteRemoteChanges: Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Set status to 'UpdatedLocal'"); Status = ItemStatus.UpdatedLocal; return; case ConflictHandling.OverwriteLocalChanges: break; } } Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Set status to 'UpdatedRemote' and LastModified to {0}", lastModified); LastModified = lastModified; Status = ItemStatus.UpdatedRemote; return; } if (lastModified < LastModified) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) RemoteLastModified is less than current LasModified. Set status to 'UpdatedLocal'"); Status = ItemStatus.UpdatedLocal; return; } Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) LastModified dates are equal"); Status = ItemStatus.Unchanged; return; } if (File.Exists(Path.Combine(LocalFolder, Name) + ".spsync")) { Status = ItemStatus.Unchanged; return; } if (ETag < etag) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Current ETag is less than remote etag. Status={0}", Status); if (Status == ItemStatus.UpdatedLocal || Status == ItemStatus.Conflict) { switch (conflictHandling) { case ConflictHandling.ManualConflictHandling: ConflictData = new ConflictData() { LocalLastModified = LastModified, RemoteLastModified = lastModified }; Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Set status to 'Conflict'"); Status = ItemStatus.Conflict; return; case ConflictHandling.OverwriteRemoteChanges: Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Set status to 'UpdatedLocal'"); Status = ItemStatus.UpdatedLocal; return; case ConflictHandling.OverwriteLocalChanges: break; } } Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Set status to 'UpdatedRemote' and ETag to {0}", etag); ETag = etag; Status = ItemStatus.UpdatedRemote; return; } if (ETag > etag) { Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) Current ETag is greater than remote etag. Set Status to 'UpdatedLocal'"); Status = ItemStatus.UpdatedLocal; return; } Logger.LogDebug(correlationId, Id, "(UpdateWithRemoteInfo) ETags are equal."); } }