/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-09-09 19:13:33 UTC
  • Revision ID: tim@ed.am-20140909191333-0b7hrzonxce8mgy3
attempt to allow arguments before main command by treating the first thing that
doesn't look like an option as the command

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