本文整理汇总了Python中seaserv.seafserv_threaded_rpc.get_commit函数的典型用法代码示例。如果您正苦于以下问题:Python get_commit函数的具体用法?Python get_commit怎么用?Python get_commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_commit函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: text_diff
def text_diff(request, repo_id):
commit_id = request.GET.get("commit", "")
path = request.GET.get("p", "")
u_filename = os.path.basename(path)
file_enc = request.GET.get("file_enc", "auto")
if not file_enc in FILE_ENCODING_LIST:
file_enc = "auto"
if not (commit_id and path):
return render_error(request, "bad params")
repo = get_repo(repo_id)
if not repo:
return render_error(request, "bad repo")
current_commit = seafserv_threaded_rpc.get_commit(repo.id, repo.version, commit_id)
if not current_commit:
return render_error(request, "bad commit id")
prev_commit = seafserv_threaded_rpc.get_commit(repo.id, repo.version, current_commit.parent_id)
if not prev_commit:
return render_error("bad commit id")
path = path.encode("utf-8")
current_content, err = get_file_content_by_commit_and_path(request, repo_id, current_commit.id, path, file_enc)
if err:
return render_error(request, err)
prev_content, err = get_file_content_by_commit_and_path(request, repo_id, prev_commit.id, path, file_enc)
if err:
return render_error(request, err)
is_new_file = False
diff_result_table = ""
if prev_content == "" and current_content == "":
is_new_file = True
else:
diff = HtmlDiff()
diff_result_table = diff.make_table(prev_content.splitlines(), current_content.splitlines(), True)
zipped = gen_path_link(path, repo.name)
return render_to_response(
"text_diff.html",
{
"u_filename": u_filename,
"repo": repo,
"path": path,
"zipped": zipped,
"current_commit": current_commit,
"prev_commit": prev_commit,
"diff_result_table": diff_result_table,
"is_new_file": is_new_file,
},
context_instance=RequestContext(request),
)
开发者ID:vikingliu,项目名称:seahub,代码行数:57,代码来源:file.py
示例2: text_diff
def text_diff(request, repo_id):
commit_id = request.GET.get('commit', '')
path = request.GET.get('p', '')
u_filename = os.path.basename(path)
file_enc = request.GET.get('file_enc', 'auto')
if not file_enc in FILE_ENCODING_LIST:
file_enc = 'auto'
if not (commit_id and path):
return render_error(request, 'bad params')
repo = get_repo(repo_id)
if not repo:
return render_error(request, 'bad repo')
current_commit = seafserv_threaded_rpc.get_commit(repo.id, repo.version, commit_id)
if not current_commit:
return render_error(request, 'bad commit id')
prev_commit = seafserv_threaded_rpc.get_commit(repo.id, repo.version, current_commit.parent_id)
if not prev_commit:
return render_error('bad commit id')
path = path.encode('utf-8')
current_content, err = get_file_content_by_commit_and_path(request, \
repo_id, current_commit.id, path, file_enc)
if err:
return render_error(request, err)
prev_content, err = get_file_content_by_commit_and_path(request, \
repo_id, prev_commit.id, path, file_enc)
if err:
return render_error(request, err)
is_new_file = False
diff_result_table = ''
if prev_content == '' and current_content == '':
is_new_file = True
else:
diff = HtmlDiff()
diff_result_table = diff.make_table(prev_content.splitlines(),
current_content.splitlines(), True)
zipped = gen_path_link(path, repo.name)
return render_to_response('text_diff.html', {
'u_filename':u_filename,
'repo': repo,
'path': path,
'zipped': zipped,
'current_commit': current_commit,
'prev_commit': prev_commit,
'diff_result_table': diff_result_table,
'is_new_file': is_new_file,
}, context_instance=RequestContext(request))
开发者ID:bits4beats,项目名称:seahub,代码行数:56,代码来源:file.py
示例3: _get_events_inner
def _get_events_inner(ev_session, username, start, limit):
'''Read events from seafevents database, and remove events that are
no longer valid
Return 'limit' events or less than 'limit' events if no more events remain
'''
valid_events = []
next_start = start
while True:
events = seafevents.get_user_events(ev_session, username,
next_start, limit)
if not events:
break
for ev in events:
if ev.etype == 'repo-update':
repo = get_repo(ev.repo_id)
if not repo:
# delete the update event for repo which has been deleted
seafevents.delete_event(ev_session, ev.uuid)
continue
if repo.encrypted:
repo.password_set = seafserv_rpc.is_passwd_set(repo.id, username)
ev.repo = repo
ev.commit = seafserv_threaded_rpc.get_commit(repo.id, repo.version, ev.commit_id)
valid_events.append(ev)
if len(valid_events) == limit:
break
if len(valid_events) == limit:
break
next_start = next_start + len(valid_events)
return valid_events
开发者ID:jamjr,项目名称:seahub,代码行数:35,代码来源:__init__.py
示例4: _get_events_inner
def _get_events_inner(ev_session, username, start, org_id=None):
'''Read 11 events from seafevents database, and remove events that are
no longer valid
'''
if org_id == None:
events = seafevents.get_user_events(ev_session, username, start, start + 11)
else:
events = seafevents.get_org_user_events(ev_session, \
org_id, username, start, start + 11)
total = len(events)
valid_events = []
for ev in events:
if ev.etype == 'repo-update':
repo = get_repo(ev.repo_id)
if not repo:
# delete the update event for repo which has been deleted
seafevents.delete_event(ev_session, ev.uuid)
continue
if repo.encrypted:
repo.password_set = seafserv_rpc.is_passwd_set(repo.id, username)
ev.repo = repo
ev.commit = seafserv_threaded_rpc.get_commit(ev.commit_id)
valid_events.append(ev)
return total, valid_events
开发者ID:oculusit,项目名称:seahub,代码行数:27,代码来源:__init__.py
示例5: get_commit_before_new_merge
def get_commit_before_new_merge(commit):
"""Traverse parents of ``commit``, and get a commit which is not a new merge.
Pre-condition: ``commit`` must be a new merge and not conflict.
Arguments:
- `commit`:
"""
assert new_merge_with_no_conflict(commit) is True
while(new_merge_with_no_conflict(commit)):
p1 = seafserv_threaded_rpc.get_commit(commit.repo_id, commit.version, commit.parent_id)
p2 = seafserv_threaded_rpc.get_commit(commit.repo_id, commit.version, commit.second_parent_id)
commit = p1 if p1.ctime > p2.ctime else p2
assert new_merge_with_no_conflict(commit) is False
return commit
开发者ID:jamjr,项目名称:seahub,代码行数:18,代码来源:__init__.py
示例6: get_repo_last_modify
def get_repo_last_modify(repo):
""" Get last modification time for a repo.
If head commit id of a repo is provided, we use that commit as last commit,
otherwise falls back to getting last commit of a repo which is time
consuming.
"""
if repo.head_cmmt_id is not None:
last_cmmt = seafserv_threaded_rpc.get_commit(repo.id, repo.version, repo.head_cmmt_id)
else:
logger.info('[repo %s] head_cmmt_id is missing.' % repo.id)
last_cmmt = get_commits(repo.id, 0, 1)[0]
return last_cmmt.ctime if last_cmmt else 0
开发者ID:jamjr,项目名称:seahub,代码行数:13,代码来源:__init__.py
示例7: get_org_user_events
def get_org_user_events(org_id, username, start):
ev_session = SeafEventsSession()
events = seafevents.get_org_user_events(ev_session, \
org_id, username, start, start + 11)
ev_session.close()
for ev in events:
if ev.etype == 'repo-update':
repo = get_repo(ev.repo_id)
if not repo:
ev.etype = 'dummy'
continue
if repo.encrypted:
repo.password_set = seafserv_rpc.is_passwd_set(repo.id, username)
ev.repo = repo
ev.commit = seafserv_threaded_rpc.get_commit(ev.commit_id)
return events
开发者ID:strogo,项目名称:seahub,代码行数:16,代码来源:utils.py
示例8: render_dir_recycle_dir
def render_dir_recycle_dir(request, repo_id, commit_id, dir_path):
basedir = request.GET.get('base', '')
path = request.GET.get('p', '')
if not basedir or not path:
return render_dir_recycle_root(request, repo_id, dir_path)
if basedir[0] != '/':
basedir = '/' + basedir
if path[-1] != '/':
path += '/'
repo = get_repo(repo_id)
if not repo:
raise Http404
try :
commit = seafserv_threaded_rpc.get_commit(repo.id, repo.version, commit_id)
except SearpcError as e:
logger.error(e)
referer = request.META.get('HTTP_REFERER', None)
next = settings.SITE_ROOT if referer is None else referer
return HttpResponseRedirect(next)
if not commit:
raise Http404
zipped = gen_path_link(path, '')
dir_entries = seafile_api.list_dir_by_commit_and_path(commit.repo_id,
commit.id, basedir+path,
-1, -1)
for dirent in dir_entries:
if stat.S_ISDIR(dirent.mode):
dirent.is_dir = True
else:
dirent.is_dir = False
return render_to_response('repo_dir_recycle_view.html', {
'show_recycle_root': False,
'repo': repo,
'repo_dir_name': os.path.basename(dir_path.rstrip('/')),
'zipped': zipped,
'dir_entries': dir_entries,
'commit_id': commit_id,
'basedir': basedir,
'path': path,
'dir_path': dir_path,
}, context_instance=RequestContext(request))
开发者ID:domal,项目名称:seahub,代码行数:47,代码来源:__init__.py
示例9: _get_events
def _get_events(username, start, org_id=None):
ev_session = SeafEventsSession()
if org_id == None:
events = seafevents.get_user_events(ev_session, username, start, start + 11)
else:
events = seafevents.get_org_user_events(ev_session, \
org_id, username, start, start + 11)
valid_events = []
ev_session.close()
for ev in events:
if ev.etype == 'repo-update':
repo = get_repo(ev.repo_id)
if not repo:
continue
if repo.encrypted:
repo.password_set = seafserv_rpc.is_passwd_set(repo.id, username)
ev.repo = repo
ev.commit = seafserv_threaded_rpc.get_commit(ev.commit_id)
valid_events.append(ev)
return valid_events
开发者ID:chuyskywalker,项目名称:seahub,代码行数:22,代码来源:__init__.py
注:本文中的seaserv.seafserv_threaded_rpc.get_commit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论