/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-07-30 19:09:02 UTC
  • Revision ID: tim@ed.am-20140730190902-bkuu372rya4zokm8
added info for add command to --help; fixed bug with add command where all files
in directories could be added to the commit instead of just the ones you've
specified

Show diffs side-by-side

added added

removed removed

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