89
89
class cmd_cat_revision(Command):
90
"""Write out metadata for a revision."""
90
"""Write out metadata for a revision.
92
The revision to print can either be specified by a specific
93
revision identifier, or you can use --revision.
93
takes_args = ['revision_id']
97
takes_args = ['revision_id?']
98
takes_options = ['revision']
95
def run(self, revision_id):
100
def run(self, revision_id=None, revision=None):
101
from bzrlib.revisionspec import RevisionSpec
103
if revision_id is not None and revision is not None:
104
raise BzrCommandError('You can only supply one of revision_id or --revision')
105
if revision_id is None and revision is None:
106
raise BzrCommandError('You must supply either --revision or a revision_id')
96
107
b = Branch.open_containing('.')
97
sys.stdout.write(b.get_revision_xml_file(revision_id).read())
108
if revision_id is not None:
109
sys.stdout.write(b.get_revision_xml_file(revision_id).read())
110
elif revision is not None:
113
raise BzrCommandError('You cannot specify a NULL revision.')
114
revno, rev_id = rev.in_history(b)
115
sys.stdout.write(b.get_revision_xml_file(rev_id).read())
100
118
class cmd_revno(Command):
112
130
takes_args = ['revision_info*']
113
131
takes_options = ['revision']
114
def run(self, revision=None, revision_info_list=()):
132
def run(self, revision=None, revision_info_list=[]):
115
133
from bzrlib.revisionspec import RevisionSpec
118
136
if revision is not None:
119
137
revs.extend(revision)
120
for rev in revision_info_list:
121
revs.append(RevisionSpec(revision_info_list))
138
if revision_info_list is not None:
139
for rev in revision_info_list:
140
revs.append(RevisionSpec(rev))
122
141
if len(revs) == 0:
123
142
raise BzrCommandError('You must supply a revision identifier')
125
144
b = Branch.open_containing('.')
128
print '%4d %s' % rev.in_history(b)
147
revinfo = rev.in_history(b)
148
if revinfo.revno is None:
149
print ' %s' % revinfo.rev_id
151
print '%4d %s' % (revinfo.revno, revinfo.rev_id)
131
154
class cmd_add(Command):
1187
1210
if None in revision:
1188
1211
raise BzrCommandError(
1189
1212
"Merge doesn't permit that revision specifier.")
1190
base = [branch, revision[0].in_history(branch).revno]
1191
other = [branch, revision[1].in_history(branch).revno]
1213
from bzrlib.branch import Branch
1214
b = Branch.open(branch)
1216
base = [branch, revision[0].in_history(b).revno]
1217
other = [branch, revision[1].in_history(b).revno]
1194
1220
merge(other, base, check_clean=(not force), merge_type=merge_type)
1222
1248
if len(file_list) == 0:
1223
1249
raise BzrCommandError("No files specified")
1224
1250
if revision is None:
1226
1252
elif len(revision) != 1:
1227
1253
raise BzrCommandError('bzr revert --revision takes exactly 1 argument')
1228
merge(('.', revision[0]), parse_spec('.'),
1255
b = Branch.open_containing('.')
1256
revno = revision[0].in_history(b).revno
1257
merge(('.', revno), parse_spec('.'),
1229
1258
check_clean=False,
1230
1259
ignore_zero=True,
1231
1260
backup_files=not no_backup,