/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: 2022-06-27 15:43:15 UTC
  • Revision ID: tim@ed.am-20220627154315-jkxty19bjqpbsqk9
reverted brz->bzr

Show diffs side-by-side

added added

removed removed

1
 
# brz.py
 
1
# bzr.py
2
2
#
3
3
# Copyright (C) 2014 Tim Marston <tim@edm.am>
4
4
#
31
31
from .vcs import Vcs
32
32
 
33
33
 
34
 
class BrzVcs( Vcs ):
 
34
class BzrVcs( Vcs ):
35
35
 
36
36
 
37
37
        def __init__( self, dir ):
65
65
                # the directory shouldn't exist
66
66
                os.mkdir( self.dir )
67
67
 
68
 
                # brz init
 
68
                # bzr init
69
69
                try:
70
 
                        self.run( [ 'brz', 'init', '.' ] )
 
70
                        self.run( [ 'bzr', 'init', '.' ] )
71
71
                except self.VcsError as e:
72
72
 
73
73
                        # attempt to clean-up dir
88
88
                # the directory shouldn't exist
89
89
                os.mkdir( self.dir )
90
90
 
91
 
                # brz co
 
91
                # bzr co
92
92
                try:
93
 
                        self.run( [ 'brz', 'checkout', url, '.' ] )
 
93
                        self.run( [ 'bzr', 'checkout', url, '.' ] )
94
94
                except self.VcsError as e:
95
95
 
96
96
                        # attempt to clean-up dir
106
106
                """Obtain some sort of revision identifier
107
107
                """
108
108
 
109
 
                # brz revno
110
 
                output = self.run( [ 'brz', 'revno', '--tree' ] )
 
109
                # bzr revno
 
110
                output = self.run( [ 'bzr', 'revno', '--tree' ] )
111
111
 
112
112
                # parse revno
113
113
                buf = io.StringIO( output )
120
120
                revision.
121
121
                """
122
122
 
123
 
                # brz st
124
 
                output = self.run( [ 'brz', 'status' ] )
 
123
                # bzr st
 
124
                output = self.run( [ 'bzr', 'status' ] )
125
125
                files = self.parse_file_blocks( output )
126
126
 
127
 
                # remove kind changed files (or they can cause `brz revert` to break in
 
127
                # remove kind changed files (or they can cause `bzr revert` to break in
128
128
                # strange situations, like when a directory has been replaced with a
129
129
                # symlink to a non-existant file)
130
130
                if 'kind changed' in files:
132
132
                                matches = re.search( '^(.+?)[/@+]? \([^)]+\)$', file )
133
133
                                if not matches:
134
134
                                        raise RunTimeError(
135
 
                                                'failed to parse brz kind change: %s' % file )
 
135
                                                'failed to parse bzr kind change: %s' % file )
136
136
                                file = matches.group( 1 )
137
137
                                if the.verbose >= 2: print("removing (kind changed): " + file)
138
138
                                full_file = os.path.join( self.dir, file )
143
143
                                else:
144
144
                                        raise RuntimeError( 'exotic file in repo: %s' % file )
145
145
 
146
 
                # brz revert
147
 
                self.run( [ 'brz', 'revert', '--no-backup' ] )
 
146
                # bzr revert
 
147
                self.run( [ 'bzr', 'revert', '--no-backup' ] )
148
148
 
149
 
                # brz st
150
 
                output = self.run( [ 'brz', 'status' ] )
 
149
                # bzr st
 
150
                output = self.run( [ 'bzr', 'status' ] )
151
151
                files = self.parse_file_blocks( output )
152
152
 
153
153
                # remove unknown files
156
156
                                matches = re.search( r'^(.+?)[/@+]?$', file )
157
157
                                if not matches:
158
158
                                        raise RunTimeError(
159
 
                                                'failed to parse brz unknowns: %s' % file )
 
159
                                                'failed to parse bzr unknowns: %s' % file )
160
160
                                file = matches.group( 1 )
161
161
                                if the.verbose >= 2: print("removing (unknown): " + file)
162
162
                                full_file = os.path.join( self.dir, file )
170
170
                # if a revision identifier has been given, ensure we're updated to that
171
171
                if revno is not None and self.get_revno() != revno:
172
172
 
173
 
                        # brz update
174
 
                        self.run( [ 'brz', 'update', '-r', revno ] )
 
173
                        # bzr update
 
174
                        self.run( [ 'bzr', 'update', '-r', revno ] )
175
175
 
176
176
 
177
177
        def update( self ):
180
180
                operation.
181
181
                """
182
182
 
183
 
#               WARNING: the following might cause brz to ask for your ssh password more than
 
183
#               WARNING: the following might cause bzr to ask for your ssh password more than
184
184
#               once during an update!!!
185
185
#
186
186
#               # get revno
187
187
#               revno = self.get_revno()
188
188
#
189
189
#               # update to current revision (pull in history without updating tree)
190
 
#               self.run( [ 'brz', 'update', '-r', revno ] )
 
190
#               self.run( [ 'bzr', 'update', '-r', revno ] )
191
191
#
192
192
#               # get log output
193
193
#               next_revno = str( int( revno ) + 1 )
194
 
#               output = self.run( [ 'brz', 'log', '-r', next_revno + '..' ] )
 
194
#               output = self.run( [ 'bzr', 'log', '-r', next_revno + '..' ] )
195
195
#
196
196
#               # parse output
197
197
#               keep_files = list()
219
219
#                                                       rename_from = rename_files[ rename_from ]
220
220
#                                               rename_files[ line[ 4 : ] ] = rename_from
221
221
 
222
 
                # brz update properly
223
 
                output = self.run( [ 'brz', 'update' ] )
 
222
                # bzr update properly
 
223
                output = self.run( [ 'bzr', 'update' ] )
224
224
 
225
225
                # parse output (see logic in report() in bzrlib/delta.py)
226
226
                files = list()
249
249
                                continue
250
250
 
251
251
                        raise RuntimeError(
252
 
                                'failed to parse brz update output line:\n%s' % line )
 
252
                                'failed to parse bzr update output line:\n%s' % line )
253
253
 
254
254
                return files
255
255
 
271
271
                """Check if the branch has any local modifications.
272
272
                """
273
273
 
274
 
                # brz status
275
 
                output = self.run( [ 'brz', 'status', '--no-pending' ] )
 
274
                # bzr status
 
275
                output = self.run( [ 'bzr', 'status', '--no-pending' ] )
276
276
 
277
277
                # parse output
278
278
                files = self.parse_file_blocks( output )
283
283
                """Return a list of files that have conflicts.
284
284
                """
285
285
 
286
 
                # brz status
287
 
                output = self.run( [ 'brz', 'status', '--no-pending' ] )
 
286
                # bzr status
 
287
                output = self.run( [ 'bzr', 'status', '--no-pending' ] )
288
288
 
289
289
                # parse output
290
290
                files = self.parse_file_blocks( output )
296
296
                @param files a list of relative filenames
297
297
                """
298
298
 
299
 
                # brz add
300
 
                self.run( [ 'brz', 'add', '-N' ] + files )
 
299
                # bzr add
 
300
                self.run( [ 'bzr', 'add', '-N' ] + files )
301
301
 
302
302
 
303
303
        def commit( self ):
304
304
                """Commit changes to the repo.
305
305
                """
306
306
 
307
 
                # brz commit
 
307
                # bzr commit
308
308
                try:
309
 
                        self.run( [ 'brz', 'commit', '-m', '' ] )
 
309
                        self.run( [ 'bzr', 'commit', '-m', '' ] )
310
310
                except self.VcsError as e:
311
311
                        if re.search( 'Working tree is out of date', e.output ):
312
312
                                raise the.program.FatalError(