Fixing conflicts is very easy with Emacs Ediff. Here, I wrote a simple Python script that allows me to fix conflicted files that occur while using Syncthing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import os import subprocess root_dir = "/home/nwpwr/Dropbox/Notes/roam/" # TODO Change this ignore_folder = ".stversions" for subdir, dirs, files in os.walk(root_dir): # Ignore the .stversions folder dirs[:] = [d for d in dirs if d != ignore_folder] for file in files: if file.endswith(".org") and "conflict" in file: conflict_file = os.path.join(subdir, file) original_file_name = file.split(".sync-conflict")[0] + ".org" original_file_path = os.path.join(subdir, original_file_name) print(f"There is a conflict: {conflict_file}") if os.path.exists(original_file_path): user_input = input(f"Do you want to compare {original_file_name} with {file}? (y/n): ") if user_input.lower() == 'y': # Running the ediff command using emacsclient directly subprocess.run([ "emacsclient", "-c", "-n", "--eval", f"(ediff \"{original_file_path}\" \"{conflict_file}\")" ]) |