/usr/bin/xx-p4-unmerge is in xxdiff-scripts 1:4.0.1+hg487+dfsg-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/usr/bin/python
"""
A wrapper script that will split up a p4 file with merge conflicts to three
files and invoke xxdiff on it.
"""
# stdlib imports
import sys, os, shutil, re, StringIO, tempfile
# xxdiff imports
from xxdiff import invoke
def unmerge_file(filename):
file_original = tempfile.NamedTemporaryFile()
file_theirs = tempfile.NamedTemporaryFile()
file_yours = tempfile.NamedTemporaryFile()
files = file_original, file_theirs, file_yours
file_current = None
for line in open(filename):
if line.startswith('>>>> ORIGINAL'):
file_current = file_original
elif line.startswith('==== THEIRS'):
file_current = file_theirs
elif line.startswith('==== YOURS'):
file_current = file_yours
elif line.startswith('<<<<'):
file_current = None
elif file_current is None:
for file_ in files:
file_.write(line)
else:
file_current.write(line)
for file_ in files:
file_.flush()
return files
def main():
import optparse
parser = optparse.OptionParser(__doc__.strip())
invoke.options_graft(parser)
opts, args = parser.parse_args()
invoke.options_validate(opts, parser)
if len(args) != 1:
parser.error("You need to provide 1 file argumnet.")
filename, = args
file_original, file_theirs, file_yours = unmerge_file(filename)
# Invoke xxdiff.
decision, mergedf, __retcode = invoke.xxdiff_decision(
opts,
'--merged-filename=%s' % filename,
'--title1=Current',
'--title2=Ancestor',
'--title3=Merging',
file_yours.name, file_original.name, file_theirs.name)
if __name__ == '__main__':
sys.exit(main())
|