mercurial/templates/map-cmdline.show
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 38450 b45c353ebbc7
permissions -rw-r--r--
procutil: make stream detection in make_line_buffered more correct and strict In make_line_buffered(), we don’t want to wrap the stream if we know that lines get flushed to the underlying raw stream already. Previously, the heuristic was too optimistic. It assumed that any stream which is not an instance of io.BufferedIOBase doesn’t need wrapping. However, there are buffered streams that aren’t instances of io.BufferedIOBase, like Mercurial’s own winstdout. The new logic is different in two ways: First, only for the check, if unwraps any combination of WriteAllWrapper and winstdout. Second, it skips wrapping the stream only if it is an instance of io.RawIOBase (or already wrapped). If it is an instance of io.BufferedIOBase, it gets wrapped. In any other case, the function raises an exception. This ensures that, if an unknown stream is passed or we add another wrapper in the future, we don’t wrap the stream if it’s already line buffered or not wrap the stream if it’s not line buffered. In fact, this was already helpful during development of this change. Without it, I possibly would have forgot that WriteAllWrapper needs to be ignored for the check, leading to unnecessary wrapping if stdout is unbuffered. The alternative would have been to always wrap unknown streams. However, I don’t think that anyone would benefit from being less strict. We can expect streams from the standard library to be subclassing either io.RawIOBase or io.BufferedIOBase, so running Mercurial in the standard way should not regress by this change. Py2exe might replace sys.stdout and sys.stderr, but that currently breaks Mercurial anyway and also these streams don’t claim to be interactive, so this function is not called for them.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32059
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     1
# TODO there are a few deficiencies in this file:
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     2
# * The "namespace" of the labels needs to be worked out. We currently
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     3
#   piggyback on existing values so color works.
34877
eb24f1d1b50b show: use labelcset() template alias for work (and stack) views
Denis Laxalde <denis@laxalde.org>
parents: 34714
diff changeset
     4
eb24f1d1b50b show: use labelcset() template alias for work (and stack) views
Denis Laxalde <denis@laxalde.org>
parents: 34714
diff changeset
     5
%include map-cmdline.default
34714
f4aeb952ab77 templater: load template fragments from [templates] section in map file
Yuya Nishihara <yuya@tcha.org>
parents: 34190
diff changeset
     6
f4aeb952ab77 templater: load template fragments from [templates] section in map file
Yuya Nishihara <yuya@tcha.org>
parents: 34190
diff changeset
     7
[templates]
34190
4441c1113eb2 show: pass the minimum length for nodes as a template keyword
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33197
diff changeset
     8
showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, nodelen)}\n'
33046
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
     9
33050
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    10
showwork = '{cset_shortnode}{namespaces % cset_namespace} {cset_shortdesc}'
33197
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33050
diff changeset
    11
showstack = '{showwork}'
33046
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
    12
34877
eb24f1d1b50b show: use labelcset() template alias for work (and stack) views
Denis Laxalde <denis@laxalde.org>
parents: 34714
diff changeset
    13
cset_shortnode = '{labelcset(shortest(node, nodelen))}'
33050
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    14
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    15
# Treat branch and tags specially so we don't display "default" or "tip"
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    16
cset_namespace = '{ifeq(namespace, "branches", names_branches, ifeq(namespace, "tags", names_tags, names_others))}'
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    17
names_branches = '{ifeq(branch, "default", "", " ({label('log.{colorname}', branch)})")}'
38450
b45c353ebbc7 show: use filter() function to strip "tip" tag
Yuya Nishihara <yuya@tcha.org>
parents: 38288
diff changeset
    18
names_tags = '{if(filter_tags(names),
b45c353ebbc7 show: use filter() function to strip "tip" tag
Yuya Nishihara <yuya@tcha.org>
parents: 38288
diff changeset
    19
                  " ({label('log.{colorname}', join(filter_tags(names), ' '))})")}'
33050
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    20
names_others = '{if(names, " ({label('log.{colorname}', join(names, ' '))})")}'
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    21
33046
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
    22
cset_shortdesc = '{label("log.description", desc|firstline)}'
38450
b45c353ebbc7 show: use filter() function to strip "tip" tag
Yuya Nishihara <yuya@tcha.org>
parents: 38288
diff changeset
    23
b45c353ebbc7 show: use filter() function to strip "tip" tag
Yuya Nishihara <yuya@tcha.org>
parents: 38288
diff changeset
    24
[templatealias]
b45c353ebbc7 show: use filter() function to strip "tip" tag
Yuya Nishihara <yuya@tcha.org>
parents: 38288
diff changeset
    25
filter_tags(names) = filter(names, ifeq(name, 'tip', '', name))