Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
cccd0599
Commit
cccd0599
authored
Apr 03, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better error messages on failed merge
parent
0fa5cf59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
trans/models.py
trans/models.py
+9
-5
trans/views.py
trans/views.py
+3
-9
No files found.
trans/models.py
View file @
cccd0599
...
...
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy, ugettext as _
from
django.utils.safestring
import
mark_safe
from
django.core.mail
import
mail_admins
from
django.core.exceptions
import
ValidationError
from
django.contrib
import
messages
from
glob
import
glob
import
os
import
time
...
...
@@ -109,13 +110,13 @@ class Project(models.Model):
for
s
in
self
.
subproject_set
.
all
():
s
.
commit_pending
()
def
do_update
(
self
):
def
do_update
(
self
,
request
=
None
):
'''
Updates all git repos.
'''
ret
=
True
for
s
in
self
.
subproject_set
.
all
():
ret
&=
s
.
do_update
()
ret
&=
s
.
do_update
(
request
)
return
ret
class
SubProject
(
models
.
Model
):
...
...
@@ -213,12 +214,12 @@ class SubProject(models.Model):
gitrepo
.
git
.
checkout
(
self
.
branch
)
del
gitrepo
def
do_update
(
self
):
def
do_update
(
self
,
request
=
None
):
'''
Wrapper for doing repository update and pushing them to translations.
'''
self
.
commit_pending
()
ret
=
self
.
update_branch
()
ret
=
self
.
update_branch
(
request
)
self
.
create_translations
()
return
ret
...
...
@@ -229,7 +230,7 @@ class SubProject(models.Model):
for
translation
in
self
.
translation_set
.
all
():
translation
.
commit_pending
()
def
update_branch
(
self
):
def
update_branch
(
self
,
request
=
None
):
'''
Updates current branch to match remote (if possible).
'''
...
...
@@ -251,6 +252,9 @@ class SubProject(models.Model):
'failed merge on repo %s'
%
self
.
__unicode__
(),
msg
)
if
request
is
not
None
:
messages
.
error
(
request
,
_
(
'Failed to merge remote branch on %s'
)
%
self
.
__unicode__
())
del
gitrepo
return
ret
...
...
trans/views.py
View file @
cccd0599
...
...
@@ -350,10 +350,8 @@ def commit_translation(request, project, subproject, lang):
def
update_project
(
request
,
project
):
obj
=
get_object_or_404
(
Project
,
slug
=
project
)
if
obj
.
do_update
():
if
obj
.
do_update
(
request
):
messages
.
add_message
(
request
,
messages
.
INFO
,
_
(
'All repositories were updated.'
))
else
:
messages
.
add_message
(
request
,
messages
.
WARNING
,
_
(
'Some repositories could not be merged.'
))
return
HttpResponseRedirect
(
obj
.
get_absolute_url
())
...
...
@@ -362,10 +360,8 @@ def update_project(request, project):
def
update_subproject
(
request
,
project
,
subproject
):
obj
=
get_object_or_404
(
SubProject
,
slug
=
subproject
,
project__slug
=
project
)
if
obj
.
do_update
():
if
obj
.
do_update
(
request
):
messages
.
add_message
(
request
,
messages
.
INFO
,
_
(
'All repositories were updated.'
))
else
:
messages
.
add_message
(
request
,
messages
.
WARNING
,
_
(
'Some repositories could not be merged.'
))
return
HttpResponseRedirect
(
obj
.
get_absolute_url
())
...
...
@@ -374,10 +370,8 @@ def update_subproject(request, project, subproject):
def
update_translation
(
request
,
project
,
subproject
,
lang
):
obj
=
get_object_or_404
(
Translation
,
language__code
=
lang
,
subproject__slug
=
subproject
,
subproject__project__slug
=
project
)
if
obj
.
do_update
():
if
obj
.
do_update
(
request
):
messages
.
add_message
(
request
,
messages
.
INFO
,
_
(
'All repositories were updated.'
))
else
:
messages
.
add_message
(
request
,
messages
.
WARNING
,
_
(
'Some repositories could not be merged.'
))
return
HttpResponseRedirect
(
obj
.
get_absolute_url
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment