Here's a script I wrote for resolving binary conflicts when merging
vendor branches. Use it at your own risk. Until sussman's proposal
about fixing the UID.RUN.rXXX files goes through, you'll have to
manually determine the UID and place it in the TARGETVERSION line.
#!/usr/bin/env python
import os
import sys
import glob
import re
import shutil
opj = os.path.join
#this is a hack until subversion is fixed
TARGETVERSION="61940"
def re_escape(s):
s = '\.'.join(s.split('.'))
s = '\+'.join(s.split('+'))
return s
def searchfile(filename):
#Check for conflict files
working = glob.glob(filename+"*.working")
if not working:
return
revisions = glob.glob(filename+"*.r*")
if not revisions:
raise Exception("Found .working, but no revisions")
#Find latest run of merge
myexp = "%s\.%s\.(\d+)\.r(\d+)" % (re_escape(filename), TARGETVERSION)
myre = re.compile(myexp)
latest = -1
latestfile = None
for x in revisions:
m = myre.match(x)
if m and latest < int(m.group(1)):
latest = int(m.group(1))
latestfile = x
if not latestfile:
raise Exception("Found no file to copy")
#Copy the newer file
print 'Copy', x, '->', filename
shutil.copyfile(x, filename)
#Remove the old files
for x in working+revisions:
os.unlink(x)
#Run svn resolve on the new file
if os.system("svn resolve %s" % filename):
raise Exception("Failed to resolved file %s" % filename)
def searchdir(dir, filespecs):
g = []
for x in filespecs:
g += glob.glob(opj(dir,x))
for x in g:
searchfile(x)
list = os.listdir(dir)
for x in list:
y = opj(dir,x)
if os.path.isdir(y):
searchdir(y, filespecs)
def main(dir, filespecs):
print 'Searching', dir, 'for', filespecs
searchdir(dir, filespecs)
main(sys.argv[1], sys.argv[2:])
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jan 9 17:52:20 2003