~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Andrew Bennetts
  • Date: 2008-04-03 14:02:59 UTC
  • mfrom: (3331 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080403140259-83o949yopz03r40j
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
221
221
                if rev is None:
222
222
                    raise errors.BzrCommandError('You cannot specify a NULL'
223
223
                                                 ' revision.')
224
 
                revno, rev_id = rev.in_history(b)
 
224
                rev_id = rev.as_revision_id(b)
225
225
                self.outf.write(b.repository.get_revision_xml(rev_id).decode('utf-8'))
226
226
    
227
227
 
295
295
            revs.append(RevisionSpec.from_string('-1'))
296
296
 
297
297
        for rev in revs:
298
 
            revinfo = rev.in_history(b)
299
 
            if revinfo.revno is None:
 
298
            revision_id = rev.as_revision_id(b)
 
299
            try:
 
300
                revno = '%4d' % (b.revision_id_to_revno(revision_id))
 
301
            except errors.NoSuchRevision:
300
302
                dotted_map = b.get_revision_id_to_revno_map()
301
 
                revno = '.'.join(str(i) for i in dotted_map[revinfo.rev_id])
302
 
                print '%s %s' % (revno, revinfo.rev_id)
303
 
            else:
304
 
                print '%4d %s' % (revinfo.revno, revinfo.rev_id)
 
303
                revno = '.'.join(str(i) for i in dotted_map[revision_id])
 
304
            print '%s %s' % (revno, revision_id)
305
305
 
306
306
    
307
307
class cmd_add(Command):
466
466
                    raise errors.BzrCommandError(
467
467
                        'bzr inventory --revision takes exactly one revision'
468
468
                        ' identifier')
469
 
                revision_id = revision[0].in_history(work_tree.branch).rev_id
 
469
                revision_id = revision[0].as_revision_id(work_tree.branch)
470
470
                tree = work_tree.branch.repository.revision_tree(revision_id)
471
471
 
472
472
                extra_trees = [work_tree]
661
661
 
662
662
        if revision is not None:
663
663
            if len(revision) == 1:
664
 
                revision_id = revision[0].in_history(branch_from).rev_id
 
664
                revision_id = revision[0].as_revision_id(branch_from)
665
665
            else:
666
666
                raise errors.BzrCommandError(
667
667
                    'bzr pull --revision takes one value.')
922
922
        br_from.lock_read()
923
923
        try:
924
924
            if len(revision) == 1 and revision[0] is not None:
925
 
                revision_id = revision[0].in_history(br_from)[1]
 
925
                revision_id = revision[0].as_revision_id(br_from)
926
926
            else:
927
927
                # FIXME - wt.last_revision, fallback to branch, fall back to
928
928
                # None or perhaps NULL_REVISION to mean copy nothing
1016
1016
        if files_from is not None:
1017
1017
            accelerator_tree = WorkingTree.open(files_from)
1018
1018
        if len(revision) == 1 and revision[0] is not None:
1019
 
            revision_id = _mod_revision.ensure_null(
1020
 
                revision[0].in_history(source)[1])
 
1019
            revision_id = revision[0].as_revision_id(source)
1021
1020
        else:
1022
1021
            revision_id = None
1023
1022
        if to_location is None:
1877
1876
            relpath += '/'
1878
1877
        if revision is not None:
1879
1878
            tree = branch.repository.revision_tree(
1880
 
                revision[0].in_history(branch).rev_id)
 
1879
                revision[0].as_revision_id(branch))
1881
1880
        elif tree is None:
1882
1881
            tree = branch.basis_tree()
1883
1882
 
2142
2141
        else:
2143
2142
            if len(revision) != 1:
2144
2143
                raise errors.BzrCommandError('bzr export --revision takes exactly 1 argument')
2145
 
            rev_id = revision[0].in_history(b).rev_id
 
2144
            rev_id = revision[0].as_revision_id(b)
2146
2145
        t = b.repository.revision_tree(rev_id)
2147
2146
        try:
2148
2147
            export(t, dest, format, root)
2187
2186
        if revision is None:
2188
2187
            revision_id = b.last_revision()
2189
2188
        else:
2190
 
            revision_id = revision[0].in_history(b).rev_id
 
2189
            revision_id = revision[0].as_revision_id(b)
2191
2190
 
2192
2191
        cur_file_id = tree.path2id(relpath)
2193
2192
        rev_tree = b.repository.revision_tree(revision_id)
2992
2991
            other_revision_id = _mod_revision.ensure_null(
2993
2992
                other_branch.last_revision())
2994
2993
        else:
2995
 
            other_revision_id = \
2996
 
                _mod_revision.ensure_null(
2997
 
                    revision[-1].in_history(other_branch).rev_id)
 
2994
            other_revision_id = revision[-1].as_revision_id(other_branch)
2998
2995
        if (revision is not None and len(revision) == 2
2999
2996
            and revision[0] is not None):
3000
 
            base_revision_id = \
3001
 
                _mod_revision.ensure_null(
3002
 
                    revision[0].in_history(base_branch).rev_id)
 
2997
            base_revision_id = revision[0].as_revision_id(base_branch)
3003
2998
        else:
3004
2999
            base_revision_id = None
3005
3000
        # Remember where we merge from
3218
3213
        elif len(revision) != 1:
3219
3214
            raise errors.BzrCommandError('bzr revert --revision takes exactly 1 argument')
3220
3215
        else:
3221
 
            rev_id = revision[0].in_history(tree.branch).rev_id
 
3216
            rev_id = revision[0].as_revision_id(tree.branch)
3222
3217
        pb = ui.ui_factory.nested_progress_bar()
3223
3218
        try:
3224
3219
            tree.revert(file_list,
3469
3464
            if revision is None:
3470
3465
                rev_id = b.last_revision()
3471
3466
            else:
3472
 
                rev_id = revision[0].in_history(b).rev_id
 
3467
                rev_id = revision[0].as_revision_id(b)
3473
3468
            t = testament_class.from_revision(b.repository, rev_id)
3474
3469
            if long:
3475
3470
                sys.stdout.writelines(t.as_text_lines())
3516
3511
            elif len(revision) != 1:
3517
3512
                raise errors.BzrCommandError('bzr annotate --revision takes exactly 1 argument')
3518
3513
            else:
3519
 
                revision_id = revision[0].in_history(branch).rev_id
 
3514
                revision_id = revision[0].as_revision_id(branch)
3520
3515
            tree = branch.repository.revision_tree(revision_id)
3521
3516
            if wt is not None:
3522
3517
                file_id = wt.path2id(relpath)
4017
4012
            if len(revision) > 2:
4018
4013
                raise errors.BzrCommandError('bzr merge-directive takes '
4019
4014
                    'at most two one revision identifiers')
4020
 
            revision_id = revision[-1].in_history(branch).rev_id
 
4015
            revision_id = revision[-1].as_revision_id(branch)
4021
4016
            if len(revision) == 2:
4022
 
                base_revision_id = revision[0].in_history(branch).rev_id
4023
 
                base_revision_id = ensure_null(base_revision_id)
 
4017
                base_revision_id = revision[0].as_revision_id(branch)
4024
4018
        else:
4025
4019
            revision_id = branch.last_revision()
4026
4020
        revision_id = ensure_null(revision_id)
4186
4180
                if len(revision) > 2:
4187
4181
                    raise errors.BzrCommandError('bzr send takes '
4188
4182
                        'at most two one revision identifiers')
4189
 
                revision_id = revision[-1].in_history(branch).rev_id
 
4183
                revision_id = revision[-1].as_revision_id(branch)
4190
4184
                if len(revision) == 2:
4191
 
                    base_revision_id = revision[0].in_history(branch).rev_id
 
4185
                    base_revision_id = revision[0].as_revision_id(branch)
4192
4186
            if revision_id is None:
4193
4187
                revision_id = branch.last_revision()
4194
4188
            if revision_id == NULL_REVISION:
4354
4348
                        raise errors.BzrCommandError(
4355
4349
                            "Tags can only be placed on a single revision, "
4356
4350
                            "not on a range")
4357
 
                    revision_id = revision[0].in_history(branch).rev_id
 
4351
                    revision_id = revision[0].as_revision_id(branch)
4358
4352
                else:
4359
4353
                    revision_id = branch.last_revision()
4360
4354
                if (not force) and branch.tags.has_tag(tag_name):