Commit 85bb2a0f authored by Michal Čihař's avatar Michal Čihař

Store merge/rebase in changes history

Issue #554
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent b4da1c88
......@@ -36,6 +36,11 @@
{% endif %}
</td>
</tr>
{% elif c.target %}
<tr>
<td colspan="4"><pre>{{ c.target }}</td>
<td></td>
</tr>
{% endif %}
{% empty %}
<tr><td colspan="4" class="tablenotice">
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('trans', '0028_auto_20150402_1430'),
]
operations = [
migrations.AlterField(
model_name='change',
name='action',
field=models.IntegerField(default=2, choices=[(0, 'Resource update'), (1, 'Translation completed'), (2, 'Translation changed'), (5, 'New translation'), (3, 'Comment added'), (4, 'Suggestion added'), (6, 'Automatic translation'), (7, 'Suggestion accepted'), (8, 'Translation reverted'), (9, 'Translation uploaded'), (10, 'Glossary added'), (11, 'Glossary updated'), (12, 'Glossary uploaded'), (13, 'New source string'), (14, 'Component locked'), (15, 'Component unlocked'), (16, 'Detected duplicate string'), (17, 'Commited changes'), (18, 'Pushed changes'), (19, 'Reset repository'), (20, 'Merged repository'), (21, 'Rebased repository'), (22, 'Failed merge on repository'), (23, 'Failed rebase on repository')]),
),
]
......@@ -154,6 +154,10 @@ class Change(models.Model):
ACTION_COMMIT = 17
ACTION_PUSH = 18
ACTION_RESET = 19
ACTION_MERGE = 20
ACTION_REBASE = 21
ACTION_FAILED_MERGE = 22
ACTION_FAILED_REBASE = 23
ACTION_CHOICES = (
(ACTION_UPDATE, ugettext_lazy('Resource update')),
......@@ -176,6 +180,10 @@ class Change(models.Model):
(ACTION_COMMIT, ugettext_lazy('Commited changes')),
(ACTION_PUSH, ugettext_lazy('Pushed changes')),
(ACTION_RESET, ugettext_lazy('Reset repository')),
(ACTION_MERGE, ugettext_lazy('Merged repository')),
(ACTION_REBASE, ugettext_lazy('Rebased repository')),
(ACTION_FAILED_MERGE, ugettext_lazy('Failed merge on repository')),
(ACTION_FAILED_REBASE, ugettext_lazy('Failed rebase on repository')),
)
ACTIONS_SUBPROJECT = set((
......@@ -185,6 +193,10 @@ class Change(models.Model):
ACTION_DUPLICATE_STRING,
ACTION_PUSH,
ACTION_RESET,
ACTION_MERGE,
ACTION_REBASE,
ACTION_FAILED_MERGE,
ACTION_FAILED_REBASE,
))
unit = models.ForeignKey('Unit', null=True)
......
......@@ -814,9 +814,13 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
if method == 'rebase':
method = self.repository.rebase
error_msg = _('Failed to rebase our branch onto remote branch %s.')
action = Change.ACTION_REBASE
action_failed = Change.ACTION_FAILED_REBASE
else:
method = self.repository.merge
error_msg = _('Failed to merge remote branch into %s.')
action = Change.ACTION_MERGE
action_failed = Change.ACTION_FAILED_MERGE
with self.repository_lock:
try:
......@@ -826,6 +830,11 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'%s remote into repo',
self.merge_style,
)
Change.objects.create(
translation=self.translation_set.all()[0],
user=request.user if request else None,
action=action,
)
return True
except RepositoryException as error:
# In case merge has failer recover
......@@ -842,6 +851,13 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
# Reset repo back
method(abort=True)
Change.objects.create(
translation=self.translation_set.all()[0],
user=request.user if request else None,
action=action_failed,
target=str(error),
)
# Notify subscribers and admins
self.notify_merge_failure(error, status)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment