~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Andrew Bennetts
  • Date: 2007-11-10 15:09:09 UTC
  • mfrom: (2916.2.17 streamable-containers)
  • mto: This revision was merged to the branch mainline in revision 3174.
  • Revision ID: andrew.bennetts@canonical.com-20071110150909-ik5254kgn930th10
Merge streamable-containers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1062
1062
    _see_also = ['revno', 'working-trees', 'repositories']
1063
1063
    takes_args = ['location?']
1064
1064
    takes_options = ['verbose']
 
1065
    encoding_type = 'replace'
1065
1066
 
1066
1067
    @display_command
1067
1068
    def run(self, location=None, verbose=False):
1071
1072
            noise_level = 0
1072
1073
        from bzrlib.info import show_bzrdir_info
1073
1074
        show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
1074
 
                         verbose=noise_level)
 
1075
                         verbose=noise_level, outfile=self.outf)
1075
1076
 
1076
1077
 
1077
1078
class cmd_remove(Command):
1385
1386
    "bzr diff -p1" is equivalent to "bzr diff --prefix old/:new/", and
1386
1387
    produces patches suitable for "patch -p1".
1387
1388
 
 
1389
    :Exit values:
 
1390
        1 - changed
 
1391
        2 - unrepresentable changes
 
1392
        3 - error
 
1393
        0 - no change
 
1394
 
1388
1395
    :Examples:
1389
1396
        Shows the difference in the working tree versus the last commit::
1390
1397
 
2362
2369
    def run(self, branch=None, verbose=False):
2363
2370
        from bzrlib.check import check
2364
2371
        if branch is None:
2365
 
            branch = Branch.open_containing('.')[0]
2366
 
        else:
2367
 
            branch = Branch.open(branch)
2368
 
        check(branch, verbose)
 
2372
            branch_obj = Branch.open_containing('.')[0]
 
2373
        else:
 
2374
            branch_obj = Branch.open(branch)
 
2375
        check(branch_obj, verbose)
 
2376
        # bit hacky, check the tree parent is accurate
 
2377
        try:
 
2378
            if branch is None:
 
2379
                tree = WorkingTree.open_containing('.')[0]
 
2380
            else:
 
2381
                tree = WorkingTree.open(branch)
 
2382
        except (errors.NoWorkingTree, errors.NotLocalUrl):
 
2383
            pass
 
2384
        else:
 
2385
            # This is a primitive 'check' for tree state. Currently this is not
 
2386
            # integrated into the main check logic as yet.
 
2387
            tree.lock_read()
 
2388
            try:
 
2389
                tree_basis = tree.basis_tree()
 
2390
                tree_basis.lock_read()
 
2391
                try:
 
2392
                    repo_basis = tree.branch.repository.revision_tree(
 
2393
                        tree.last_revision())
 
2394
                    if len(list(repo_basis._iter_changes(tree_basis))):
 
2395
                        raise errors.BzrCheckError(
 
2396
                            "Mismatched basis inventory content.")
 
2397
                    tree._validate()
 
2398
                finally:
 
2399
                    tree_basis.unlock()
 
2400
            finally:
 
2401
                tree.unlock()
2369
2402
 
2370
2403
 
2371
2404
class cmd_upgrade(Command):
4164
4197
            short_name='d',
4165
4198
            type=unicode,
4166
4199
            ),
 
4200
        RegistryOption.from_kwargs('sort',
 
4201
            'Sort tags by different criteria.', title='Sorting',
 
4202
            alpha='Sort tags lexicographically (default).',
 
4203
            time='Sort tags chronologically.',
 
4204
            ),
 
4205
        'show-ids',
4167
4206
    ]
4168
4207
 
4169
4208
    @display_command
4170
4209
    def run(self,
4171
4210
            directory='.',
 
4211
            sort='alpha',
 
4212
            show_ids=False,
4172
4213
            ):
4173
4214
        branch, relpath = Branch.open_containing(directory)
4174
 
        for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
4175
 
            self.outf.write('%-20s %s\n' % (tag_name, target))
 
4215
        tags = branch.tags.get_tag_dict().items()
 
4216
        if sort == 'alpha':
 
4217
            tags.sort()
 
4218
        elif sort == 'time':
 
4219
            timestamps = {}
 
4220
            for tag, revid in tags:
 
4221
                try:
 
4222
                    revobj = branch.repository.get_revision(revid)
 
4223
                except errors.NoSuchRevision:
 
4224
                    timestamp = sys.maxint # place them at the end
 
4225
                else:
 
4226
                    timestamp = revobj.timestamp
 
4227
                timestamps[revid] = timestamp
 
4228
            tags.sort(key=lambda x: timestamps[x[1]])
 
4229
        if not show_ids:
 
4230
            # [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
 
4231
            revno_map = branch.get_revision_id_to_revno_map()
 
4232
            tags = [ (tag, '.'.join(map(str, revno_map.get(revid, ('?',)))))
 
4233
                        for tag, revid in tags ]
 
4234
        for tag, revspec in tags:
 
4235
            self.outf.write('%-20s %s\n' % (tag, revspec))
4176
4236
 
4177
4237
 
4178
4238
class cmd_reconfigure(Command):