mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-10 13:05:46 +01:00
- don't diff binary files, using diff's heuristic
- add 'rebuildpac' command, which triggers a rebuild for all repositories/architectures of the package - fix merge on 'update', if osc is called from another directory - escape '+' signs in filenames in GET requests as well (adds to [#153725, 181593]) - don't fail on 'resolve' when the working copy is in a newer rev already
This commit is contained in:
parent
24a49bbfd6
commit
3e412a67a5
@ -33,6 +33,7 @@ Available subcommands:
|
|||||||
ls
|
ls
|
||||||
meta
|
meta
|
||||||
platforms
|
platforms
|
||||||
|
rebuildpac
|
||||||
remove (del, delete, rm)
|
remove (del, delete, rm)
|
||||||
resolved
|
resolved
|
||||||
results
|
results
|
||||||
@ -572,6 +573,18 @@ usage: history <pacdir>
|
|||||||
print ''.join(get_history(p.prjname, p.name))
|
print ''.join(get_history(p.prjname, p.name))
|
||||||
|
|
||||||
|
|
||||||
|
def rebuildpac(args):
|
||||||
|
"""rebuildpac: Triggers a package rebuild for all repositories/architectures of the package
|
||||||
|
|
||||||
|
usage: rebuildpac <pacdir>
|
||||||
|
"""
|
||||||
|
args = parseargs(args)
|
||||||
|
pacs = findpacs(args)
|
||||||
|
|
||||||
|
for p in pacs:
|
||||||
|
print ''.join(cmd_rebuild(p.prjname, p.name))
|
||||||
|
|
||||||
|
|
||||||
def help(args):
|
def help(args):
|
||||||
"""help: Describe the usage of this program or its subcommands.
|
"""help: Describe the usage of this program or its subcommands.
|
||||||
|
|
||||||
@ -622,6 +635,7 @@ cmd_dict = {
|
|||||||
'resolved': resolved,
|
'resolved': resolved,
|
||||||
'results': results,
|
'results': results,
|
||||||
'results_meta': results_meta,
|
'results_meta': results_meta,
|
||||||
|
'rebuildpac': rebuildpac,
|
||||||
'status': status,
|
'status': status,
|
||||||
'update': update,
|
'update': update,
|
||||||
}
|
}
|
||||||
|
53
osc/core.py
53
osc/core.py
@ -175,9 +175,13 @@ class Package:
|
|||||||
myfilename = os.path.join(self.dir, n + '.mine')
|
myfilename = os.path.join(self.dir, n + '.mine')
|
||||||
upfilename = os.path.join(self.dir, n + '.r' + self.rev)
|
upfilename = os.path.join(self.dir, n + '.r' + self.rev)
|
||||||
|
|
||||||
try: os.unlink(myfilename)
|
try:
|
||||||
except: pass
|
os.unlink(myfilename)
|
||||||
os.rename(upfilename, storefilename)
|
# the working copy may be updated, so the .r* ending may be obsolete...
|
||||||
|
# then we don't care
|
||||||
|
os.unlink(upfilename)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
self.in_conflict.remove(n)
|
self.in_conflict.remove(n)
|
||||||
|
|
||||||
@ -243,8 +247,8 @@ class Package:
|
|||||||
|
|
||||||
get_source_file(self.prjname, self.name, n, targetfilename=upfilename)
|
get_source_file(self.prjname, self.name, n, targetfilename=upfilename)
|
||||||
|
|
||||||
ret = os.system('cd %s; diff3 -m -E %s %s %s > %s' \
|
ret = os.system('diff3 -m -E %s %s %s > %s' \
|
||||||
% (self.dir, myfilename, storefilename, upfilename, filename))
|
% (myfilename, storefilename, upfilename, filename))
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
# merge was successful... clean up
|
# merge was successful... clean up
|
||||||
os.rename(upfilename, filename)
|
os.rename(upfilename, filename)
|
||||||
@ -845,8 +849,7 @@ def get_user_id(user):
|
|||||||
|
|
||||||
|
|
||||||
def get_source_file(prj, package, filename, targetfilename=None):
|
def get_source_file(prj, package, filename, targetfilename=None):
|
||||||
u = makeurl(['source', prj, package, filename])
|
u = makeurl(['source', prj, package, filename.replace('+', '%2B')])
|
||||||
#print 'checking out', u
|
|
||||||
f = urllib2.urlopen(u)
|
f = urllib2.urlopen(u)
|
||||||
|
|
||||||
o = open(targetfilename or filename, 'w')
|
o = open(targetfilename or filename, 'w')
|
||||||
@ -872,19 +875,11 @@ def dgst(file):
|
|||||||
return s.hexdigest()
|
return s.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def get_source_file_diff_upstream(prj, package, filename):
|
def binary(s):
|
||||||
url = makeurl(['source', prj, package, filename])
|
"""return true if a string is binary data using diff's heuristic"""
|
||||||
f = urllib2.urlopen(url)
|
if s and '\0' in s[:4096]:
|
||||||
|
return True
|
||||||
localfile = open(filename, 'r')
|
return False
|
||||||
|
|
||||||
import difflib
|
|
||||||
#print url
|
|
||||||
d = difflib.unified_diff(f.readlines(), localfile.readlines(), fromfile = url, tofile = filename)
|
|
||||||
|
|
||||||
localfile.close()
|
|
||||||
|
|
||||||
return ''.join(d)
|
|
||||||
|
|
||||||
|
|
||||||
def get_source_file_diff(dir, filename, rev):
|
def get_source_file_diff(dir, filename, rev):
|
||||||
@ -896,9 +891,16 @@ def get_source_file_diff(dir, filename, rev):
|
|||||||
f1 = open(file1, 'r')
|
f1 = open(file1, 'r')
|
||||||
f2 = open(file2, 'r')
|
f2 = open(file2, 'r')
|
||||||
|
|
||||||
|
s1 = f1.read()
|
||||||
|
s2 = f2.read()
|
||||||
|
|
||||||
|
if binary(s1) or binary (s2):
|
||||||
|
d = ['Binary file %s has changed\n' % filename]
|
||||||
|
|
||||||
|
else:
|
||||||
d = difflib.unified_diff(\
|
d = difflib.unified_diff(\
|
||||||
f1.readlines(), \
|
s1.splitlines(1), \
|
||||||
f2.readlines(), \
|
s2.splitlines(1), \
|
||||||
fromfile = '%s (revision %s)' % (filename, rev), \
|
fromfile = '%s (revision %s)' % (filename, rev), \
|
||||||
tofile = '%s (working copy)' % filename)
|
tofile = '%s (working copy)' % filename)
|
||||||
|
|
||||||
@ -1017,6 +1019,13 @@ def get_history(prj, package):
|
|||||||
return f.readlines()
|
return f.readlines()
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_rebuild(prj, package):
|
||||||
|
u = makeurl(['source', prj, package, '?cmd=rebuild'])
|
||||||
|
# adding data to the request makes it a POST
|
||||||
|
f = urllib2.urlopen(u, data=' ')
|
||||||
|
return f.readlines()
|
||||||
|
|
||||||
|
|
||||||
def store_read_project(dir):
|
def store_read_project(dir):
|
||||||
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
|
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
|
||||||
return p
|
return p
|
||||||
|
Loading…
x
Reference in New Issue
Block a user