mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 22:01:06 +00:00
Fix get_diff bug
This commit is contained in:
2
po.py
2
po.py
@@ -5,7 +5,7 @@ TRANSLATION_MAP = {
|
|||||||
'Added' : u'添加了',
|
'Added' : u'添加了',
|
||||||
'Deleted' : u'删除了',
|
'Deleted' : u'删除了',
|
||||||
'Modified' : u'修改了',
|
'Modified' : u'修改了',
|
||||||
'Renamed' : u'重命名了',
|
'Renamed' : u'重命名或移动了',
|
||||||
'and' : u'以及另外',
|
'and' : u'以及另外',
|
||||||
'more files' : u'个文件',
|
'more files' : u'个文件',
|
||||||
'Reverted repo to status at' : u'同步目录内容还原到',
|
'Reverted repo to status at' : u'同步目录内容还原到',
|
||||||
|
@@ -106,7 +106,7 @@
|
|||||||
show(data['removed']);
|
show(data['removed']);
|
||||||
}
|
}
|
||||||
if (data['renamed'].length > 0) {
|
if (data['renamed'].length > 0) {
|
||||||
str_con += '<h4 id="ls-ch-rn">移动的文件</h4>';
|
str_con += '<h4 id="ls-ch-rn">重命名或移动的文件</h4>';
|
||||||
show(data['renamed']);
|
show(data['renamed']);
|
||||||
}
|
}
|
||||||
if (data['modified'].length > 0) {
|
if (data['modified'].length > 0) {
|
||||||
|
44
views.py
44
views.py
@@ -435,44 +435,22 @@ def repo_history_revert(request, repo_id):
|
|||||||
|
|
||||||
return HttpResponseRedirect(reverse(repo_history, args=[repo_id]))
|
return HttpResponseRedirect(reverse(repo_history, args=[repo_id]))
|
||||||
|
|
||||||
def get_filename(start, ent):
|
|
||||||
i = start + 1
|
|
||||||
lenidx = start - 1
|
|
||||||
while i <= len(ent):
|
|
||||||
tmp = " ".join(ent[start:i])
|
|
||||||
if len(tmp) == int(ent[lenidx]):
|
|
||||||
return (tmp, i)
|
|
||||||
i = i + 1
|
|
||||||
return ("", 0)
|
|
||||||
|
|
||||||
def add_to_status_list(lists, status_ent):
|
|
||||||
if status_ent[1] == 'A':
|
|
||||||
filename, index = get_filename(4, status_ent)
|
|
||||||
lists['new'].append(filename)
|
|
||||||
elif status_ent[1] == 'D':
|
|
||||||
filename, index = get_filename(4, status_ent)
|
|
||||||
lists['removed'].append(filename)
|
|
||||||
elif status_ent[1] == 'R':
|
|
||||||
filename1, index1 = get_filename(4, status_ent)
|
|
||||||
filename2, index2 = get_filename(index1 + 1, status_ent)
|
|
||||||
lists['renamed'].append(filename1 + u' 被移动到 ' + filename2)
|
|
||||||
elif status_ent[1] == 'M':
|
|
||||||
filename, index = get_filename(4, status_ent)
|
|
||||||
lists['modified'].append(filename)
|
|
||||||
|
|
||||||
def get_diff(repo_id, arg1, arg2):
|
def get_diff(repo_id, arg1, arg2):
|
||||||
lists = {'new' : [], 'removed' : [], 'renamed' : [], 'modified' : []}
|
lists = {'new' : [], 'removed' : [], 'renamed' : [], 'modified' : []}
|
||||||
|
|
||||||
diff_result = seafserv_threaded_rpc.get_diff(repo_id, arg1, arg2)
|
diff_result = seafserv_threaded_rpc.get_diff(repo_id, arg1, arg2)
|
||||||
if diff_result == "":
|
if not diff_result:
|
||||||
return lists;
|
return lists
|
||||||
|
|
||||||
diff_result = diff_result[:len(diff_result)-1]
|
for d in diff_result:
|
||||||
|
if d.status == "add":
|
||||||
for d in diff_result.split("\n"):
|
lists['new'].append(d.name)
|
||||||
tmp = d.split(" ")
|
elif d.status == "del":
|
||||||
if tmp[0] == 'C':
|
lists['removed'].append(d.name)
|
||||||
add_to_status_list(lists, tmp)
|
elif d.status == "mov":
|
||||||
|
lists['renamed'].append(d.name + " ==> " + d.new_name)
|
||||||
|
elif d.status == "mod":
|
||||||
|
lists['modified'].append(d.name)
|
||||||
|
|
||||||
return lists
|
return lists
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user