comparison mercurial/cmdutil.py @ 14323:a79fea6b3e77

debugindex etc.: add --changelog and --manifest options These open the changelog and manifest, respectively, directly so you don't need to specify the path. The options have been added to debugindex, debugdata and debugrevlog. The patch also fixes some minor usage-related bugs.
author Sune Foldager <cryo@cyanite.org>
date Sat, 14 May 2011 00:30:32 +0200
parents a90131b85fd8
children 5b48ad1e7f1a
comparison
equal deleted inserted replaced
14322:a90131b85fd8 14323:a79fea6b3e77
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from node import hex, nullid, nullrev, short 8 from node import hex, nullid, nullrev, short
9 from i18n import _ 9 from i18n import _
10 import os, sys, errno, re, tempfile 10 import os, sys, errno, re, tempfile
11 import util, scmutil, templater, patch, error, templatekw 11 import util, scmutil, templater, patch, error, templatekw, revlog
12 import match as matchmod 12 import match as matchmod
13 import subrepo 13 import subrepo
14 14
15 def parsealiases(cmd): 15 def parsealiases(cmd):
16 return cmd.lstrip("^").split("|") 16 return cmd.lstrip("^").split("|")
167 if hasattr(pat, 'read') and 'r' in mode: 167 if hasattr(pat, 'read') and 'r' in mode:
168 return pat 168 return pat
169 return open(makefilename(repo, pat, node, total, seqno, revwidth, 169 return open(makefilename(repo, pat, node, total, seqno, revwidth,
170 pathname), 170 pathname),
171 mode) 171 mode)
172
173 def openrevlog(repo, cmd, file_, opts):
174 """opens the changelog, manifest, a filelog or a given revlog"""
175 cl = opts['changelog']
176 mf = opts['manifest']
177 msg = None
178 if cl and mf:
179 msg = _('cannot specify --changelog and --manifest at the same time')
180 elif cl or mf:
181 if file_:
182 msg = _('cannot specify filename with --changelog or --manifest')
183 elif not repo:
184 msg = _('cannot specify --changelog or --manifest '
185 'without a repository')
186 if msg:
187 raise util.Abort(msg)
188
189 r = None
190 if repo:
191 if cl:
192 r = repo.changelog
193 elif mf:
194 r = repo.manifest
195 elif file_:
196 filelog = repo.file(file_)
197 if len(filelog):
198 r = filelog
199 if not r:
200 if not file_:
201 raise error.CommandError(cmd, _('invalid arguments'))
202 if not os.path.isfile(file_):
203 raise util.Abort(_("revlog '%s' not found") % file_)
204 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
205 file_[:-2] + ".i")
206 return r
172 207
173 def copy(ui, repo, pats, opts, rename=False): 208 def copy(ui, repo, pats, opts, rename=False):
174 # called with the repo lock held 209 # called with the repo lock held
175 # 210 #
176 # hgsep => pathname that uses "/" to separate directories 211 # hgsep => pathname that uses "/" to separate directories