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
d9bfa977
Commit
d9bfa977
authored
Sep 11, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for optional rebasing instead of merge (issue #95)
parent
6407582a
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
221 additions
and
8 deletions
+221
-8
weblate/trans/migrations/0010_add_merge_style.py
weblate/trans/migrations/0010_add_merge_style.py
+167
-0
weblate/trans/models.py
weblate/trans/models.py
+54
-8
No files found.
weblate/trans/migrations/0010_add_merge_style.py
0 → 100644
View file @
d9bfa977
This diff is collapsed.
Click to expand it.
weblate/trans/models.py
View file @
d9bfa977
...
...
@@ -119,6 +119,10 @@ NEW_LANG_CHOICES = (
(
'contact'
,
ugettext_lazy
(
'Use contact form'
)),
(
'url'
,
ugettext_lazy
(
'Point to translation instructions URL'
)),
)
MERGE_CHOICES
=
(
(
'merge'
,
ugettext_lazy
(
'Merge'
)),
(
'rebase'
,
ugettext_lazy
(
'Rebase'
)),
)
class
Project
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
...
...
@@ -131,6 +135,12 @@ class Project(models.Model):
choices
=
NEW_LANG_CHOICES
,
default
=
'contact'
)
merge_style
=
models
.
CharField
(
max_length
=
10
,
choices
=
MERGE_CHOICES
,
default
=
'merge'
,
help_text
=
ugettext_lazy
(
'Define whether Weblate should merge upstream repository or rebase changes onto it'
),
)
# VCS config
commit_message
=
models
.
CharField
(
...
...
@@ -672,6 +682,8 @@ class SubProject(models.Model):
'''
Checks whether there is any translation which needs commit.
'''
gitrepo
=
self
.
get_repo
()
if
not
from_link
and
self
.
is_repo_link
():
return
self
.
get_linked_repo
().
commit_pending
(
True
,
skip_push
=
skip_push
)
...
...
@@ -682,16 +694,10 @@ class SubProject(models.Model):
for
sp
in
self
.
get_linked_childs
():
sp
.
commit_pending
(
True
,
skip_push
=
skip_push
)
def
update_
branch
(
self
,
request
=
None
):
def
update_
merge
(
self
,
request
=
None
):
'''
Updates current branch to
match remote (if possible)
.
Updates current branch to
remote using merge
.
'''
if
self
.
is_repo_link
():
return
self
.
get_linked_repo
().
update_branch
(
request
)
gitrepo
=
self
.
get_repo
()
# Merge with lock acquired
with
self
.
get_git_lock
():
try
:
# Try to merge it
...
...
@@ -713,6 +719,46 @@ class SubProject(models.Model):
messages
.
error
(
request
,
_
(
'Failed to merge remote branch into %s.'
)
%
self
.
__unicode__
())
return
False
def
update_rebase
(
self
,
request
=
None
):
'''
Updates current branch to remote using rebase.
'''
gitrepo
=
self
.
get_repo
()
with
self
.
get_git_lock
():
try
:
# Try to merge it
gitrepo
.
git
.
rebase
(
'origin/%s'
%
self
.
branch
)
logger
.
info
(
'rebased remote into repo %s'
,
self
.
__unicode__
())
return
True
except
Exception
,
e
:
# In case merge has failer recover and tell admins
status
=
gitrepo
.
git
.
status
()
gitrepo
.
git
.
rebase
(
'--abort'
)
logger
.
warning
(
'failed rebase on repo %s'
,
self
.
__unicode__
())
msg
=
'Error:
\
n
%s'
%
str
(
e
)
msg
+=
'
\
n
\
n
Status:
\
n
'
+
status
mail_admins
(
'failed rebase on repo %s'
%
self
.
__unicode__
(),
msg
)
if
request
is
not
None
:
messages
.
error
(
request
,
_
(
'Failed to rebase our branch onto remote branch %s.'
)
%
self
.
__unicode__
())
return
False
def
update_branch
(
self
,
request
=
None
):
'''
Updates current branch to match remote (if possible).
'''
if
self
.
is_repo_link
():
return
self
.
get_linked_repo
().
update_branch
(
request
)
# Merge/rebase
if
self
.
project
.
merge_style
==
'rebase'
:
return
self
.
update_rebase
(
request
)
else
:
return
self
.
update_merge
(
request
)
def
get_mask_matches
(
self
):
'''
Returns files matching current mask.
...
...
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