Menu

[5e5f88]: / old / scripts / conversion-old-invocations.py  Maximize  Restore  History

Download this file

130 lines (87 with data), 3.8 kB

  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
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#-------------------------------------------------------------------------------
# findgrepsed:
# Create a temporary file to contain the merged results.
tmpf2 = tempfile.NamedTemporaryFile('w', prefix=tmpprefix)
# Call xxdiff on it.
status, xxdiff_output = commands.getstatusoutput(
('xxdiff --decision --merged-filename "%s" '
'--title2 "NEW FILE" "%s" "%s" ') %
(tmpf2.name, fn, tmpf.name))
print xxdiff_output
# Check out the exit code from xxdiff
l1 = xxdiff_output.splitlines()[0] # first line
if l1 == 'ACCEPT':
#-------------------------------------------------------------------------------
# condreplace:
tmpf2 = tempfile.NamedTemporaryFile('w', prefix=tmpprefix)
cmd = ('%s --decision --merged-filename "%s" ' + \
'--title2 "NEW FILE" "%s" "%s" ') % \
(opts.xxdiff_exec, tmpf2.name, origfile, modfile)
s, o = commands.getstatusoutput(cmd)
if o == 'ACCEPT' ...
#-------------------------------------------------------------------------------
# cvsdiff:
tmpf2 = NamedTemporaryFile('w', prefix=tmpprefix)
cmd = ('xxdiff --decision --merged-filename "%s" ' +
'--title2 "NEW FILE" "%s" "%s" ') % \
(tmpf2.name, tmpf.name, filename)
s, o = commands.getstatusoutput(cmd)
# print output of xxdiff command.
if o:
print o
#-------------------------------------------------------------------------------
# encrypted:
diffcmd = '%(xxdiff)s --merged-filename "%(merged)s" ' + \
'--indicate-input-processed ' # + filenames
fmerge = NamedTemporaryFile(prefix=tmpprefix)
print '== TEMPFILE', fmerge.name
m = {'xxdiff': opts.xxdiff_exec,
'gpg': opts.gpg,
'merged': fmerge.name}
cmd = diffcmd % m + ' '.join(map(lambda x: '"%s"' % x.name, tempfiles))
fout = os.popen(cmd, 'r')
# Leave time for xxdiff to read the files before hiding, it will let us know
# when it is done with the input files.
l = fout.readline()
assert l.startswith('INPUT-PROCESSED')
fout.read()
#-------------------------------------------------------------------------------
# match:
print ' '.join(l)
cmd = ' '.join( ['xxdiff'] + extra + opts + l )
os.popen(cmd)
#-------------------------------------------------------------------------------
# patch:
dopts += '--title%d="%s (patched)"' % (pno, sfilename)
dopts += opts.xxdiff_options
cmd = 'xxdiff %s "%s" "%s"' % (dopts, leftfn, rightfn)
s, o = commands.getstatusoutput(cmd)
# print output of xxdiff command.
if o: print o
# perform the requested action
if o and not opts.dry_run:
if o == 'ACCEPT':
#-------------------------------------------------------------------------------
# diffproxy:
tmpf = NamedTemporaryFile('rw', prefix=tmpprefix)
# run command
xxdiff_path = 'xxdiff'
decision = len(args) == 3
cmd = [xxdiff_path]
if decision:
cmd.append('--decision')
if opts.merge:
cmd.append('--merge')
cmd.append('--merged-filename="%s"' % tmpf.name)
for o1, o2, fn in zip(['--title1', '--title2', '--title3'],
['"%s"' % x for x in opts.label],
args):
if os.path.basename(fn) == 'empty-file':
o2 = '"(NON-EXISTANT FILE)"'
cmd.extend([o1, o2])
cmd.extend(args)
##print ' '.join(cmd)
s, o = commands.getstatusoutput(' '.join(cmd))
if decision:
# if the user merged, copy the merged file over the original.
if o in ['MERGED', 'ACCEPT', 'REJECT']:
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.