summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2015-12-16 19:18:54 +0100
committerOlav Vitters <olav@vitters.nl>2015-12-16 19:18:54 +0100
commitd55dfc1682678d966e2303223ef5198d24f1bc9d (patch)
tree4d388fa612345848bf0fd48e46e7a0d02382cf70
parentd715e84c00aa6004b1b37c55cd8343fb43d2407a (diff)
downloadmgagnome-d55dfc1682678d966e2303223ef5198d24f1bc9d.tar
mgagnome-d55dfc1682678d966e2303223ef5198d24f1bc9d.tar.gz
mgagnome-d55dfc1682678d966e2303223ef5198d24f1bc9d.tar.bz2
mgagnome-d55dfc1682678d966e2303223ef5198d24f1bc9d.tar.xz
mgagnome-d55dfc1682678d966e2303223ef5198d24f1bc9d.zip
ensure spec changes are commited only once
-rwxr-xr-xmgagnome27
1 files changed, 15 insertions, 12 deletions
diff --git a/mgagnome b/mgagnome
index d143272..fdc9534 100755
--- a/mgagnome
+++ b/mgagnome
@@ -51,6 +51,9 @@ import requests
import concurrent.futures
+# for merging comments in order
+import collections
+
SLEEP_INITIAL=180
SLEEP_REPEAT=30
SLEEP_TIMES=30
@@ -315,11 +318,11 @@ class SpecFile(object):
self.path = path
self.cwd = os.path.dirname(path)
self.module = module
- self._changes = []
+ self._changes = collections.OrderedDict()
@property
def changes(self):
- return self._changes[0] if len(self._changes) == 1 else "\n".join(("- %s" % change for change in self._changes))
+ return ''.join(self._changes.keys()) if len(self._changes) == 1 else "\n".join(("- %s" % change for change in self._changes.keys()))
@property
def version(self):
@@ -374,7 +377,7 @@ class SpecFile(object):
data, nr = regexp.subn(change_to, data)
if nr:
made_changes = True
- self._changes.append('SILENT %s' % reason)
+ self._changes['SILENT %s' % reason] = True
# Convert %py_requires and %py_requires -d
# - first figure out how a buildrequire is usually defined
@@ -396,7 +399,7 @@ class SpecFile(object):
data, nr = regexp.subn(change_to, data)
if nr:
made_changes = True
- self._changes.append('SILENT %s' % reason)
+ self._changes['SILENT %s' % reason] = True
# Convert:
# %define name SOMETHING
@@ -421,7 +424,7 @@ class SpecFile(object):
if made_changes and converted_defines:
data = data.lstrip()
- self._changes.append('SILENT remove variable definition(s) %s' % ", ".join(converted_defines))
+ self._changes['SILENT remove variable definition(s) %s' % ", ".join(converted_defines)] = True
made_changes, data = self._clean_spec_patches(f, made_changes, data)
@@ -503,7 +506,7 @@ class SpecFile(object):
if self.check_and_update_patches(check_only=True):
pass
data = change_to
- self._changes.append('SILENT use autopatch')
+ self._changes['SILENT use autopatch'] = True
made_changes = True
finally:
if not made_changes:
@@ -541,7 +544,7 @@ class SpecFile(object):
def _revert_changes(self):
"""Revert uncommited changes made to spec file"""
- self._changes = []
+ self._changes.clear()
subprocess.check_call(["svn", "revert", "-R", os.path.join(self.cwd, '..')])
def remove_patch(self, nr):
@@ -562,7 +565,7 @@ class SpecFile(object):
# Overwrite file with new version number
write_file(self.path, data)
- self._changes.append('dropped merged patch %s' % nr)
+ self._changes['dropped merged patch %s' % nr] = True
subprocess.check_call(['mgarepo', 'sync'], cwd=self.cwd)
return True
@@ -671,7 +674,7 @@ class SpecFile(object):
data, nr = self.re_update_br_unsplit.subn(lambda mo: ''.join((''.join((mo.group('pre'), mo2.group(0), mo.group('unsplitpost'))) for mo2 in self.re_br_part.finditer(mo.group('unsplit')) if mo.group(0).strip() != '')), data)
if data_before != data:
made_changes = True
- self._changes.append('SILENT one line per buildrequirement')
+ self._changes['SILENT one line per buildrequirement'] = True
data_before = data
# Change =< and => operators into <= and >=
@@ -679,7 +682,7 @@ class SpecFile(object):
data, nr = self.re_update_br_fix_operator.subn(lambda mo: mo.group(0).replace('=>', '>=').replace('=<', '<') if self.re_update_br.match(mo.group(0).replace('=>', '>=').replace('=<', '<')) else mo.group(0), data)
if data_before != data:
made_changes = True
- self._changes.append('SILENT fix operator in buildrequires')
+ self._changes['SILENT fix operator in buildrequires'] = True
data_before = data
# Now update buildrequires if any
@@ -688,7 +691,7 @@ class SpecFile(object):
# XXX - very hacky because of multiple changes, could miss out on a change
if data_before != data:
made_changes = True
- self._changes.append('SILENT %s' % change_description)
+ self._changes['SILENT %s' % change_description] = True
elif len(changes) != 0:
print("ERROR: Could not update buildrequires!", file=sys.stderr)
print(changes)
@@ -763,7 +766,7 @@ class SpecFile(object):
# Overwrite file with new version number
write_file(self.path, data)
- self._changes.append('new version %s' % version)
+ self._changes['new version %s' % version] = True
# Verify that RPM also agrees that version number has changed
if self.version != version: