mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 13:50:07 +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'添加了',
|
||||
'Deleted' : u'删除了',
|
||||
'Modified' : u'修改了',
|
||||
'Renamed' : u'重命名了',
|
||||
'Renamed' : u'重命名或移动了',
|
||||
'and' : u'以及另外',
|
||||
'more files' : u'个文件',
|
||||
'Reverted repo to status at' : u'同步目录内容还原到',
|
||||
|
@@ -106,7 +106,7 @@
|
||||
show(data['removed']);
|
||||
}
|
||||
if (data['renamed'].length > 0) {
|
||||
str_con += '<h4 id="ls-ch-rn">移动的文件</h4>';
|
||||
str_con += '<h4 id="ls-ch-rn">重命名或移动的文件</h4>';
|
||||
show(data['renamed']);
|
||||
}
|
||||
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]))
|
||||
|
||||
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):
|
||||
lists = {'new' : [], 'removed' : [], 'renamed' : [], 'modified' : []}
|
||||
|
||||
diff_result = seafserv_threaded_rpc.get_diff(repo_id, arg1, arg2)
|
||||
if diff_result == "":
|
||||
return lists;
|
||||
if not diff_result:
|
||||
return lists
|
||||
|
||||
diff_result = diff_result[:len(diff_result)-1]
|
||||
|
||||
for d in diff_result.split("\n"):
|
||||
tmp = d.split(" ")
|
||||
if tmp[0] == 'C':
|
||||
add_to_status_list(lists, tmp)
|
||||
for d in diff_result:
|
||||
if d.status == "add":
|
||||
lists['new'].append(d.name)
|
||||
elif d.status == "del":
|
||||
lists['removed'].append(d.name)
|
||||
elif d.status == "mov":
|
||||
lists['renamed'].append(d.name + " ==> " + d.new_name)
|
||||
elif d.status == "mod":
|
||||
lists['modified'].append(d.name)
|
||||
|
||||
return lists
|
||||
|
||||
|
Reference in New Issue
Block a user