/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Daniel Watkins
  • Date: 2009-02-07 23:54:41 UTC
  • mto: (3993.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3994.
  • Revision ID: daniel@daniel-watkins.co.uk-20090207235441-igbvmxlrs7nz966p
Changed from option type to helper function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
                                     (e.path, file_list[0]))
74
74
 
75
75
 
 
76
def _get_one_revision(command_name, revisions):
 
77
    if revisions is None:
 
78
        return None
 
79
    if len(revisions) != 1:
 
80
        raise errors.BzrCommandError(
 
81
            'bzr %s --revision takes exactly one revision identifier' % (
 
82
                command_name,))
 
83
    return revisions[0]
 
84
 
 
85
 
76
86
def _get_one_revision_tree(command_name, revisions, branch=None, tree=None):
77
87
    if branch is None:
78
88
        branch = tree.branch
82
92
        else:
83
93
            rev_tree = branch.basis_tree()
84
94
    else:
85
 
        if len(revisions) != 1:
86
 
            raise errors.BzrCommandError(
87
 
                'bzr %s --revision takes exactly one revision identifier' % (
88
 
                    command_name,))
89
 
        rev_tree = revisions[0].as_tree(branch)
 
95
        revision = _get_one_revision(command_name, revisions)
 
96
        rev_tree = revision.as_tree(branch)
90
97
    return rev_tree
91
98
 
92
99
 
997
1004
 
998
1005
    _see_also = ['checkout']
999
1006
    takes_args = ['from_location', 'to_location?']
1000
 
    takes_options = ['1revision', Option('hardlink',
 
1007
    takes_options = ['revision', Option('hardlink',
1001
1008
        help='Hard-link working tree files where possible.'),
1002
1009
        Option('stacked',
1003
1010
            help='Create a stacked branch referring to the source branch. '
1014
1021
 
1015
1022
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1016
1023
            from_location)
 
1024
        revision = _get_one_revision(revision)
1017
1025
        br_from.lock_read()
1018
1026
        try:
1019
1027
            if revision is not None:
1085
1093
 
1086
1094
    _see_also = ['checkouts', 'branch']
1087
1095
    takes_args = ['branch_location?', 'to_location?']
1088
 
    takes_options = ['1revision',
 
1096
    takes_options = ['revision',
1089
1097
                     Option('lightweight',
1090
1098
                            help="Perform a lightweight checkout.  Lightweight "
1091
1099
                                 "checkouts depend on access to the branch for "
1108
1116
            to_location = branch_location
1109
1117
        accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(
1110
1118
            branch_location)
 
1119
        revision = _get_one_revision(revision)
1111
1120
        if files_from is not None:
1112
1121
            accelerator_tree = WorkingTree.open(files_from)
1113
1122
        if revision is not None: