Changeset 257
- Timestamp:
- 26-05-07 13:21:34 (6 years ago)
- File:
-
- 1 edited
-
trunk/moap/vcs/bzr.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/moap/vcs/bzr.py
r256 r257 8 8 import os 9 9 import commands 10 import subprocess11 10 import re 12 11 … … 14 13 from moap.vcs import vcs 15 14 16 def _getoutput(argv):17 return subprocess.Popen(argv, stdout=subprocess.PIPE).communicate()[0]18 19 def _getstatusoutput(argv):20 p = subprocess.Popen(argv, stdout=subprocess.PIPE)21 out = p.communicate()[0]22 return p.returncode, out23 24 15 def detect(path): 25 16 """ 26 Detect if the given source tree is using B zr.17 Detect if the given source tree is using Bazaar. 27 18 28 @return: True if the given path looks like a B zr tree.19 @return: True if the given path looks like a Bazaar tree. 29 20 """ 30 21 while path and path != '/': … … 40 31 41 32 def getNotIgnored(self): 42 return _getoutput(["bzr", "unknowns"]).split('\n') 33 oldPath = os.getcwd() 34 os.chdir(self.path) 35 36 result = commands.getoutput("bzr unknowns").split('\n') 37 # one empty line does not a return value make 38 if result and result == ['']: 39 result = [] 40 41 os.chdir(oldPath) 42 return result 43 43 44 44 def ignore(self, paths, commit=True): 45 subprocess.call(['bzr', 'ignore'] + list(paths)) 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 46 57 if commit: 47 self.commit([os.path.join(self.path, '.bzrignore'), ],58 self.commit([os.path.join(self.path, '.bzrignore'), ], 48 59 'moap ignore') 60 61 os.chdir(oldPath) 49 62 50 63 def commit(self, paths, message): 51 64 try: 52 curpath = os.getcwd()65 oldPath = os.getcwd() 53 66 os.chdir(self.path) 54 subprocess.call(['bzr', 'commit', '-m', message] + paths)67 os.system("bzr commit -m \"%s\" %s" % (message, " ".join(paths))) 55 68 finally: 56 os.chdir( curpath)69 os.chdir(oldPath) 57 70 58 71 def diff(self, path): 59 return _getoutput(['bzr', 'diff']) 72 oldPath = os.getcwd() 73 os.chdir(path) 74 75 output = commands.getoutput("bzr diff") 76 77 os.chdir(oldPath) 78 return output 60 79 61 80 def getFileMatcher(self): … … 64 83 def update(self, path): 65 84 # FIXME: No way to pull just updates to the given path 66 status, output = _getstatusoutput(['bzr', 'pull'])85 status, output = commands.getstatusoutput("bzr pull") 67 86 if status != 0: 68 87 raise vcs.VCSException(output)
Note: See TracChangeset
for help on using the changeset viewer.
