##// END OF EJS Templates
unmarshal p4 -G output to list
vivainio -
Show More
@@ -1,34 +1,42 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Add %p4 magic for pythonic p4 (Perforce) usage.
3 Add %p4 magic for pythonic p4 (Perforce) usage.
4 """
4 """
5
5
6 import IPython.ipapi
6 import IPython.ipapi
7 ip = IPython.ipapi.get()
7 ip = IPython.ipapi.get()
8
8
9 import os,sys,marshal
9 import os,sys,marshal
10
10
11 import ipy_stock_completers
11 import ipy_stock_completers
12
12
13 def p4_f(self, parameter_s=''):
13 def p4_f(self, parameter_s=''):
14 cmd = 'p4 -G ' + parameter_s
14 cmd = 'p4 -G ' + parameter_s
15 return marshal.load(os.popen(cmd))
15 fobj = os.popen(cmd)
16 out = []
17 while 1:
18 try:
19 out.append(marshal.load(fobj))
20 except EOFError:
21 break
22
23 return out
16
24
17 ip.expose_magic('p4', p4_f)
25 ip.expose_magic('p4', p4_f)
18
26
19 p4_commands = """\
27 p4_commands = """\
20 add admin annotate branch branches change changes changelist
28 add admin annotate branch branches change changes changelist
21 changelists client clients counter counters delete depot depots
29 changelists client clients counter counters delete depot depots
22 describe diff diff2 dirs edit filelog files fix fixes flush fstat
30 describe diff diff2 dirs edit filelog files fix fixes flush fstat
23 group groups have help info integrate integrated job jobs jobspec
31 group groups have help info integrate integrated job jobs jobspec
24 label labels labelsync lock logger login logout monitor obliterate
32 label labels labelsync lock logger login logout monitor obliterate
25 opened passwd print protect rename reopen resolve resolved revert
33 opened passwd print protect rename reopen resolve resolved revert
26 review reviews set submit sync tag tickets triggers typemap unlock
34 review reviews set submit sync tag tickets triggers typemap unlock
27 user users verify workspace workspaces where"""
35 user users verify workspace workspaces where"""
28
36
29 def p4_completer(self,event):
37 def p4_completer(self,event):
30 return ipy_stock_completers.vcs_completer(p4_commands, event)
38 return ipy_stock_completers.vcs_completer(p4_commands, event)
31
39
32 ip.set_hook('complete_command', p4_completer, str_key = '%p4')
40 ip.set_hook('complete_command', p4_completer, str_key = '%p4')
33
41 ip.set_hook('complete_command', p4_completer, str_key = 'p4')
34
42
General Comments 0
You need to be logged in to leave comments. Login now