/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/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-18 01:57:45 UTC
  • mto: This revision was merged to the branch mainline in revision 7493.
  • Revision ID: jelmer@jelmer.uk-20200218015745-q2ss9tsk74h4nh61
drop use of future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1188
1188
        if revno < 1 or revno > self.revno():
1189
1189
            raise errors.InvalidRevisionNumber(revno)
1190
1190
 
1191
 
    def clone(self, to_controldir, revision_id=None, name=None,
1192
 
              repository_policy=None, tag_selector=None):
 
1191
    def clone(self, to_controldir, revision_id=None, repository_policy=None):
1193
1192
        """Clone this branch into to_controldir preserving all semantic values.
1194
1193
 
1195
1194
        Most API users will want 'create_clone_on_transport', which creates a
1198
1197
        revision_id: if not None, the revision history in the new branch will
1199
1198
                     be truncated to end with revision_id.
1200
1199
        """
1201
 
        result = to_controldir.create_branch(name=name)
 
1200
        result = to_controldir.create_branch()
1202
1201
        with self.lock_read(), result.lock_write():
1203
1202
            if repository_policy is not None:
1204
1203
                repository_policy.configure_branch(result)
1205
 
            self.copy_content_into(
1206
 
                result, revision_id=revision_id, tag_selector=tag_selector)
 
1204
            self.copy_content_into(result, revision_id=revision_id)
1207
1205
        return result
1208
1206
 
1209
1207
    def sprout(self, to_controldir, revision_id=None, repository_policy=None,
1210
 
               repository=None, lossy=False, tag_selector=None):
 
1208
               repository=None, lossy=False):
1211
1209
        """Create a new line of development from the branch, into to_controldir.
1212
1210
 
1213
1211
        to_controldir controls the branch format.
1224
1222
        with self.lock_read(), result.lock_write():
1225
1223
            if repository_policy is not None:
1226
1224
                repository_policy.configure_branch(result)
1227
 
            self.copy_content_into(
1228
 
                result, revision_id=revision_id, tag_selector=tag_selector)
 
1225
            self.copy_content_into(result, revision_id=revision_id)
1229
1226
            master_url = self.get_bound_location()
1230
1227
            if master_url is None:
1231
1228
                result.set_parent(self.user_url)
1258
1255
                revno = 1
1259
1256
        destination.set_last_revision_info(revno, revision_id)
1260
1257
 
1261
 
    def copy_content_into(self, destination, revision_id=None, tag_selector=None):
 
1258
    def copy_content_into(self, destination, revision_id=None):
1262
1259
        """Copy the content of self into destination.
1263
1260
 
1264
1261
        revision_id: if not None, the revision history in the new branch will
1265
1262
                     be truncated to end with revision_id.
1266
 
        tag_selector: Optional callback that receives a tag name
1267
 
            and should return a boolean to indicate whether a tag should be copied
1268
1263
        """
1269
1264
        return InterBranch.get(self, destination).copy_content_into(
1270
 
            revision_id=revision_id, tag_selector=tag_selector)
 
1265
            revision_id=revision_id)
1271
1266
 
1272
1267
    def update_references(self, target):
1273
1268
        if not self._format.supports_reference_locations:
1312
1307
 
1313
1308
    def create_clone_on_transport(self, to_transport, revision_id=None,
1314
1309
                                  stacked_on=None, create_prefix=False,
1315
 
                                  use_existing_dir=False, no_tree=None,
1316
 
                                  tag_selector=None):
 
1310
                                  use_existing_dir=False, no_tree=None):
1317
1311
        """Create a clone of this branch and its bzrdir.
1318
1312
 
1319
1313
        :param to_transport: The transport to clone onto.
1333
1327
        dir_to = self.controldir.clone_on_transport(
1334
1328
            to_transport, revision_id=revision_id, stacked_on=stacked_on,
1335
1329
            create_prefix=create_prefix, use_existing_dir=use_existing_dir,
1336
 
            no_tree=no_tree, tag_selector=tag_selector)
 
1330
            no_tree=no_tree)
1337
1331
        return dir_to.open_branch()
1338
1332
 
1339
1333
    def create_checkout(self, to_location, revision_id=None,
2060
2054
        raise NotImplementedError(klass._get_branch_formats_to_test)
2061
2055
 
2062
2056
    def pull(self, overwrite=False, stop_revision=None,
2063
 
             possible_transports=None, local=False, tag_selector=None):
 
2057
             possible_transports=None, local=False):
2064
2058
        """Mirror source into target branch.
2065
2059
 
2066
2060
        The target branch is considered to be 'local', having low latency.
2070
2064
        raise NotImplementedError(self.pull)
2071
2065
 
2072
2066
    def push(self, overwrite=False, stop_revision=None, lossy=False,
2073
 
             _override_hook_source_branch=None, tag_selector=None):
 
2067
             _override_hook_source_branch=None):
2074
2068
        """Mirror the source branch into the target branch.
2075
2069
 
2076
2070
        The source branch is considered to be 'local', having low latency.
2077
2071
        """
2078
2072
        raise NotImplementedError(self.push)
2079
2073
 
2080
 
    def copy_content_into(self, revision_id=None, tag_selector=None):
 
2074
    def copy_content_into(self, revision_id=None):
2081
2075
        """Copy the content of source into target
2082
2076
 
2083
 
        :param revision_id:
2084
 
            if not None, the revision history in the new branch will
2085
 
            be truncated to end with revision_id.
2086
 
        :param tag_selector: Optional callback that can decide
2087
 
            to copy or not copy tags.
 
2077
        revision_id: if not None, the revision history in the new branch will
 
2078
                     be truncated to end with revision_id.
2088
2079
        """
2089
2080
        raise NotImplementedError(self.copy_content_into)
2090
2081
 
2131
2122
            return format._custom_format
2132
2123
        return format
2133
2124
 
2134
 
    def copy_content_into(self, revision_id=None, tag_selector=None):
 
2125
    def copy_content_into(self, revision_id=None):
2135
2126
        """Copy the content of source into target
2136
2127
 
2137
2128
        revision_id: if not None, the revision history in the new branch will
2148
2139
                if parent:
2149
2140
                    self.target.set_parent(parent)
2150
2141
            if self.source._push_should_merge_tags():
2151
 
                self.source.tags.merge_to(self.target.tags, selector=tag_selector)
 
2142
                self.source.tags.merge_to(self.target.tags)
2152
2143
 
2153
2144
    def fetch(self, stop_revision=None, limit=None, lossy=False):
2154
2145
        if self.target.base == self.source.base:
2209
2200
 
2210
2201
    def pull(self, overwrite=False, stop_revision=None,
2211
2202
             possible_transports=None, run_hooks=True,
2212
 
             _override_hook_target=None, local=False,
2213
 
             tag_selector=None):
 
2203
             _override_hook_target=None, local=False):
2214
2204
        """Pull from source into self, updating my master if any.
2215
2205
 
2216
2206
        :param run_hooks: Private parameter - if false, this branch
2241
2231
            if master_branch:
2242
2232
                # pull from source into master.
2243
2233
                master_branch.pull(
2244
 
                    self.source, overwrite, stop_revision, run_hooks=False,
2245
 
                    tag_selector=tag_selector)
 
2234
                    self.source, overwrite, stop_revision, run_hooks=False)
2246
2235
            return self._pull(
2247
2236
                overwrite, stop_revision, _hook_master=master_branch,
2248
2237
                run_hooks=run_hooks,
2249
2238
                _override_hook_target=_override_hook_target,
2250
 
                merge_tags_to_master=not source_is_master,
2251
 
                tag_selector=tag_selector)
 
2239
                merge_tags_to_master=not source_is_master)
2252
2240
 
2253
2241
    def push(self, overwrite=False, stop_revision=None, lossy=False,
2254
 
             _override_hook_source_branch=None, tag_selector=None):
 
2242
             _override_hook_source_branch=None):
2255
2243
        """See InterBranch.push.
2256
2244
 
2257
2245
        This is the basic concrete implementation of push()
2283
2271
                with master_branch.lock_write():
2284
2272
                    # push into the master from the source branch.
2285
2273
                    master_inter = InterBranch.get(self.source, master_branch)
2286
 
                    master_inter._basic_push(
2287
 
                        overwrite, stop_revision, tag_selector=tag_selector)
 
2274
                    master_inter._basic_push(overwrite, stop_revision)
2288
2275
                    # and push into the target branch from the source. Note
2289
2276
                    # that we push from the source branch again, because it's
2290
2277
                    # considered the highest bandwidth repository.
2291
 
                    result = self._basic_push(
2292
 
                        overwrite, stop_revision, tag_selector=tag_selector)
 
2278
                    result = self._basic_push(overwrite, stop_revision)
2293
2279
                    result.master_branch = master_branch
2294
2280
                    result.local_branch = self.target
2295
2281
                    _run_hooks()
2296
2282
            else:
2297
2283
                master_branch = None
2298
2284
                # no master branch
2299
 
                result = self._basic_push(
2300
 
                    overwrite, stop_revision, tag_selector=tag_selector)
 
2285
                result = self._basic_push(overwrite, stop_revision)
2301
2286
                # TODO: Why set master_branch and local_branch if there's no
2302
2287
                # binding?  Maybe cleaner to just leave them unset? -- mbp
2303
2288
                # 20070504
2306
2291
                _run_hooks()
2307
2292
            return result
2308
2293
 
2309
 
    def _basic_push(self, overwrite, stop_revision, tag_selector=None):
 
2294
    def _basic_push(self, overwrite, stop_revision):
2310
2295
        """Basic implementation of push without bound branches or hooks.
2311
2296
 
2312
2297
        Must be called with source read locked and target write locked.
2325
2310
        if self.source._push_should_merge_tags():
2326
2311
            result.tag_updates, result.tag_conflicts = (
2327
2312
                self.source.tags.merge_to(
2328
 
                    self.target.tags, "tags" in overwrite, selector=tag_selector))
 
2313
                    self.target.tags, "tags" in overwrite))
2329
2314
        self.update_references()
2330
2315
        result.new_revno, result.new_revid = self.target.last_revision_info()
2331
2316
        return result
2333
2318
    def _pull(self, overwrite=False, stop_revision=None,
2334
2319
              possible_transports=None, _hook_master=None, run_hooks=True,
2335
2320
              _override_hook_target=None, local=False,
2336
 
              merge_tags_to_master=True, tag_selector=None):
 
2321
              merge_tags_to_master=True):
2337
2322
        """See Branch.pull.
2338
2323
 
2339
2324
        This function is the core worker, used by GenericInterBranch.pull to
2377
2362
            result.tag_updates, result.tag_conflicts = (
2378
2363
                self.source.tags.merge_to(
2379
2364
                    self.target.tags, "tags" in overwrite,
2380
 
                    ignore_master=not merge_tags_to_master,
2381
 
                    selector=tag_selector))
 
2365
                    ignore_master=not merge_tags_to_master))
2382
2366
            self.update_references()
2383
2367
            result.new_revno, result.new_revid = (
2384
2368
                self.target.last_revision_info())