Skip to content

Commit bfa4efe

Browse files
committed
Append PySvn_examples: commit_watcher.py, get_commit_by_revision.py
1 parent 6964fca commit bfa4efe

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

PySvn_examples/commit_watcher.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = 'ipetrash'
5+
6+
7+
# SOURCE: https://github.com/dsoprea/PySvn
8+
9+
10+
def get_log_list(url, revision_from=None, limit=None) -> list:
11+
import svn.remote
12+
repo = svn.remote.RemoteClient(url)
13+
14+
return list(repo.log_default(revision_from=revision_from, limit=limit))
15+
16+
17+
if __name__ == '__main__':
18+
url = 'svn+cplus://svn2.compassplus.ru/twrbs/csm/optt/dev/trunk'
19+
20+
last_log = get_log_list(url, limit=1)[0]
21+
last_revision = last_log.revision
22+
print('Start from commit rev{} by {}: "{}" in {}'.format(
23+
last_revision,
24+
last_log.author,
25+
repr(last_log.msg),
26+
last_log.date
27+
))
28+
29+
while True:
30+
log_list = get_log_list(url, revision_from=last_revision)
31+
if len(log_list) > 1:
32+
# Первым в списке будет коммит с ревизией revision_from
33+
log_list = log_list[1:]
34+
35+
last_log = log_list[-1]
36+
37+
if last_revision != last_log.revision:
38+
print('commits +{} from: rev{} by {}: "{}" in {}....{}\n'.format(
39+
len(log_list),
40+
last_revision,
41+
last_log.author,
42+
repr(last_log.msg),
43+
last_log.date,
44+
log_list
45+
))
46+
47+
last_revision = last_log.revision
48+
49+
# Every 10 minutes
50+
import time
51+
time.sleep(60 * 10)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = 'ipetrash'
5+
6+
7+
url = 'svn+cplus://svn2.compassplus.ru/twrbs/csm/optt/dev/trunk'
8+
9+
import svn.remote
10+
repo = svn.remote.RemoteClient(url)
11+
12+
print(list(repo.log_default(revision_from=159807, limit=1)))

0 commit comments

Comments
 (0)