diff -r c9226bcc288d -r f90513a3dbcd mercurial/commands.py --- a/mercurial/commands.py Sat Apr 01 11:58:50 2006 +0200 +++ b/mercurial/commands.py Sun Apr 02 08:19:41 2006 +0200 @@ -407,15 +407,20 @@ '''set template string to use''' self.t.cache['changeset'] = t - def write(self, thing): + def write(self, thing, header=False): '''write expanded template. uses in-order recursive traverse of iterators.''' for t in thing: if hasattr(t, '__iter__'): - self.write(t) + self.write(t, header=header) + elif header: + self.ui.write_header(t) else: self.ui.write(t) + def write_header(self, thing): + self.write(thing, header=True) + def show(self, rev=0, changenode=None, brinfo=None): '''show a single changeset or file revision''' log = self.repo.changelog @@ -549,6 +554,18 @@ } try: + if self.ui.debugflag and 'header_debug' in self.t: + key = 'header_debug' + elif self.ui.quiet and 'header_quiet' in self.t: + key = 'header_quiet' + elif self.ui.verbose and 'header_verbose' in self.t: + key = 'header_verbose' + elif 'header' in self.t: + key = 'header' + else: + key = '' + if key: + self.write_header(self.t(key, **props)) if self.ui.debugflag and 'changeset_debug' in self.t: key = 'changeset_debug' elif self.ui.quiet and 'changeset_quiet' in self.t: @@ -1255,11 +1272,26 @@ a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) ui.write("%d:%s\n" % (r.rev(a), hex(a))) -def debugcomplete(ui, cmd): +def debugcomplete(ui, cmd='', **opts): """returns the completion list associated with the given command""" + + if opts['options']: + options = [] + otables = [globalopts] + if cmd: + aliases, entry = find(cmd) + otables.append(entry[1]) + for t in otables: + for o in t: + if o[0]: + options.append('-%s' % o[0]) + options.append('--%s' % o[1]) + ui.write("%s\n" % "\n".join(options)) + return + clist = findpossible(cmd).keys() clist.sort() - ui.write("%s\n" % " ".join(clist)) + ui.write("%s\n" % "\n".join(clist)) def debugrebuildstate(ui, repo, rev=None): """rebuild the dirstate as it would look like for the given revision""" @@ -1897,9 +1929,11 @@ def __init__(self, ui): self.ui = ui self.hunk = {} + self.header = {} def bump(self, rev): self.rev = rev self.hunk[rev] = [] + self.header[rev] = [] def note(self, *args): if self.verbose: self.write(*args) @@ -1908,6 +1942,8 @@ self.write(*args) def write(self, *args): self.hunk[self.rev].append(args) + def write_header(self, *args): + self.header[self.rev].append(args) def debug(self, *args): if self.debugflag: self.write(*args) @@ -1964,6 +2000,9 @@ du.write("\n\n") elif st == 'iter': if count == limit: break + if du.header[rev]: + for args in du.header[rev]: + ui.write_header(*args) if du.hunk[rev]: count += 1 for args in du.hunk[rev]: @@ -2637,7 +2676,10 @@ r = "%5d:%s" % (repo.changelog.rev(n), hex(n)) except KeyError: r = " ?:?" - ui.write("%-30s %s\n" % (t, r)) + if ui.quiet: + ui.write("%s\n" % t) + else: + ui.write("%-30s %s\n" % (t, r)) def tip(ui, repo, **opts): """show the tip revision @@ -2814,7 +2856,10 @@ ('X', 'exclude', [], _('exclude names matching the given patterns'))], _('hg copy [OPTION]... [SOURCE]... DEST')), "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), - "debugcomplete": (debugcomplete, [], _('debugcomplete CMD')), + "debugcomplete": + (debugcomplete, + [('o', 'options', None, _('show the command options'))], + _('debugcomplete [-o] CMD')), "debugrebuildstate": (debugrebuildstate, [('r', 'rev', '', _('revision to rebuild to'))],