本文整理汇总了Python中git.Git.shadowInit方法的典型用法代码示例。如果您正苦于以下问题:Python Git.shadowInit方法的具体用法?Python Git.shadowInit怎么用?Python Git.shadowInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Git
的用法示例。
在下文中一共展示了Git.shadowInit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import shadowInit [as 别名]
#.........这里部分代码省略.........
def push(self, remote):
""" Sync with the git server
Push using shadow-git tools, first shadow-push,
if rejected because of unfetched update on the
server side, do a shadow-fetch and shadow-merge,
then a shadow-push again. In case of conflict
that can not be automatically resolved, exit,
after manually solved the conflict, user can
then try to push again.
"""
if not self.preActionOfPushAndFetch(remote):
return False
for i in range(2): # try twice at most
print('pushing...')
stat, msg = self.git.shadowPush(remote)
if stat == Git.TOFETCH:
print('push rejected, need to fetch')
if self.fetch(remote):
continue
elif stat == Git.UNKNOWN:
self.perror('unknown error:\n' + msg.decode())
elif stat == Git.SUCCESS:
print('push done.')
return True
return False
def preActionOfPushAndFetch(self, remote):
""" Actions to carry out before push/fetch
"""
if not self.git.shadowInit():
return False
if not self.git.setRemote(remote):
return False
return True
def fetch(self, remote):
""" Fetch from the git server
"""
if not self.preActionOfPushAndFetch(remote):
return False
print('fetching...')
stat, msg = self.git.shadowFetch(remote)
if not stat:
self.perror('fetch failed:\n' + msg.decode())
else:
print('merging...')
stat, msg = self.git.shadowMerge(remote)
if stat == Git.SUCCESS:
print('fetch done.')
return True
elif stat == Git.UNKNOWN:
self.perror('unknown error:\n' + msg.decode())
elif stat == Git.CONFLICT:
self.perror('automatic merge failed, fix the conflict, and retry')
return False
def recentLogs(self, count):
""" Fetch the last 'count' logs that newly
added or changed, use git for better speed.