annotate python/patchutils.py @ 508:9b69ce4e50a4

stub
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 01 Sep 2013 19:38:34 -0700
parents
children cb8484ae2643
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
508
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 http://k0s.org/blog/20100821174911
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 Tag -> hg
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 # XXX stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 import subprocess
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import which
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 def call(*args, **kwargs):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 """"""
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 return subprocess.check_output(*args, **kwargs)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 class ExecuteCommands(object):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 def __init__(self, *commands, **kwargs):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 self.commands = commands
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 self.kwargs = kwargs
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 def __call__(self):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 for command in self.commands:
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 yield call(command, **self.kwargs)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 class lsdiff(ExecuteCommands):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 commands = ['lsdiff']
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 def __call__(self):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 output = []
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31 for retval in ExecuteCommands(self):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32 raise NotImplementedError
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
33
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
34 def hg_root(directory=None):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
35 directory = directory if directory else os.getcwd()
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
36
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
37 # CLI
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
38
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
39 def main(args=sys.argv[1:]):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
40 parser = optparse.OptionParser()
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
41 options, args = parser.parse_args(args)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
42
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
43 # find the root
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
44 root = hg_root()
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
45
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
46 # get the files
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
47 paths = lsdiff(root)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
48
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
49 if __name__ == '__main__':
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
50 main()