tests/test-fix.t
changeset 40533 2ecf5c24d0cd
parent 40532 93bab80993f4
child 40563 2ad56a9b983b
equal deleted inserted replaced
40532:93bab80993f4 40533:2ecf5c24d0cd
    64   > [experimental]
    64   > [experimental]
    65   > evolution.createmarkers=True
    65   > evolution.createmarkers=True
    66   > evolution.allowunstable=True
    66   > evolution.allowunstable=True
    67   > [fix]
    67   > [fix]
    68   > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY all
    68   > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY all
    69   > uppercase-whole-file:fileset=set:**.whole
    69   > uppercase-whole-file:pattern=set:**.whole
    70   > uppercase-changed-lines:command="$PYTHON" $UPPERCASEPY
    70   > uppercase-changed-lines:command="$PYTHON" $UPPERCASEPY
    71   > uppercase-changed-lines:linerange={first}-{last}
    71   > uppercase-changed-lines:linerange={first}-{last}
    72   > uppercase-changed-lines:fileset=set:**.changed
    72   > uppercase-changed-lines:pattern=set:**.changed
    73   > EOF
    73   > EOF
    74 
    74 
    75 Help text for fix.
    75 Help text for fix.
    76 
    76 
    77   $ hg help fix
    77   $ hg help fix
   124   formatting fixes to modified lines in C++ code:
   124   formatting fixes to modified lines in C++ code:
   125   
   125   
   126     [fix]
   126     [fix]
   127     clang-format:command=clang-format --assume-filename={rootpath}
   127     clang-format:command=clang-format --assume-filename={rootpath}
   128     clang-format:linerange=--lines={first}:{last}
   128     clang-format:linerange=--lines={first}:{last}
   129     clang-format:fileset=set:**.cpp or **.hpp
   129     clang-format:pattern=set:**.cpp or **.hpp
   130   
   130   
   131   The :command suboption forms the first part of the shell command that will be
   131   The :command suboption forms the first part of the shell command that will be
   132   used to fix a file. The content of the file is passed on standard input, and
   132   used to fix a file. The content of the file is passed on standard input, and
   133   the fixed file content is expected on standard output. Any output on standard
   133   the fixed file content is expected on standard output. Any output on standard
   134   error will be displayed as a warning. If the exit status is not zero, the file
   134   error will be displayed as a warning. If the exit status is not zero, the file
   145   substituted into the command:
   145   substituted into the command:
   146   
   146   
   147     {first}   The 1-based line number of the first line in the modified range
   147     {first}   The 1-based line number of the first line in the modified range
   148     {last}    The 1-based line number of the last line in the modified range
   148     {last}    The 1-based line number of the last line in the modified range
   149   
   149   
   150   The :fileset suboption determines which files will be passed through each
   150   The :pattern suboption determines which files will be passed through each
   151   configured tool. See 'hg help fileset' for possible values. If there are file
   151   configured tool. See 'hg help patterns' for possible values. If there are file
   152   arguments to 'hg fix', the intersection of these filesets is used.
   152   arguments to 'hg fix', the intersection of these patterns is used.
   153   
   153   
   154   There is also a configurable limit for the maximum size of file that will be
   154   There is also a configurable limit for the maximum size of file that will be
   155   processed by 'hg fix':
   155   processed by 'hg fix':
   156   
   156   
   157     [fix]
   157     [fix]
   369   $ hg commit -Aqm "foo"
   369   $ hg commit -Aqm "foo"
   370   $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt
   370   $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt
   371 
   371 
   372   $ hg --config "fix.fail:command=echo" \
   372   $ hg --config "fix.fail:command=echo" \
   373   >    --config "fix.fail:linerange={first}:{last}" \
   373   >    --config "fix.fail:linerange={first}:{last}" \
   374   >    --config "fix.fail:fileset=foo.txt" \
   374   >    --config "fix.fail:pattern=foo.txt" \
   375   >    fix --working-dir
   375   >    fix --working-dir
   376   $ cat foo.txt
   376   $ cat foo.txt
   377   1:1 4:6 8:8
   377   1:1 4:6 8:8
   378 
   378 
   379   $ cd ..
   379   $ cd ..
   532   > printf 'HELLO\n'
   532   > printf 'HELLO\n'
   533   > printf "$@: some\nerror that didn't stop the tool" >&2
   533   > printf "$@: some\nerror that didn't stop the tool" >&2
   534   > exit 0 # success despite the stderr output
   534   > exit 0 # success despite the stderr output
   535   > EOF
   535   > EOF
   536   $ hg --config "fix.work:command=sh $TESTTMP/work.sh {rootpath}" \
   536   $ hg --config "fix.work:command=sh $TESTTMP/work.sh {rootpath}" \
   537   >    --config "fix.work:fileset=hello.txt" \
   537   >    --config "fix.work:pattern=hello.txt" \
   538   >    fix --working-dir
   538   >    fix --working-dir
   539   [wdir] work: hello.txt: some
   539   [wdir] work: hello.txt: some
   540   [wdir] work: error that didn't stop the tool
   540   [wdir] work: error that didn't stop the tool
   541   $ cat hello.txt
   541   $ cat hello.txt
   542   HELLO
   542   HELLO
   549   > printf 'GOODBYE\n'
   549   > printf 'GOODBYE\n'
   550   > printf "$@: some\nerror that did stop the tool\n" >&2
   550   > printf "$@: some\nerror that did stop the tool\n" >&2
   551   > exit 42 # success despite the stdout output
   551   > exit 42 # success despite the stdout output
   552   > EOF
   552   > EOF
   553   $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
   553   $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
   554   >    --config "fix.fail:fileset=hello.txt" \
   554   >    --config "fix.fail:pattern=hello.txt" \
   555   >    --config "fix.failure=abort" \
   555   >    --config "fix.failure=abort" \
   556   >    fix --working-dir
   556   >    fix --working-dir
   557   [wdir] fail: hello.txt: some
   557   [wdir] fail: hello.txt: some
   558   [wdir] fail: error that did stop the tool
   558   [wdir] fail: error that did stop the tool
   559   abort: no fixes will be applied
   559   abort: no fixes will be applied
   563   goodbye
   563   goodbye
   564   $ cat foo.whole
   564   $ cat foo.whole
   565   foo
   565   foo
   566 
   566 
   567   $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
   567   $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
   568   >    --config "fix.fail:fileset=hello.txt" \
   568   >    --config "fix.fail:pattern=hello.txt" \
   569   >    fix --working-dir
   569   >    fix --working-dir
   570   [wdir] fail: hello.txt: some
   570   [wdir] fail: hello.txt: some
   571   [wdir] fail: error that did stop the tool
   571   [wdir] fail: error that did stop the tool
   572   $ cat hello.txt
   572   $ cat hello.txt
   573   goodbye
   573   goodbye
   574   $ cat foo.whole
   574   $ cat foo.whole
   575   FOO
   575   FOO
   576 
   576 
   577   $ hg --config "fix.fail:command=exit 42" \
   577   $ hg --config "fix.fail:command=exit 42" \
   578   >    --config "fix.fail:fileset=hello.txt" \
   578   >    --config "fix.fail:pattern=hello.txt" \
   579   >    fix --working-dir
   579   >    fix --working-dir
   580   [wdir] fail: exited with status 42
   580   [wdir] fail: exited with status 42
   581 
   581 
   582   $ cd ..
   582   $ cd ..
   583 
   583 
  1025   $ printf "hello\ngoodbye\n" > foo/bar
  1025   $ printf "hello\ngoodbye\n" > foo/bar
  1026   $ hg add
  1026   $ hg add
  1027   adding foo/bar
  1027   adding foo/bar
  1028   $ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
  1028   $ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
  1029   >    --config "fix.fail:linerange='{first}' '{last}'" \
  1029   >    --config "fix.fail:linerange='{first}' '{last}'" \
  1030   >    --config "fix.fail:fileset=foo/bar" \
  1030   >    --config "fix.fail:pattern=foo/bar" \
  1031   >    fix --working-dir
  1031   >    fix --working-dir
  1032   $ cat foo/bar
  1032   $ cat foo/bar
  1033   foo/bar
  1033   foo/bar
  1034   bar
  1034   bar
  1035   1
  1035   1
  1103   BAR
  1103   BAR
  1104   FOO1
  1104   FOO1
  1105   FOO2
  1105   FOO2
  1106 
  1106 
  1107   $ cd ..
  1107   $ cd ..
       
  1108 
       
  1109 The :fileset subconfig was a misnomer, so we renamed it to :pattern. We will
       
  1110 still accept :fileset by itself as if it were :pattern, but this will issue a
       
  1111 warning.
       
  1112 
       
  1113   $ hg init filesetispattern
       
  1114   $ cd filesetispattern
       
  1115 
       
  1116   $ printf "foo\n" > foo.whole
       
  1117   $ printf "first\nsecond\n" > bar.txt
       
  1118   $ hg add -q
       
  1119   $ hg fix -w --config fix.sometool:fileset=bar.txt \
       
  1120   >           --config fix.sometool:command=tac
       
  1121   the fix.tool:fileset config name is deprecated; please rename it to fix.tool:pattern
       
  1122 
       
  1123   $ cat foo.whole
       
  1124   FOO
       
  1125   $ cat bar.txt
       
  1126   second
       
  1127   first
       
  1128 
       
  1129   $ cd ..