~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] john

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    for filename in file_list:
59
59
        try:
60
60
            new_list.append(tree.relpath(filename))
61
 
        except NotBranchError:
 
61
        except errors.PathNotChild:
62
62
            raise FileInWrongBranch(tree.branch, filename)
63
63
    return tree, new_list
64
64
 
157
157
    """Show current revision number.
158
158
 
159
159
    This is equal to the number of revisions on this branch."""
 
160
    takes_args = ['location?']
160
161
    @display_command
161
 
    def run(self):
162
 
        print Branch.open_containing(u'.')[0].revno()
 
162
    def run(self, location=u'.'):
 
163
        print Branch.open_containing(location)[0].revno()
163
164
 
164
165
 
165
166
class cmd_revision_info(Command):
478
479
                            raise BzrCommandError("Could not creeate "
479
480
                                                  "path prefix.")
480
481
            br_to = Branch.initialize(location)
 
482
        old_rh = br_to.revision_history()
481
483
        try:
482
 
            old_rh = br_to.revision_history()
483
 
            count = br_to.pull(br_from, overwrite)
 
484
            try:
 
485
                tree_to = br_to.working_tree()
 
486
            except NoWorkingTree:
 
487
                # TODO: This should be updated for branches which don't have a
 
488
                # working tree, as opposed to ones where we just couldn't 
 
489
                # update the tree.
 
490
                warning('Unable to update the working tree of: %s' % (br_to.base,))
 
491
                count = br_to.pull(br_from, overwrite)
 
492
            else:
 
493
                count = tree_to.pull(br_from, overwrite)
484
494
        except DivergedBranches:
485
495
            raise BzrCommandError("These branches have diverged."
486
496
                                  "  Try a merge then push with overwrite.")
1171
1181
 
1172
1182
    @display_command
1173
1183
    def run(self, filename, revision=None):
1174
 
        if revision is None:
1175
 
            raise BzrCommandError("bzr cat requires a revision number")
1176
 
        elif len(revision) != 1:
 
1184
        if revision is not None and len(revision) != 1:
1177
1185
            raise BzrCommandError("bzr cat --revision takes exactly one number")
1178
1186
        tree = None
1179
1187
        try:
1181
1189
            b = tree.branch
1182
1190
        except NotBranchError:
1183
1191
            pass
 
1192
 
1184
1193
        if tree is None:
1185
1194
            b, relpath = Branch.open_containing(filename)
1186
 
        b.print_file(relpath, revision[0].in_history(b).revno)
 
1195
        if revision is None:
 
1196
            revision_id = b.last_revision()
 
1197
        else:
 
1198
            revision_id = revision[0].in_history(b).rev_id
 
1199
        b.print_file(relpath, revision_id)
1187
1200
 
1188
1201
 
1189
1202
class cmd_local_time_offset(Command):