jsvn: add 'watch-lock' subcommand for notification when file is unlocked
This commit is contained in:
parent
86ed22d3d6
commit
f307e3d256
45
jsvn
45
jsvn
@ -30,6 +30,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
from subprocess import *
|
from subprocess import *
|
||||||
|
|
||||||
PATH = os.environ['PATH'].split(os.pathsep)
|
PATH = os.environ['PATH'].split(os.pathsep)
|
||||||
@ -180,6 +181,47 @@ def merge(argv, svn):
|
|||||||
root + '/branches/' + argv[1] + path, '.']).wait()
|
root + '/branches/' + argv[1] + path, '.']).wait()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def watch_lock(argv, svn):
|
||||||
|
if len(argv) < 2:
|
||||||
|
return -1
|
||||||
|
path = argv[1]
|
||||||
|
if os.path.exists(path):
|
||||||
|
# Get the repository URL of the file being watched
|
||||||
|
p = Popen([svn, 'info', path], stdout=PIPE)
|
||||||
|
lines = p.communicate()[0].split('\n')
|
||||||
|
for line in lines:
|
||||||
|
m = re.match(r'URL: (.*)', line)
|
||||||
|
if m is not None:
|
||||||
|
path = m.group(1)
|
||||||
|
break
|
||||||
|
|
||||||
|
last_lock_owner = ''
|
||||||
|
while 1:
|
||||||
|
lock_owner = ''
|
||||||
|
p = Popen([svn, 'info', path], stdout=PIPE)
|
||||||
|
lines = p.communicate()[0].split('\n')
|
||||||
|
for line in lines:
|
||||||
|
m = re.match(r'Lock\sOwner:\s*(.*)', line)
|
||||||
|
if m is not None:
|
||||||
|
lock_owner = m.group(1)
|
||||||
|
break
|
||||||
|
if lock_owner == '':
|
||||||
|
break
|
||||||
|
if lock_owner != last_lock_owner:
|
||||||
|
sys.stdout.write('Locked by: %s\n' % lock_owner)
|
||||||
|
last_lock_owner = lock_owner
|
||||||
|
time.sleep(60)
|
||||||
|
|
||||||
|
sys.stdout.write('''
|
||||||
|
_ _ _ _ _ _
|
||||||
|
| | | |_ __ | | ___ ___| | _____ __| | |
|
||||||
|
| | | | '_ \| |/ _ \ / __| |/ / _ \/ _` | |
|
||||||
|
| |_| | | | | | (_) | (__| < __/ (_| |_|
|
||||||
|
\___/|_| |_|_|\___/ \___|_|\_\___|\__,_(_)
|
||||||
|
|
||||||
|
''')
|
||||||
|
return 0
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
realsvn = findInPath('svn')
|
realsvn = findInPath('svn')
|
||||||
colorsvn = findInPath('colorsvn')
|
colorsvn = findInPath('colorsvn')
|
||||||
@ -218,6 +260,9 @@ def main(argv):
|
|||||||
sys.stdout.write(getSVNRoot(realsvn) + '\n')
|
sys.stdout.write(getSVNRoot(realsvn) + '\n')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
if argv[0] == "watch-lock":
|
||||||
|
return watch_lock(argv, realsvn)
|
||||||
|
|
||||||
if argv[0] in ('st', 'status', 'log', 'up', 'update') \
|
if argv[0] in ('st', 'status', 'log', 'up', 'update') \
|
||||||
and colorsvn != '':
|
and colorsvn != '':
|
||||||
realsvn = colorsvn
|
realsvn = colorsvn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user