hgext/fix.py
branchstable
changeset 50439 f4ff55583dec
parent 50090 a3c856e2ea2f
equal deleted inserted replaced
50438:4ca794f4e6a3 50439:f4ff55583dec
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 """rewrite file content in changesets or working copy (EXPERIMENTAL)
     7 """rewrite file content in changesets or working copy (EXPERIMENTAL)
     8 
     8 
     9 Provides a command that runs configured tools on the contents of modified files,
     9 Provides a command that runs configured tools on the contents of modified files,
    10 writing back any fixes to the working copy or replacing changesets.
    10 writing back any fixes to the working copy or replacing changesets.
       
    11 
       
    12 Fixer tools are run in the repository's root directory. This allows them to read
       
    13 configuration files from the working copy, or even write to the working copy.
       
    14 The working copy is not updated to match the revision being fixed. In fact,
       
    15 several revisions may be fixed in parallel. Writes to the working copy are not
       
    16 amended into the revision being fixed; fixer tools MUST always read content to
       
    17 be fixed from stdin, and write fixed file content back to stdout.
    11 
    18 
    12 Here is an example configuration that causes :hg:`fix` to apply automatic
    19 Here is an example configuration that causes :hg:`fix` to apply automatic
    13 formatting fixes to modified lines in C++ code::
    20 formatting fixes to modified lines in C++ code::
    14 
    21 
    15   [fix]
    22   [fix]
   111     made obsolete. Provides a boolean "$HG_WDIRWRITTEN" to indicate whether any
   118     made obsolete. Provides a boolean "$HG_WDIRWRITTEN" to indicate whether any
   112     files in the working copy were updated. Provides a list "$HG_METADATA"
   119     files in the working copy were updated. Provides a list "$HG_METADATA"
   113     mapping fixer tool names to lists of metadata values returned from
   120     mapping fixer tool names to lists of metadata values returned from
   114     executions that modified a file. This aggregates the same metadata
   121     executions that modified a file. This aggregates the same metadata
   115     previously passed to the "postfixfile" hook.
   122     previously passed to the "postfixfile" hook.
   116 
       
   117 Fixer tools are run in the repository's root directory. This allows them to read
       
   118 configuration files from the working copy, or even write to the working copy.
       
   119 The working copy is not updated to match the revision being fixed. In fact,
       
   120 several revisions may be fixed in parallel. Writes to the working copy are not
       
   121 amended into the revision being fixed; fixer tools should always write fixed
       
   122 file content back to stdout as documented above.
       
   123 """
   123 """
   124 
   124 
   125 
   125 
   126 import collections
   126 import collections
   127 import itertools
   127 import itertools
   237     helpcategory=command.CATEGORY_FILE_CONTENTS,
   237     helpcategory=command.CATEGORY_FILE_CONTENTS,
   238 )
   238 )
   239 def fix(ui, repo, *pats, **opts):
   239 def fix(ui, repo, *pats, **opts):
   240     """rewrite file content in changesets or working directory
   240     """rewrite file content in changesets or working directory
   241 
   241 
   242     Runs any configured tools to fix the content of files. Only affects files
   242     Runs any configured tools to fix the content of files. (See
       
   243     :hg:`help -e fix` for details about configuring tools.) Only affects files
   243     with changes, unless file arguments are provided. Only affects changed lines
   244     with changes, unless file arguments are provided. Only affects changed lines
   244     of files, unless the --whole flag is used. Some tools may always affect the
   245     of files, unless the --whole flag is used. Some tools may always affect the
   245     whole file regardless of --whole.
   246     whole file regardless of --whole.
   246 
   247 
   247     If --working-dir is used, files with uncommitted changes in the working copy
   248     If --working-dir is used, files with uncommitted changes in the working copy