~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2007-11-16 02:11:34 UTC
  • mto: This revision was merged to the branch mainline in revision 3002.
  • Revision ID: john@arbash-meinel.com-20071116021134-e0fjjpjllimkhj3v
Re-introduce the None check in case someone asks to uncommit *to* the last revision

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'
1066
1065
 
1067
1066
    @display_command
1068
1067
    def run(self, location=None, verbose=False):
1072
1071
            noise_level = 0
1073
1072
        from bzrlib.info import show_bzrdir_info
1074
1073
        show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
1075
 
                         verbose=noise_level, outfile=self.outf)
 
1074
                         verbose=noise_level)
1076
1075
 
1077
1076
 
1078
1077
class cmd_remove(Command):
1386
1385
    "bzr diff -p1" is equivalent to "bzr diff --prefix old/:new/", and
1387
1386
    produces patches suitable for "patch -p1".
1388
1387
 
1389
 
    :Exit values:
1390
 
        1 - changed
1391
 
        2 - unrepresentable changes
1392
 
        3 - error
1393
 
        0 - no change
1394
 
 
1395
1388
    :Examples:
1396
1389
        Shows the difference in the working tree versus the last commit::
1397
1390
 
2369
2362
    def run(self, branch=None, verbose=False):
2370
2363
        from bzrlib.check import check
2371
2364
        if branch is None:
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()
 
2365
            branch = Branch.open_containing('.')[0]
 
2366
        else:
 
2367
            branch = Branch.open(branch)
 
2368
        check(branch, verbose)
2402
2369
 
2403
2370
 
2404
2371
class cmd_upgrade(Command):
4197
4164
            short_name='d',
4198
4165
            type=unicode,
4199
4166
            ),
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',
4206
4167
    ]
4207
4168
 
4208
4169
    @display_command
4209
4170
    def run(self,
4210
4171
            directory='.',
4211
 
            sort='alpha',
4212
 
            show_ids=False,
4213
4172
            ):
4214
4173
        branch, relpath = Branch.open_containing(directory)
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))
 
4174
        for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
 
4175
            self.outf.write('%-20s %s\n' % (tag_name, target))
4236
4176
 
4237
4177
 
4238
4178
class cmd_reconfigure(Command):