/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-16 00:26:53 UTC
  • Revision ID: tim@ed.am-20160216002653-oa8dgponknyislg3
added home directory change reporting to CopyOutWalker; added --quiet option to
update, resolve, revert and init commands; replace use of re.match with
re.search for clarity (and fixed related bug in FileMatcher); added BzrVcs.run
command output when verbose >= 2

Show diffs side-by-side

added added

removed removed

86
86
                """Obtain some sort of revision identifier
87
87
                """
88
88
 
89
 
                # bzr revert
 
89
                # bzr revno
90
90
                output = self.run( [ 'bzr', 'revno', '--tree' ] )
91
91
 
92
92
                # parse revno
109
109
                # symlink to a non-existant file)
110
110
                if 'kind changed' in files:
111
111
                        for file in files[ 'kind changed' ]:
112
 
                                matches = re.match( r'(.+?)[/@+]? \([^)]+\)', file )
 
112
                                matches = re.search( '^(.+?)[/@+]? \([^)]+\)$', file )
113
113
                                if not matches:
114
114
                                        raise RunTimeError(
115
115
                                                'failed to parse bzr kind change: %s' % file )
133
133
                # remove unknown files
134
134
                if 'unknown' in files:
135
135
                        for file in files[ 'unknown' ]:
 
136
                                matches = re.search( r'^(.+?)[/@+]?$', file )
 
137
                                if not matches:
 
138
                                        raise RunTimeError(
 
139
                                                'failed to parse bzr unknowns: %s' % file )
 
140
                                file = matches.group( 1 )
136
141
                                if the.verbose >= 2: print "removing (unknown): " + file
137
142
                                full_file = os.path.join( self.dir, file )
138
 
                                if os.path.isfile( full_file ):
 
143
                                if os.path.isfile( full_file ) or os.path.islink( full_file ):
139
144
                                        os.unlink( full_file )
140
145
                                elif os.path.isdir( full_file ):
141
146
                                        shutil.rmtree( full_file )
203
208
                for line in buf:
204
209
                        if not re.search( '^[-R+ ?][K NMD!][* ] ', line ): continue
205
210
                        line = line.rstrip()
206
 
                        if the.verbose >= 2: print '  %s' % line
207
211
 
208
212
                        # renames show before and after file names
209
213
                        matches = re.search( '^R.. (.*?)[/@+]? => (.*?)[/@+]?$', line )
278
282
                output = p.communicate()[ 0 ]
279
283
                if p.returncode > 0:
280
284
                        raise self.VcsError( ' '.join( cmd[ : 2 ] ), output )
 
285
                if the.verbose >= 2:
 
286
                        print re.sub( '(^|\n)', '\\1  > ', output.rstrip() )
281
287
                return output
282
288
 
283
289