/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/vcs/bzr.py

  • Committer: Tim Marston
  • Date: 2014-04-06 14:04:12 UTC
  • Revision ID: tim@ed.am-20140406140412-jucgusrltzf8vyz5
during `stdhome status`, announce if a deployment is ongoing

Show diffs side-by-side

added added

removed removed

34
34
 
35
35
                @param dir the fully-qualified directory to work in.
36
36
                """
37
 
 
38
37
                self.dir = dir
39
38
 
40
39
 
114
113
                                        raise RunTimeError(
115
114
                                                'failed to parse bzr kind change: %s' % file )
116
115
                                file = matches.group( 1 )
117
 
                                if the.verbose >= 2: print "removing (kind changed): " + file
 
116
                                if the.verbose > 1: print "removing (kind changed): " + file
118
117
                                full_file = os.path.join( self.dir, file )
119
118
                                if os.path.isfile( full_file ) or os.path.islink( full_file ):
120
119
                                        os.unlink( full_file )
133
132
                # remove unknown files
134
133
                if 'unknown' in files:
135
134
                        for file in files[ 'unknown' ]:
136
 
                                if the.verbose >= 2: print "removing (unknown): " + file
 
135
                                if the.verbose > 1: print "removing (unknown): " + file
137
136
                                full_file = os.path.join( self.dir, file )
138
137
                                if os.path.isfile( full_file ):
139
138
                                        os.unlink( full_file )
142
141
                                else:
143
142
                                        raise RuntimeError( 'exotic file in repo: %s' % file )
144
143
 
145
 
                # if a revision identifier has been given, ensure we're updated to that
146
 
                if revno is not None and self.get_revno() != revno:
 
144
                # if a revision identifyer has been given, update to that
 
145
                if revno is not None:
147
146
 
148
147
                        # bzr update
149
148
                        self.run( [ 'bzr', 'update', '-r', revno ] )
203
202
                for line in buf:
204
203
                        if not re.search( '^[-R+ ?][K NMD!][* ] ', line ): continue
205
204
                        line = line.rstrip()
206
 
                        if the.verbose >= 2: print '  %s' % line
 
205
                        if the.verbose > 1: print '  %s' % line
207
206
 
208
207
                        # renames show before and after file names
209
208
                        matches = re.search( '^R.. (.*?)[/@+]? => (.*?)[/@+]?$', line )
254
253
                return files['conflicts'] if 'conflicts' in files else None
255
254
 
256
255
 
257
 
        def add( self, files ):
258
 
                """Make sure files are added to version control.
259
 
                @param files a list of relative filenames
260
 
                """
261
 
 
262
 
                # bzr add
263
 
                self.run( [ 'bzr', 'add', '-N' ] + files )
264
 
 
265
 
 
266
 
        def commit( self ):
267
 
                """Commit changes to the repo.
268
 
                """
269
 
 
270
 
                # bzr commit
271
 
                self.run( [ 'bzr', 'commit', '-m', '' ] )
272
 
 
273
 
 
274
256
        def run( self, cmd ):
275
 
                if the.verbose >= 2: print 'exec: %s' % ' '.join( cmd )
 
257
                if the.verbose > 1: print 'exec: %s' % ' '.join( cmd )
276
258
                p = Popen( cmd, cwd = self.dir,
277
259
                                   stdout = subprocess.PIPE, stderr = subprocess.STDOUT )
278
260
                output = p.communicate()[ 0 ]