mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-04 10:36:17 +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
|
||||
meta
|
||||
platforms
|
||||
rebuildpac
|
||||
remove (del, delete, rm)
|
||||
resolved
|
||||
results
|
||||
@ -572,6 +573,18 @@ usage: history <pacdir>
|
||||
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):
|
||||
"""help: Describe the usage of this program or its subcommands.
|
||||
|
||||
@ -622,6 +635,7 @@ cmd_dict = {
|
||||
'resolved': resolved,
|
||||
'results': results,
|
||||
'results_meta': results_meta,
|
||||
'rebuildpac': rebuildpac,
|
||||
'status': status,
|
||||
'update': update,
|
||||
}
|
||||
|
59
osc/core.py
59
osc/core.py
@ -175,9 +175,13 @@ class Package:
|
||||
myfilename = os.path.join(self.dir, n + '.mine')
|
||||
upfilename = os.path.join(self.dir, n + '.r' + self.rev)
|
||||
|
||||
try: os.unlink(myfilename)
|
||||
except: pass
|
||||
os.rename(upfilename, storefilename)
|
||||
try:
|
||||
os.unlink(myfilename)
|
||||
# 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)
|
||||
|
||||
@ -243,8 +247,8 @@ class Package:
|
||||
|
||||
get_source_file(self.prjname, self.name, n, targetfilename=upfilename)
|
||||
|
||||
ret = os.system('cd %s; diff3 -m -E %s %s %s > %s' \
|
||||
% (self.dir, myfilename, storefilename, upfilename, filename))
|
||||
ret = os.system('diff3 -m -E %s %s %s > %s' \
|
||||
% (myfilename, storefilename, upfilename, filename))
|
||||
if ret == 0:
|
||||
# merge was successful... clean up
|
||||
os.rename(upfilename, filename)
|
||||
@ -845,8 +849,7 @@ def get_user_id(user):
|
||||
|
||||
|
||||
def get_source_file(prj, package, filename, targetfilename=None):
|
||||
u = makeurl(['source', prj, package, filename])
|
||||
#print 'checking out', u
|
||||
u = makeurl(['source', prj, package, filename.replace('+', '%2B')])
|
||||
f = urllib2.urlopen(u)
|
||||
|
||||
o = open(targetfilename or filename, 'w')
|
||||
@ -872,19 +875,11 @@ def dgst(file):
|
||||
return s.hexdigest()
|
||||
|
||||
|
||||
def get_source_file_diff_upstream(prj, package, filename):
|
||||
url = makeurl(['source', prj, package, filename])
|
||||
f = urllib2.urlopen(url)
|
||||
|
||||
localfile = open(filename, 'r')
|
||||
|
||||
import difflib
|
||||
#print url
|
||||
d = difflib.unified_diff(f.readlines(), localfile.readlines(), fromfile = url, tofile = filename)
|
||||
|
||||
localfile.close()
|
||||
|
||||
return ''.join(d)
|
||||
def binary(s):
|
||||
"""return true if a string is binary data using diff's heuristic"""
|
||||
if s and '\0' in s[:4096]:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_source_file_diff(dir, filename, rev):
|
||||
@ -896,11 +891,18 @@ def get_source_file_diff(dir, filename, rev):
|
||||
f1 = open(file1, 'r')
|
||||
f2 = open(file2, 'r')
|
||||
|
||||
d = difflib.unified_diff(\
|
||||
f1.readlines(), \
|
||||
f2.readlines(), \
|
||||
fromfile = '%s (revision %s)' % (filename, rev), \
|
||||
tofile = '%s (working copy)' % filename)
|
||||
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(\
|
||||
s1.splitlines(1), \
|
||||
s2.splitlines(1), \
|
||||
fromfile = '%s (revision %s)' % (filename, rev), \
|
||||
tofile = '%s (working copy)' % filename)
|
||||
|
||||
f1.close()
|
||||
f2.close()
|
||||
@ -1017,6 +1019,13 @@ def get_history(prj, package):
|
||||
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):
|
||||
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
|
||||
return p
|
||||
|
Loading…
Reference in New Issue
Block a user