/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-23 19:35:21 UTC
  • Revision ID: tim@ed.am-20160223193521-2vgtxbfos50rrpku
renamed version -> VERSION

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