From db17ec404e6a1bd4baf66bd88eb48d3d5434c06b Mon Sep 17 00:00:00 2001 From: Thomas Arendsen Hein Date: Sat, 1 Apr 2006 19:11:59 +0200 Subject: [PATCH 1/5] Web site and wiki are now the same. --- README | 1 - doc/hg.1.txt | 2 -- 2 files changed, 3 deletions(-) diff --git a/README b/README index 97a82098da..a8524d7394 100644 --- a/README +++ b/README @@ -97,4 +97,3 @@ For more info: Documentation in doc/ Mercurial website at http://selenic.com/mercurial - Mercurial wiki at http://selenic.com/mercurial/wiki diff --git a/doc/hg.1.txt b/doc/hg.1.txt index 7675e692a9..788f4795b9 100644 --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -210,8 +210,6 @@ RESOURCES --------- http://selenic.com/mercurial[Main Web Site] -http://www.serpentine.com/mercurial[Wiki site] - http://selenic.com/hg[Source code repository] http://selenic.com/mailman/listinfo/mercurial[Mailing list] From f72c380299b973a81c83fd8f3276cc68e4f6cd6e Mon Sep 17 00:00:00 2001 From: Thomas Arendsen Hein Date: Sat, 1 Apr 2006 20:56:55 +0200 Subject: [PATCH 2/5] Don't print filenames in braces for changelog style. --- templates/map-cmdline.changelog | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/templates/map-cmdline.changelog b/templates/map-cmdline.changelog index 4b9110bedb..1019b51b51 100644 --- a/templates/map-cmdline.changelog +++ b/templates/map-cmdline.changelog @@ -4,12 +4,9 @@ changeset_verbose = '{date|isodate} {author|person} <{author|email}> ({node|s start_tags = ' [' tag = '{tag}, ' last_tag = '{tag}]' -start_files = '(' file = '{file}, ' -last_file = '{file}):\n\t' -start_file_adds = '(' +last_file = '{file}:\n\t' file_add = '{file_add}, ' -last_file_add = '{file_add}): new file.\n* ' -start_file_dels = '(' +last_file_add = '{file_add}: new file.\n* ' file_del = '{file_del}, ' -last_file_del = '{file_del}): deleted file.\n* ' +last_file_del = '{file_del}: deleted file.\n* ' From ee03ece42849cd74b20d825f1ab210c4186f8406 Mon Sep 17 00:00:00 2001 From: Thomas Arendsen Hein Date: Sat, 1 Apr 2006 21:37:08 +0200 Subject: [PATCH 3/5] Group changes done by the same developer on the same with --style=changelog Changeset and tags are appended to the change message for non-quiet and non-verbose output, so grouping works. Fixes last bit of issue110. --- mercurial/commands.py | 28 ++++++++++++++++++++++++++-- mercurial/ui.py | 11 +++++++++++ templates/map-cmdline.changelog | 6 ++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/mercurial/commands.py b/mercurial/commands.py index 459f9152de..7d66de52c5 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -407,15 +407,20 @@ class changeset_templater(object): '''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 @@ class changeset_templater(object): } 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: @@ -1897,9 +1914,11 @@ def log(ui, repo, *pats, **opts): 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 +1927,8 @@ def log(ui, repo, *pats, **opts): 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 +1985,9 @@ def log(ui, repo, *pats, **opts): 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]: diff --git a/mercurial/ui.py b/mercurial/ui.py index 5263888b78..fbfe30c066 100644 --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -27,6 +27,8 @@ class ui(object): self.updateopts(verbose, debug, quiet, interactive) self.diffcache = None + self.header = [] + self.prev_header = [] else: # parentui may point to an ui object which is already a child self.parentui = parentui.parentui or parentui @@ -184,9 +186,18 @@ class ui(object): return self.config("paths", loc, loc) def write(self, *args): + if self.header: + if self.header != self.prev_header: + self.prev_header = self.header + self.write(*self.header) + self.header = [] for a in args: sys.stdout.write(str(a)) + def write_header(self, *args): + for a in args: + self.header.append(str(a)) + def write_err(self, *args): try: if not sys.stdout.closed: sys.stdout.flush() diff --git a/templates/map-cmdline.changelog b/templates/map-cmdline.changelog index 1019b51b51..8ae39b59b1 100644 --- a/templates/map-cmdline.changelog +++ b/templates/map-cmdline.changelog @@ -1,5 +1,7 @@ -changeset = '{date|shortdate} {author|person} <{author|email}> ({node|short}{tags})\n\n\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\n' -changeset_quiet = '{date|shortdate} {author|person} <{author|email}>\n\n\t* {desc|firstline|fill68|tabindent|strip}\n\n' +header = '{date|shortdate} {author|person} <{author|email}>\n\n' +header_verbose = '' +changeset = '\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\t[{node|short}]{tags}\n\n' +changeset_quiet = '\t* {desc|firstline|fill68|tabindent|strip}\n\n' changeset_verbose = '{date|isodate} {author|person} <{author|email}> ({node|short}{tags})\n\n\t* {file_adds|stringify|fill68|tabindent}{file_dels|stringify|fill68|tabindent}{files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\n' start_tags = ' [' tag = '{tag}, ' From b5be2f0b92c23af3ff6f15c7fa7f237e01ec8eba Mon Sep 17 00:00:00 2001 From: "Alexis S. L. Carvalho" Date: Sat, 1 Apr 2006 22:50:12 +0200 Subject: [PATCH 4/5] add --options to debugcomplete and change bash_completion to use it make debugcomplete print one item per line (this is not needed for the bash_completion script, but should be easier to use in other scripts) --- contrib/bash_completion | 15 +-------------- mercurial/commands.py | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/contrib/bash_completion b/contrib/bash_completion index e20cc22e69..e466716d21 100644 --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -1,18 +1,5 @@ shopt -s extglob -_hg_option_list() -{ - "$hg" -v help $1 2>/dev/null | \ - awk '/^ *-/ { - for (i = 1; i <= NF; i ++) { - if (index($i, "-") != 1) - break; - print $i; - } - }' -} - - _hg_commands() { local commands @@ -89,7 +76,7 @@ _hg() done if [[ "$cur" == -* ]]; then - opts=$(_hg_option_list $cmd) + opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null) COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) return diff --git a/mercurial/commands.py b/mercurial/commands.py index 7d66de52c5..88fa9dcfbd 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1272,11 +1272,26 @@ def debugancestor(ui, index, rev1, rev2): 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""" @@ -2853,7 +2868,10 @@ table = { ('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'))], From 7bd3e367e74205a2466f6c7f4178cbfda3df0300 Mon Sep 17 00:00:00 2001 From: Thomas Arendsen Hein Date: Sat, 1 Apr 2006 23:57:24 +0200 Subject: [PATCH 5/5] Make 'hg tags -q' only list tag names without revision numbers and hashes, and change bash_completion to use this. --- contrib/bash_completion | 4 ++-- mercurial/commands.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/bash_completion b/contrib/bash_completion index e466716d21..1dc058069a 100644 --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -29,8 +29,8 @@ _hg_status() _hg_tags() { - local tags="$("$hg" tags 2>/dev/null | - sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" + local tags="$("$hg" tags -q 2>/dev/null)" + local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) } diff --git a/mercurial/commands.py b/mercurial/commands.py index 88fa9dcfbd..7cba9b2b61 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2691,7 +2691,10 @@ def tags(ui, repo): 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