/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_foreign.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
from ..bzr import groupcompress_repo
40
40
 
41
 
# This is the dummy foreign revision control system, used 
 
41
# This is the dummy foreign revision control system, used
42
42
# mainly here in the testsuite to test the foreign VCS infrastructure.
43
 
# It is basically standard Bazaar with some minor modifications to 
44
 
# make it "foreign". 
45
 
 
43
# It is basically standard Bazaar with some minor modifications to
 
44
# make it "foreign".
 
45
#
46
46
# It has the following differences to "regular" Bazaar:
47
47
# - The control directory is named ".dummy", not ".bzr".
48
48
# - The revision ids are tuples, not strings.
85
85
        self.abbreviation = "dummy"
86
86
 
87
87
    def show_foreign_revid(self, foreign_revid):
88
 
        return { "dummy ding": "%s/%s\\%s" % foreign_revid }
 
88
        return {"dummy ding": "%s/%s\\%s" % foreign_revid}
89
89
 
90
90
    def serialize_foreign_revid(self, foreign_revid):
91
91
        return "%s|%s|%s" % foreign_revid
104
104
        self._ignore_fallbacks = False
105
105
        self.controldir = a_controldir
106
106
        foreign.ForeignBranch.__init__(self,
107
 
            DummyForeignVcsMapping(DummyForeignVcs()))
 
107
                                       DummyForeignVcsMapping(DummyForeignVcs()))
108
108
        bzrbranch.BzrBranch6.__init__(self, _format, _control_files, a_controldir,
109
 
            *args, **kwargs)
 
109
                                      *args, **kwargs)
110
110
 
111
111
    def _get_checkout_format(self, lightweight=False):
112
112
        """Return the most suitable metadir for a checkout of this branch.
141
141
 
142
142
 
143
143
class DummyForeignVcsRepository(groupcompress_repo.CHKInventoryRepository,
144
 
    foreign.ForeignRepository):
 
144
                                foreign.ForeignRepository):
145
145
    """Dummy foreign vcs repository."""
146
146
 
147
147
 
160
160
 
161
161
def branch_history(graph, revid):
162
162
    ret = list(graph.iter_lefthand_ancestry(revid,
163
 
        (revision.NULL_REVISION,)))
 
163
                                            (revision.NULL_REVISION,)))
164
164
    ret.reverse()
165
165
    return ret
166
166
 
183
183
            graph = self.source.repository.get_graph()
184
184
            # This just handles simple cases, but that's good enough for tests
185
185
            my_history = branch_history(self.target.repository.get_graph(),
186
 
                result.old_revid)
 
186
                                        result.old_revid)
187
187
            if stop_revision is None:
188
188
                stop_revision = self.source.last_revision()
189
189
            their_history = branch_history(graph, stop_revision)
200
200
                new_revid = self.target.mapping.revision_id_foreign_to_bzr(
201
201
                    (b'%d' % rev.timestamp, str(rev.timezone).encode('ascii'),
202
202
                        str(self.target.revno()).encode('ascii')))
203
 
                parent_revno, parent_revid= self.target.last_revision_info()
 
203
                parent_revno, parent_revid = self.target.last_revision_info()
204
204
                if parent_revid == revision.NULL_REVISION:
205
205
                    parent_revids = []
206
206
                else:
207
207
                    parent_revids = [parent_revid]
208
208
                builder = self.target.get_commit_builder(parent_revids,
209
 
                        self.target.get_config_stack(), rev.timestamp,
210
 
                        rev.timezone, rev.committer, rev.properties,
211
 
                        new_revid)
 
209
                                                         self.target.get_config_stack(), rev.timestamp,
 
210
                                                         rev.timezone, rev.committer, rev.properties,
 
211
                                                         new_revid)
212
212
                try:
213
213
                    parent_tree = self.target.repository.revision_tree(
214
214
                        parent_revid)
220
220
                    builder.abort()
221
221
                    raise
222
222
                revidmap[revid] = builder.commit(rev.message)
223
 
                self.target.set_last_revision_info(parent_revno+1,
224
 
                    revidmap[revid])
 
223
                self.target.set_last_revision_info(parent_revno + 1,
 
224
                                                   revidmap[revid])
225
225
                trace.mutter('lossily pushed revision %s -> %s',
226
 
                    revid, revidmap[revid])
 
226
                             revid, revidmap[revid])
227
227
        finally:
228
228
            self.source.unlock()
229
229
        result.new_revno, result.new_revid = self.target.last_revision_info()
242
242
        return DummyForeignVcsDirFormat()
243
243
 
244
244
    def open(self, a_controldir, name=None, _found=False, ignore_fallbacks=False,
245
 
            found_repository=None):
 
245
             found_repository=None):
246
246
        if name is None:
247
247
            name = a_controldir._get_selected_branch()
248
248
        if not _found:
254
254
            if found_repository is None:
255
255
                found_repository = a_controldir.find_repository()
256
256
            return DummyForeignVcsBranch(_format=self,
257
 
                              _control_files=control_files,
258
 
                              a_controldir=a_controldir,
259
 
                              _repository=found_repository,
260
 
                              name=name)
 
257
                                         _control_files=control_files,
 
258
                                         a_controldir=a_controldir,
 
259
                                         _repository=found_repository,
 
260
                                         name=name)
261
261
        except errors.NoSuchFile:
262
262
            raise errors.NotBranchError(path=transport.base)
263
263
 
289
289
        # Since we don't have a .bzr directory, inherit the
290
290
        # mode from the root directory
291
291
        temp_control = lockable_files.LockableFiles(transport,
292
 
                            '', lockable_files.TransportLock)
 
292
                                                    '', lockable_files.TransportLock)
293
293
        temp_control._transport.mkdir('.dummy',
294
294
                                      # FIXME: RBC 20060121 don't peek under
295
295
                                      # the covers
298
298
        bzrdir_transport = transport.clone('.dummy')
299
299
        # NB: no need to escape relative paths that are url safe.
300
300
        control_files = lockable_files.LockableFiles(bzrdir_transport,
301
 
            self._lock_file_name, self._lock_class)
 
301
                                                     self._lock_file_name, self._lock_class)
302
302
        control_files.create_lock()
303
303
        return self.open(transport, _found=True)
304
304
 
314
314
        self.root_transport = _transport
315
315
        self._mode_check_done = False
316
316
        self._control_files = lockable_files.LockableFiles(self.transport,
317
 
            "lock", lockable_files.TransportLock)
 
317
                                                           "lock", lockable_files.TransportLock)
318
318
 
319
319
    def create_workingtree(self):
320
320
        # dirstate requires a ".bzr" entry to exist