~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-20 13:31:00 UTC
  • mto: This revision was merged to the branch mainline in revision 6153.
  • Revision ID: jriddell@canonical.com-20110920133100-kpsomvcnjoxv6n6b
syntax fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
653
653
    are added.  This search proceeds recursively into versioned
654
654
    directories.  If no names are given '.' is assumed.
655
655
 
656
 
    A warning will be printed when nested trees are encountered,
657
 
    unless they are explicitly ignored.
658
 
 
659
656
    Therefore simply saying 'bzr add' will version all files that
660
657
    are currently unknown.
661
658
 
1344
1341
class cmd_branches(Command):
1345
1342
    __doc__ = """List the branches available at the current location.
1346
1343
 
1347
 
    This command will print the names of all the branches at the current
1348
 
    location.
 
1344
    This command will print the names of all the branches at the current location.
1349
1345
    """
1350
1346
 
1351
1347
    takes_args = ['location?']
1352
 
    takes_options = [
1353
 
                  Option('recursive', short_name='R',
1354
 
                         help='Recursively scan for branches rather than '
1355
 
                              'just looking in the specified location.')]
1356
1348
 
1357
 
    def run(self, location=".", recursive=False):
1358
 
        if recursive:
1359
 
            t = transport.get_transport(location)
1360
 
            if not t.listable():
1361
 
                raise errors.BzrCommandError(
1362
 
                    "Can't scan this type of location.")
1363
 
            for b in bzrdir.BzrDir.find_branches(t):
1364
 
                self.outf.write("%s\n" % urlutils.unescape_for_display(
1365
 
                    urlutils.relative_url(t.base, b.base),
1366
 
                    self.outf.encoding).rstrip("/"))
1367
 
        else:
1368
 
            dir = bzrdir.BzrDir.open_containing(location)[0]
1369
 
            for branch in dir.list_branches():
1370
 
                if branch.name is None:
1371
 
                    self.outf.write(gettext(" (default)\n"))
1372
 
                else:
1373
 
                    self.outf.write(" %s\n" % branch.name.encode(
1374
 
                        self.outf.encoding))
 
1349
    def run(self, location="."):
 
1350
        dir = bzrdir.BzrDir.open_containing(location)[0]
 
1351
        for branch in dir.list_branches():
 
1352
            if branch.name is None:
 
1353
                self.outf.write(gettext(" (default)\n"))
 
1354
            else:
 
1355
                self.outf.write(" %s\n" % branch.name.encode(self.outf.encoding))
1375
1356
 
1376
1357
 
1377
1358
class cmd_checkout(Command):
2636
2617
            match_dict['author'] = match_author
2637
2618
        if match_bugs:
2638
2619
            match_dict['bugs'] = match_bugs
2639
 
 
 
2620
            
2640
2621
        # Build the LogRequest and execute it
2641
2622
        if len(file_ids) == 0:
2642
2623
            file_ids = None
5255
5236
                    'option leads to global uncontrolled write access to your '
5256
5237
                    'file system.'
5257
5238
                ),
5258
 
        Option('client-timeout', type=float,
5259
 
               help='Override the default idle client timeout (5min).'),
5260
5239
        ]
5261
5240
 
5262
5241
    def get_host_and_port(self, port):
5279
5258
        return host, port
5280
5259
 
5281
5260
    def run(self, port=None, inet=False, directory=None, allow_writes=False,
5282
 
            protocol=None, client_timeout=None):
 
5261
            protocol=None):
5283
5262
        from bzrlib import transport
5284
5263
        if directory is None:
5285
5264
            directory = os.getcwd()
5290
5269
        if not allow_writes:
5291
5270
            url = 'readonly+' + url
5292
5271
        t = transport.get_transport(url)
5293
 
        try:
5294
 
            protocol(t, host, port, inet, client_timeout)
5295
 
        except TypeError, e:
5296
 
            # We use symbol_versioning.deprecated_in just so that people
5297
 
            # grepping can find it here.
5298
 
            # symbol_versioning.deprecated_in((2, 5, 0))
5299
 
            symbol_versioning.warn(
5300
 
                'Got TypeError(%s)\ntrying to call protocol: %s.%s\n'
5301
 
                'Most likely it needs to be updated to support a'
5302
 
                ' "timeout" parameter (added in bzr 2.5.0)'
5303
 
                % (e, protocol.__module__, protocol),
5304
 
                DeprecationWarning)
5305
 
            protocol(t, host, port, inet)
 
5272
        protocol(t, host, port, inet)
5306
5273
 
5307
5274
 
5308
5275
class cmd_join(Command):
5782
5749
 
5783
5750
        self.add_cleanup(branch.lock_read().unlock)
5784
5751
        if revision:
5785
 
            # Restrict to the specified range
5786
 
            tags = self._tags_for_range(branch, revision)
 
5752
            graph = branch.repository.get_graph()
 
5753
            rev1, rev2 = _get_revision_range(revision, branch, self.name())
 
5754
            revid1, revid2 = rev1.rev_id, rev2.rev_id
 
5755
            # only show revisions between revid1 and revid2 (inclusive)
 
5756
            tags = [(tag, revid) for tag, revid in tags if
 
5757
                graph.is_between(revid, revid1, revid2)]
5787
5758
        if sort is None:
5788
5759
            sort = tag_sort_methods.get()
5789
5760
        sort(branch, tags)
5794
5765
                    revno = branch.revision_id_to_dotted_revno(revid)
5795
5766
                    if isinstance(revno, tuple):
5796
5767
                        revno = '.'.join(map(str, revno))
5797
 
                except (errors.NoSuchRevision,
5798
 
                        errors.GhostRevisionsHaveNoRevno):
 
5768
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
5799
5769
                    # Bad tag data/merges can lead to tagged revisions
5800
5770
                    # which are not in this branch. Fail gracefully ...
5801
5771
                    revno = '?'
5804
5774
        for tag, revspec in tags:
5805
5775
            self.outf.write('%-20s %s\n' % (tag, revspec))
5806
5776
 
5807
 
    def _tags_for_range(self, branch, revision):
5808
 
        range_valid = True
5809
 
        rev1, rev2 = _get_revision_range(revision, branch, self.name())
5810
 
        revid1, revid2 = rev1.rev_id, rev2.rev_id
5811
 
        # _get_revision_range will always set revid2 if it's not specified.
5812
 
        # If revid1 is None, it means we want to start from the branch
5813
 
        # origin which is always a valid ancestor. If revid1 == revid2, the
5814
 
        # ancestry check is useless.
5815
 
        if revid1 and revid1 != revid2:
5816
 
            # FIXME: We really want to use the same graph than
5817
 
            # branch.iter_merge_sorted_revisions below, but this is not
5818
 
            # easily available -- vila 2011-09-23
5819
 
            if branch.repository.get_graph().is_ancestor(revid2, revid1):
5820
 
                # We don't want to output anything in this case...
5821
 
                return []
5822
 
        # only show revisions between revid1 and revid2 (inclusive)
5823
 
        tagged_revids = branch.tags.get_reverse_tag_dict()
5824
 
        found = []
5825
 
        for r in branch.iter_merge_sorted_revisions(
5826
 
            start_revision_id=revid2, stop_revision_id=revid1,
5827
 
            stop_rule='include'):
5828
 
            revid_tags = tagged_revids.get(r[0], None)
5829
 
            if revid_tags:
5830
 
                found.extend([(tag, r[0]) for tag in revid_tags])
5831
 
        return found
5832
 
 
5833
5777
 
5834
5778
class cmd_reconfigure(Command):
5835
5779
    __doc__ = """Reconfigure the type of a bzr directory.