/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: 2016-02-13 13:25:21 UTC
  • Revision ID: tim@ed.am-20160213132521-46v5774k6ql7tdfn
fixed uninitialised variable

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
 
37
38
                self.dir = dir
38
39
 
39
40
 
113
114
                                        raise RunTimeError(
114
115
                                                'failed to parse bzr kind change: %s' % file )
115
116
                                file = matches.group( 1 )
116
 
                                if the.verbose > 1: print "removing (kind changed): " + file
 
117
                                if the.verbose >= 2: print "removing (kind changed): " + file
117
118
                                full_file = os.path.join( self.dir, file )
118
119
                                if os.path.isfile( full_file ) or os.path.islink( full_file ):
119
120
                                        os.unlink( full_file )
132
133
                # remove unknown files
133
134
                if 'unknown' in files:
134
135
                        for file in files[ 'unknown' ]:
135
 
                                if the.verbose > 1: print "removing (unknown): " + file
 
136
                                if the.verbose >= 2: print "removing (unknown): " + file
136
137
                                full_file = os.path.join( self.dir, file )
137
138
                                if os.path.isfile( full_file ):
138
139
                                        os.unlink( full_file )
141
142
                                else:
142
143
                                        raise RuntimeError( 'exotic file in repo: %s' % file )
143
144
 
144
 
                # if a revision identifyer has been given, update to that
145
 
                if revno is not None:
 
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:
146
147
 
147
148
                        # bzr update
148
149
                        self.run( [ 'bzr', 'update', '-r', revno ] )
202
203
                for line in buf:
203
204
                        if not re.search( '^[-R+ ?][K NMD!][* ] ', line ): continue
204
205
                        line = line.rstrip()
205
 
                        if the.verbose > 1: print '  %s' % line
 
206
                        if the.verbose >= 2: print '  %s' % line
206
207
 
207
208
                        # renames show before and after file names
208
209
                        matches = re.search( '^R.. (.*?)[/@+]? => (.*?)[/@+]?$', line )
253
254
                return files['conflicts'] if 'conflicts' in files else None
254
255
 
255
256
 
 
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
 
256
274
        def run( self, cmd ):
257
 
                if the.verbose > 1: print 'exec: %s' % ' '.join( cmd )
 
275
                if the.verbose >= 2: print 'exec: %s' % ' '.join( cmd )
258
276
                p = Popen( cmd, cwd = self.dir,
259
277
                                   stdout = subprocess.PIPE, stderr = subprocess.STDOUT )
260
278
                output = p.communicate()[ 0 ]