aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpettet <rush@wikimedia.org>2014-11-24 11:15:00 -0600
committercpettet <rush@wikimedia.org>2014-11-24 11:15:00 -0600
commit6544e2e9a20fc0c5bc0ecc85e745eeca84eeb043 (patch)
treee8844e7d686ae12854c4340518c88cfae47745c9
parent3e9210eacc0f91ab183f1f86c38161ef84f076d9 (diff)
correctly handle comment assignment
* handles the ***'s literal case * handles the private comment case * handles the stripping of legacy attachment notice
-rwxr-xr-xbugzilla_update_user_comments.py13
-rwxr-xr-xwmfphablib/bzlib.py25
2 files changed, 24 insertions, 14 deletions
diff --git a/bugzilla_update_user_comments.py b/bugzilla_update_user_comments.py
index b3009e6..3acc4c5 100755
--- a/bugzilla_update_user_comments.py
+++ b/bugzilla_update_user_comments.py
@@ -54,22 +54,15 @@ def update(user):
jcom, jxcom = comdetails[0]
coms = json.loads(jcom)
xcoms = json.loads(jxcom)
-
for key, xi in xcoms.iteritems():
com = coms[util.get_index(coms, "count", int(key))]
content = com['text']
-
- if com['is_private']:
- vlog('is private')
- comment_content = bzlib.security_mask
- else:
- vlog('is NOT private')
- comment_content = content + xi['xattached']
-
+ comment_content = bzlib.build_comment_comment_regen(content, com['is_private'])
if com["creator"] == user['user']:
log("Updating comment %s for %s" % (xi['xctransaction'], user['user']))
phabdb.set_comment_author(xi['xctransaction'], user['userphid'])
- phabdb.set_comment_content(xi['xctransaction'], comment_content)
+ phabdb.set_comment_content(xi['xctransaction'],
+ comment_content + xi['xattached'])
current = phabdb.get_user_migration_comment_history(user['user'], pmig)
if current:
diff --git a/wmfphablib/bzlib.py b/wmfphablib/bzlib.py
index 92fc7ef..600c79e 100755
--- a/wmfphablib/bzlib.py
+++ b/wmfphablib/bzlib.py
@@ -2,6 +2,10 @@ import re
prepend = 'bz'
security_mask = '//**content hidden as private in Bugzilla**//'
+dupe_literals = ['This bug has been marked as a duplicate of bug',
+ 'This bug has been marked as a duplicate of',
+ 'has been marked as a duplicate of this bug']
+
# Some issues are just missing instead of constant failures we skip
missing = [15368, 15369, 15370, 15371, 15372, 15373, 15374]
@@ -28,10 +32,6 @@ def build_comment(c, secstate):
# these indicate textual metadata history and should be
# preserved as literal
- dupe_literals = ['This bug has been marked as a duplicate of bug',
- 'This bug has been marked as a duplicate of',
- 'has been marked as a duplicate of this bug']
-
clean_c = {}
clean_c['author'] = c['author'].split('@')[0]
clean_c['creation_time'] = str(c['creation_time'])
@@ -63,6 +63,23 @@ def build_comment(c, secstate):
clean_c['text'] = c['text']
return clean_c
+def build_comment_comment_regen(text, is_private):
+
+ if is_private:
+ text = security_mask
+
+ fmt_text = []
+ text = text.splitlines()
+ for t in text:
+ if t.startswith('Created attachment'):
+ continue
+ elif '***' in t and any(map(lambda l: l in t, dupe_literals)):
+ fmt_text.append('%%%{0}%%%'.format(t))
+ else:
+ fmt_text.append(t)
+ clean_text = '\n'.join(fmt_text)
+ return clean_text
+
def find_attachment_in_comment(text):
"""Find attachment id in bz comment
:param text: str