mercurial/templates/map-cmdline.default
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 28 Mar 2020 12:18:58 -0700
changeset 44651 00e0c5c06ed5
parent 39370 46f3ff64bea7
permissions -rw-r--r--
pycompat: change argv conversion semantics Use of os.fsencode() to convert Python's sys.argv back to bytes was not correct because it isn't the logically inverse operation from what CPython was doing under the hood. This commit changes the logic for doing the str -> bytes conversion. This required a separate implementation for POSIX and Windows. The Windows behavior is arguably not ideal. The previous behavior on Windows was leading to failing tests, such as test-http-branchmap.t, which defines a utf-8 branch name via a command argument. Previously, Mercurial's argument parser looked to be receiving wchar_t bytes in some cases. After this commit, behavior on Windows is compatible with Python 2, where CPython did not implement `int wmain()` and Windows was performing a Unicode to ANSI conversion on the wchar_t native command line. Arguably better behavior on Windows would be for Mercurial to preserve the original Unicode sequence coming from Python and to wrap this in a bytes-like type so we can round trip safely. But, this would be new, backwards incompatible behavior. My goal for this commit was to converge Mercurial behavior on Python 3 on Windows to fix busted tests. And I believe I was successful, as this commit fixes 9 tests on my Windows machine and 14 tests in the AWS CI environment! Differential Revision: https://phab.mercurial-scm.org/D8337
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
     1
# Base templates. Due to name clashes with existing keywords, we have
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
     2
# to replace some keywords with 'lkeyword', for 'labelled keyword'
34714
f4aeb952ab77 templater: load template fragments from [templates] section in map file
Yuya Nishihara <yuya@tcha.org>
parents: 33783
diff changeset
     3
f4aeb952ab77 templater: load template fragments from [templates] section in map file
Yuya Nishihara <yuya@tcha.org>
parents: 33783
diff changeset
     4
[templates]
38947
f9a98075a37e templates: rename "user" to "luser" defined in default map file (API)
Yuya Nishihara <yuya@tcha.org>
parents: 34901
diff changeset
     5
changeset = '{cset}{branches}{bookmarks}{tags}{parents}{luser}{ldate}{ltroubles}{lobsfate}{summary}\n'
24304
6136704b975d templates: fix "log -q" output of default style
Yuya Nishihara <yuya@tcha.org>
parents: 22766
diff changeset
     6
changeset_quiet = '{lnode}'
38947
f9a98075a37e templates: rename "user" to "luser" defined in default map file (API)
Yuya Nishihara <yuya@tcha.org>
parents: 34901
diff changeset
     7
changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{luser}{ldate}{ltroubles}{lobsfate}{lfiles}{lfile_copies_switch}{description}\n'
f9a98075a37e templates: rename "user" to "luser" defined in default map file (API)
Yuya Nishihara <yuya@tcha.org>
parents: 34901
diff changeset
     8
changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{luser}{ldate}{ltroubles}{lobsfate}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n'
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
     9
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    10
# File templates
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    11
lfiles = '{if(files,
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    12
               label("ui.note log.files",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    13
                     "files:       {files}\n"))}'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    14
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    15
lfile_mods = '{if(file_mods,
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    16
                  label("ui.debug log.files",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    17
                        "files:       {file_mods}\n"))}'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    18
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    19
lfile_adds = '{if(file_adds,
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    20
                  label("ui.debug log.files",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    21
                        "files+:      {file_adds}\n"))}'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    22
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    23
lfile_dels = '{if(file_dels,
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    24
                  label("ui.debug log.files",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    25
                        "files-:      {file_dels}\n"))}'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    26
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    27
lfile_copies_switch = '{if(file_copies_switch,
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    28
                           label("ui.note log.copies",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    29
                                 "copies:     {file_copies_switch
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    30
                                               % ' {name} ({source})'}\n"))}'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    31
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    32
# General templates
34716
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    33
cset = '{labelcset("changeset:   {rev}:{node|short}")}\n'
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    34
fullcset = '{labelcset("changeset:   {rev}:{node}")}\n'
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    35
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    36
lphase = '{label("log.phase",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    37
                 "phase:       {phase}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    38
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    39
parent = '{label("log.parent changeset.{phase}",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    40
                  "parent:      {rev}:{node|formatnode}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    41
24304
6136704b975d templates: fix "log -q" output of default style
Yuya Nishihara <yuya@tcha.org>
parents: 22766
diff changeset
    42
lnode = '{label("log.node",
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    43
                "{rev}:{node|short}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    44
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    45
manifest = '{label("ui.debug log.manifest",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    46
                   "manifest:    {rev}:{node}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    47
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    48
branch = '{label("log.branch",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    49
                 "branch:      {branch}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    50
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    51
tag = '{label("log.tag",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    52
              "tag:         {tag}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    53
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    54
bookmark = '{label("log.bookmark",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    55
                   "bookmark:    {bookmark}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    56
38947
f9a98075a37e templates: rename "user" to "luser" defined in default map file (API)
Yuya Nishihara <yuya@tcha.org>
parents: 34901
diff changeset
    57
luser = '{label("log.user",
f9a98075a37e templates: rename "user" to "luser" defined in default map file (API)
Yuya Nishihara <yuya@tcha.org>
parents: 34901
diff changeset
    58
                "user:        {author}")}\n'
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    59
24637
c1cb6523e968 templates-default: do not show description or summary if empty
Yuya Nishihara <yuya@tcha.org>
parents: 24304
diff changeset
    60
summary = '{if(desc|strip, "{label('log.summary',
c1cb6523e968 templates-default: do not show description or summary if empty
Yuya Nishihara <yuya@tcha.org>
parents: 24304
diff changeset
    61
                                   'summary:     {desc|firstline}')}\n")}'
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    62
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    63
ldate = '{label("log.date",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    64
                "date:        {date|date}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    65
33783
db6b666ce1e6 label: rename log.trouble into log.instability
Boris Feld <boris.feld@octobus.net>
parents: 33782
diff changeset
    66
ltroubles = '{if(instabilities, "{label('log.instability',
33709
511d6ae462f3 template: rename troubles templatekw into instabilities
Boris Feld <boris.feld@octobus.net>
parents: 31702
diff changeset
    67
                                   'instability: {join(instabilities, ", ")}')}\n")}'
30713
6d0b1a69f98c templates: display evolution "troubles" in command line style
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 30696
diff changeset
    68
22766
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    69
extra = '{label("ui.debug log.extra",
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    70
                "extra:       {key}={value|stringescape}")}\n'
0ded0f0b1c04 log: rewrite default template to use labels (issue2866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15907
diff changeset
    71
24637
c1cb6523e968 templates-default: do not show description or summary if empty
Yuya Nishihara <yuya@tcha.org>
parents: 24304
diff changeset
    72
description = '{if(desc|strip, "{label('ui.note log.description',
c1cb6523e968 templates-default: do not show description or summary if empty
Yuya Nishihara <yuya@tcha.org>
parents: 24304
diff changeset
    73
                                       'description:')}
c1cb6523e968 templates-default: do not show description or summary if empty
Yuya Nishihara <yuya@tcha.org>
parents: 24304
diff changeset
    74
                                {label('ui.note log.description',
c1cb6523e968 templates-default: do not show description or summary if empty
Yuya Nishihara <yuya@tcha.org>
parents: 24304
diff changeset
    75
                                       '{desc|strip}')}\n\n")}'
25514
9b1a8ce1f03b templates: add a default template style for status
Matt Mackall <mpm@selenic.com>
parents: 24637
diff changeset
    76
39370
46f3ff64bea7 status: rename {copy} to {source} for compatibility with {file_copies} (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 39369
diff changeset
    77
status = '{status} {path|relpath}\n{if(source, "  {source|relpath}\n")}'
34716
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    78
34853
962f7df21a73 obsfate: add obsfate to default mapfile
Boris Feld <boris.feld@octobus.net>
parents: 34717
diff changeset
    79
# Obsfate templates, it would be removed once we introduce the obsfate
962f7df21a73 obsfate: add obsfate to default mapfile
Boris Feld <boris.feld@octobus.net>
parents: 34717
diff changeset
    80
# template fragment
34901
ec765a71bd65 obsfate: rename obsfate into obsolete in default mapfile
Boris Feld <boris.feld@octobus.net>
parents: 34853
diff changeset
    81
lobsfate = '{if(obsfate, "{label('log.obsfate', '{obsfate % "obsolete:    {fate}\n"}')}")}'
34853
962f7df21a73 obsfate: add obsfate to default mapfile
Boris Feld <boris.feld@octobus.net>
parents: 34717
diff changeset
    82
34716
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    83
[templatealias]
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    84
labelcset(expr) = label(separate(" ",
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    85
                                 "log.changeset",
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    86
                                 "changeset.{phase}",
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    87
                                 if(obsolete, "changeset.obsolete"),
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    88
                                 if(instabilities, "changeset.unstable"),
34717
06b52671552b templates: fix missed space between instability labels
Yuya Nishihara <yuya@tcha.org>
parents: 34716
diff changeset
    89
                                 join(instabilities
06b52671552b templates: fix missed space between instability labels
Yuya Nishihara <yuya@tcha.org>
parents: 34716
diff changeset
    90
                                      % "instability.{instability}", " ")),
34716
d36a36ca7bc2 templates: introduce labelcset() function in map-cmdline.default as example
Yuya Nishihara <yuya@tcha.org>
parents: 34714
diff changeset
    91
                        expr)