~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Lalo Martins
  • Date: 2005-09-13 09:52:12 UTC
  • mto: (1185.1.22)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: lalo@exoweb.net-20050913095212-210555d61a893f1e
fixing up users of RevisionSpec, and moving it over to commands.py
(single point)

There are still a few users who could move, but that's a thought for
later... when someone sits down to separate UI from backend code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.trace import mutter, note, log_error, warning
24
24
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError
25
25
from bzrlib.branch import Branch
26
 
from bzrlib.revisionspec import RevisionSpec
27
26
from bzrlib import BZRDIR
28
27
from bzrlib.commands import Command
29
28
 
111
110
    hidden = True
112
111
    takes_args = ['revision_info*']
113
112
    takes_options = ['revision']
114
 
    def run(self, revision=None, revision_info_list=None):
115
 
        from bzrlib.branch import find_branch
 
113
    def run(self, revision=None, revision_info_list=()):
 
114
        from bzrlib.revisionspec import RevisionSpec
116
115
 
117
116
        revs = []
118
117
        if revision is not None:
119
118
            revs.extend(revision)
120
 
        if revision_info_list is not None:
121
 
            revs.extend(revision_info_list)
 
119
        for rev in revision_info_list:
 
120
            revs.append(RevisionSpec(revision_info_list))
122
121
        if len(revs) == 0:
123
122
            raise BzrCommandError('You must supply a revision identifier')
124
123
 
125
124
        b = Branch.open_containing('.')
126
125
 
127
126
        for rev in revs:
128
 
            print '%4d %s' % RevisionSpec(rev).in_history(b)
 
127
            print '%4d %s' % rev.in_history(b)
129
128
 
130
129
    
131
130
class cmd_add(Command):
193
192
    
194
193
    def run(self, revision=None, show_ids=False):
195
194
        b = Branch.open_containing('.')
196
 
        if revision == None:
 
195
        if revision is None:
197
196
            inv = b.read_working_inventory()
198
197
        else:
199
198
            if len(revision) > 1:
200
199
                raise BzrCommandError('bzr inventory --revision takes'
201
200
                    ' exactly one revision identifier')
202
 
            spec = RevisionSpec(revision[0])
203
 
            inv = b.get_revision_inventory(spec.in_history(b).rev_id)
 
201
            inv = b.get_revision_inventory(revision[0].in_history(b).rev_id)
204
202
 
205
203
        for path, entry in inv.entries():
206
204
            if show_ids:
688
686
            rev1 = None
689
687
            rev2 = None
690
688
        elif len(revision) == 1:
691
 
            rev1 = rev2 = RevisionSpec(revision[0]).in_history(b).revno
 
689
            rev1 = rev2 = revision[0].in_history(b).revno
692
690
        elif len(revision) == 2:
693
 
            rev1 = RevisionSpec(revision[0]).in_history(b).revno
694
 
            rev2 = RevisionSpec(revision[1]).in_history(b).revno
 
691
            rev1 = revision[0].in_history(b).revno
 
692
            rev2 = revision[1].in_history(b).revno
695
693
        else:
696
694
            raise BzrCommandError('bzr log --revision takes one or two values.')
697
695
 
751
749
        if revision == None:
752
750
            tree = b.working_tree()
753
751
        else:
754
 
            tree = b.revision_tree(RevisionSpec(revision).in_history(b).rev_id)
 
752
            tree = b.revision_tree(revision.in_history(b).rev_id)
755
753
 
756
754
        for fp, fc, kind, fid in tree.list_files():
757
755
            if verbose:
889
887
        else:
890
888
            if len(revision) != 1:
891
889
                raise BzrError('bzr export --revision takes exactly 1 argument')
892
 
            rev_id = RevisionSpec(revision[0]).in_history(b).rev_id
 
890
            rev_id = revision[0].in_history(b).rev_id
893
891
        t = b.revision_tree(rev_id)
894
892
        root, ext = os.path.splitext(dest)
895
893
        if not format:
911
909
    takes_args = ['filename']
912
910
 
913
911
    def run(self, filename, revision=None):
914
 
        if revision == None:
 
912
        if revision is None:
915
913
            raise BzrCommandError("bzr cat requires a revision number")
916
914
        elif len(revision) != 1:
917
915
            raise BzrCommandError("bzr cat --revision takes exactly one number")
918
916
        b = Branch.open_containing('.')
919
 
        b.print_file(b.relpath(filename), revision[0])
 
917
        b.print_file(b.relpath(filename), revision[0].in_history(b).revno)
920
918
 
921
919
 
922
920
class cmd_local_time_offset(Command):
1188
1186
        else:
1189
1187
            if len(revision) == 1:
1190
1188
                base = [None, None]
1191
 
                spec = RevisionSpec(revision[0])
1192
 
                other = [branch, spec.in_history(branch).revno]
 
1189
                other = [branch, revision[0].in_history(branch).revno]
1193
1190
            else:
1194
1191
                assert len(revision) == 2
1195
1192
                if None in revision:
1196
1193
                    raise BzrCommandError(
1197
1194
                        "Merge doesn't permit that revision specifier.")
1198
 
                spec = RevisionSpec(revision[0])
1199
 
                base = [branch, spec.in_history(branch).revno]
1200
 
                spec = RevisionSpec(revision[1])
1201
 
                other = [branch, spec.in_history(branch).revno]
 
1195
                base = [branch, revision[0].in_history(branch).revno]
 
1196
                other = [branch, revision[1].in_history(branch).revno]
1202
1197
 
1203
1198
        try:
1204
1199
            merge(other, base, check_clean=(not force), merge_type=merge_type)