1
2
3
4 """
5 Bazaar functionality.
6 """
7
8 import os
9 import commands
10 import re
11
12 from moap.util import util, log
13 from moap.vcs import vcs
14
16 """
17 Detect if the given source tree is using Bazaar.
18
19 @return: True if the given path looks like a Bazaar tree.
20 """
21 while path and path != '/':
22 if (os.path.exists(os.path.join(path, '.bzr'))
23 and os.path.exists(os.path.join(path, '.bzr', 'checkout'))):
24 return True
25 path = os.path.dirname(path)
26 return False
27
28
30 name = 'Bazaar'
31
33 oldPath = os.getcwd()
34 os.chdir(self.path)
35
36 result = commands.getoutput("bzr unknowns").split('\n')
37
38 if result and result == ['']:
39 result = []
40
41 os.chdir(oldPath)
42 return result
43
44 - def ignore(self, paths, commit=True):
45 if not paths:
46 return
47
48 oldPath = os.getcwd()
49 os.chdir(self.path)
50
51 self.debug("Ignoring %d paths" % len(paths))
52
53 cmd = "bzr ignore %s" % " ".join(paths)
54 self.debug("Running %s" % cmd)
55 os.system(cmd)
56
57 if commit:
58 self.commit([os.path.join(self.path, '.bzrignore'), ],
59 'moap ignore')
60
61 os.chdir(oldPath)
62
63 - def commit(self, paths, message):
64 try:
65 oldPath = os.getcwd()
66 os.chdir(self.path)
67 os.system("bzr commit -m \"%s\" %s" % (message, " ".join(paths)))
68 finally:
69 os.chdir(oldPath)
70
71 - def diff(self, path):
72 output = commands.getoutput("bzr diff %s" % path)
73
74 return output
75
77 return re.compile(r'^\+\+\+ ([^\t]+)\t.*$')
78
80
81 status, output = commands.getstatusoutput("bzr pull")
82 if status != 0:
83 raise vcs.VCSException(output)
84
85 return output
86
87 VCSClass = Bzr
88