pysvn에서 svn update를 실행할 때 가능한 경우 어떻게 파일을 추가, 제거, 업데이트했는지에 대한 정보를 얻을 수 있습니까? 이 정보를 로그 파일에 기록하고 싶습니다.log pysvn update
3
A
답변
2
원본 및 업데이트 된 버전을 저장 한 다음 diff_summarize를 사용하여 업데이트 된 파일을 가져올 수 있습니다.
여기에 예입니다 (pysvn Programmer's reference 참조)
import time
import pysvn
work_path = '.'
client = pysvn.Client()
entry = client.info(work_path)
old_rev = entry.revision.number
revs = client.update(work_path)
new_rev = revs[-1].number
print 'updated from %s to %s.\n' % (old_rev, new_rev)
head = pysvn.Revision(pysvn.opt_revision_kind.number, old_rev)
end = pysvn.Revision(pysvn.opt_revision_kind.number, new_rev)
log_messages = client.log(work_path, revision_start=head, revision_end=end,
limit=0)
for log in log_messages:
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(log.date))
print '[%s]\t%s\t%s\n %s\n' % (log.revision.number, timestamp,
log.author, log.message)
print
FILE_CHANGE_INFO = {
pysvn.diff_summarize_kind.normal: ' ',
pysvn.diff_summarize_kind.modified: 'M',
pysvn.diff_summarize_kind.delete: 'D',
pysvn.diff_summarize_kind.added: 'A',
}
print 'file changed:'
summary = client.diff_summarize(work_path, head, work_path, end)
for info in summary:
path = info.path
if info.node_kind == pysvn.node_kind.dir:
path += '/'
file_changed = FILE_CHANGE_INFO[info.summarize_kind]
prop_changed = ' '
if info.prop_changed:
prop_changed = 'M'
print file_changed + prop_changed, path
print
1
은 클라이언트 객체를 생성 할 때, notify callback를 추가합니다. 콜백은 이벤트에 대한 정보가 dict
인 함수입니다.
import pysvn
import pprint
def notify(event_dict):
pprint.pprint(event_dict)
client = pysvn.Client()
client.callback_notify = notify
# Perform actions with client
1
나는이 오래지만 거기에 허용 대답은하지 않고 node_kind
에 관한 정보를 검색하는 동안 내가 운 좋게 발견 한 것을 알고있다.
import pysvn
tmpFile = open('your.log', 'w')
repository = sys.argv[1]
transactionId = sys.argv[2]
transaction = pysvn.Transaction(repository, transactionId)
#
# transaction.changed()
#
# {
# u'some.file': ('R', <node_kind.file>, 1, 0),
# u'another.file': ('R', <node_kind.file>, 1, 0),
# u'aDirectory/a.file': ('R', <node_kind.file>, 1, 0),
# u'anotherDirectory': ('A', <node_kind.dir>, 0, 0),
# u'junk.file': ('D', <node_kind.file>, 0, 0)
# }
#
for changedFile in transaction.changed():
tmpFile.writelines(transaction.cat(changedFile))
# if you need to check data in the .changed() dict...
# if ('A' or 'R') in transaction.changed()[changedFile][0]
위의 SVN 사전 커밋 (pre-commit) 스크립트에서 비슷한 방식으로 트랜잭션을 사용합니다. 사전 자세한 내용
참조 문서 :
http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_transaction
또한 http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_transaction_changed
, 내가 트랜잭션의 목록도 관심을 가질 수있는() 메소드를 사용하지 않았지만 :
http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_transaction
'요약 = 클라이언트를. diff_summarize (url, pysvn.Revision (pysvn.opt_revision_kind.committed), url, pysvn.Revision (pysvn.opt_revision_kind.previous))'diff_summarize는 작업 경로가 아닌 두 URL에서 위와 같이 사용할 수 있습니까? – slee