tests/test-fix.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Fri, 03 Feb 2023 12:54:17 +0100
branchstable
changeset 49977 b5ecd0bcbcd7
parent 48672 657e490756e6
child 50359 f4ff55583dec
permissions -rw-r--r--
fix: add more information to the debug output The previous debug output did not help to understand which file where fixed in which revision. The new output should cover that.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     1
A script that implements uppercasing of specific lines in a file. This
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     2
approximates the behavior of code formatters well enough for our tests.
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     3
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     4
  $ UPPERCASEPY="$TESTTMP/uppercase.py"
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     5
  $ cat > $UPPERCASEPY <<EOF
47765
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
     6
  > import re
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     7
  > import sys
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     8
  > from mercurial.utils.procutil import setbinary
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
     9
  > setbinary(sys.stdin)
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    10
  > setbinary(sys.stdout)
47067
ea563187ee7c tests: change the fixer commands to use the buffer attribute on stdio objects
Matt Harbison <matt_harbison@yahoo.com>
parents: 46838
diff changeset
    11
  > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
ea563187ee7c tests: change the fixer commands to use the buffer attribute on stdio objects
Matt Harbison <matt_harbison@yahoo.com>
parents: 46838
diff changeset
    12
  > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    13
  > lines = set()
47765
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
    14
  > def format(text):
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
    15
  >   return re.sub(b' +', b' ', text.upper())
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    16
  > for arg in sys.argv[1:]:
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    17
  >   if arg == 'all':
47765
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
    18
  >     stdout.write(format(stdin.read()))
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    19
  >     sys.exit(0)
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    20
  >   else:
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    21
  >     first, last = arg.split('-')
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    22
  >     lines.update(range(int(first), int(last) + 1))
47067
ea563187ee7c tests: change the fixer commands to use the buffer attribute on stdio objects
Matt Harbison <matt_harbison@yahoo.com>
parents: 46838
diff changeset
    23
  > for i, line in enumerate(stdin.readlines()):
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    24
  >   if i + 1 in lines:
47765
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
    25
  >     stdout.write(format(line))
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    26
  >   else:
47067
ea563187ee7c tests: change the fixer commands to use the buffer attribute on stdio objects
Matt Harbison <matt_harbison@yahoo.com>
parents: 46838
diff changeset
    27
  >     stdout.write(line)
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    28
  > EOF
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    29
  $ TESTLINES="foo\nbar\nbaz\nqux\n"
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    30
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    31
  foo
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    32
  bar
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    33
  baz
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    34
  qux
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    35
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY all
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    36
  FOO
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    37
  BAR
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    38
  BAZ
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    39
  QUX
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    40
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 1-1
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    41
  FOO
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    42
  bar
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    43
  baz
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    44
  qux
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    45
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 1-2
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    46
  FOO
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    47
  BAR
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    48
  baz
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    49
  qux
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    50
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 2-3
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    51
  foo
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    52
  BAR
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    53
  BAZ
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    54
  qux
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    55
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 2-2 4-4
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    56
  foo
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    57
  BAR
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    58
  baz
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    59
  QUX
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    60
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    61
Set up the config with two simple fixers: one that fixes specific line ranges,
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    62
and one that always fixes the whole file. They both "fix" files by converting
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    63
letters to uppercase. They use different file extensions, so each test case can
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    64
choose which behavior to use by naming files.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    65
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    66
  $ cat >> $HGRCPATH <<EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    67
  > [extensions]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    68
  > fix =
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    69
  > [experimental]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    70
  > evolution.createmarkers=True
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    71
  > evolution.allowunstable=True
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    72
  > [fix]
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    73
  > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY all
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
    74
  > uppercase-whole-file:pattern=set:**.whole
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39111
diff changeset
    75
  > uppercase-changed-lines:command="$PYTHON" $UPPERCASEPY
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
    76
  > uppercase-changed-lines:linerange={first}-{last}
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
    77
  > uppercase-changed-lines:pattern=set:**.changed
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    78
  > EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    79
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    80
Help text for fix.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    81
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    82
  $ hg help fix
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    83
  hg fix [OPTION]... [FILE]...
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    84
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    85
  rewrite file content in changesets or working directory
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    86
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    87
      Runs any configured tools to fix the content of files. Only affects files
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    88
      with changes, unless file arguments are provided. Only affects changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    89
      lines of files, unless the --whole flag is used. Some tools may always
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    90
      affect the whole file regardless of --whole.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    91
  
45218
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    92
      If --working-dir is used, files with uncommitted changes in the working
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    93
      copy will be fixed. Note that no backup are made.
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
    94
  
45218
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    95
      If revisions are specified with --source, those revisions and their
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    96
      descendants will be checked, and they may be replaced with new revisions
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    97
      that have fixed file content. By automatically including the descendants,
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    98
      no merging, rebasing, or evolution will be required. If an ancestor of the
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
    99
      working copy is included, then the working copy itself will also be fixed,
3ea3b85df03f fix: update documentation to reflect preference for --source over --rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 45215
diff changeset
   100
      and the working copy will be updated to the fixed parent.
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   101
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   102
      When determining what lines of each file to fix at each revision, the
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   103
      whole set of revisions being fixed is considered, so that fixes to earlier
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   104
      revisions are not forgotten in later ones. The --base flag can be used to
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   105
      override this default behavior, though it is not usually desirable to do
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   106
      so.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   107
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   108
  (use 'hg help -e fix' to show help for the fix extension)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   109
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   110
  options ([+] can be repeated):
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   111
  
44574
5205b46bd887 fix: add a -s option to format a revision and its descendants
Martin von Zweigbergk <martinvonz@google.com>
parents: 44129
diff changeset
   112
      --all            fix all non-public non-obsolete revisions
5205b46bd887 fix: add a -s option to format a revision and its descendants
Martin von Zweigbergk <martinvonz@google.com>
parents: 44129
diff changeset
   113
      --base REV [+]   revisions to diff against (overrides automatic selection,
5205b46bd887 fix: add a -s option to format a revision and its descendants
Martin von Zweigbergk <martinvonz@google.com>
parents: 44129
diff changeset
   114
                       and applies to every revision being fixed)
5205b46bd887 fix: add a -s option to format a revision and its descendants
Martin von Zweigbergk <martinvonz@google.com>
parents: 44129
diff changeset
   115
   -s --source REV [+] fix the specified revisions and their descendants
5205b46bd887 fix: add a -s option to format a revision and its descendants
Martin von Zweigbergk <martinvonz@google.com>
parents: 44129
diff changeset
   116
   -w --working-dir    fix the working directory
5205b46bd887 fix: add a -s option to format a revision and its descendants
Martin von Zweigbergk <martinvonz@google.com>
parents: 44129
diff changeset
   117
      --whole          always fix every line of a file
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   118
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   119
  (some details hidden, use --verbose to show complete help)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   120
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   121
  $ hg help -e fix
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   122
  fix extension - rewrite file content in changesets or working copy
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   123
  (EXPERIMENTAL)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   124
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   125
  Provides a command that runs configured tools on the contents of modified
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   126
  files, writing back any fixes to the working copy or replacing changesets.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   127
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   128
  Here is an example configuration that causes 'hg fix' to apply automatic
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   129
  formatting fixes to modified lines in C++ code:
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   130
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   131
    [fix]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   132
    clang-format:command=clang-format --assume-filename={rootpath}
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   133
    clang-format:linerange=--lines={first}:{last}
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   134
    clang-format:pattern=set:**.cpp or **.hpp
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   135
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   136
  The :command suboption forms the first part of the shell command that will be
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   137
  used to fix a file. The content of the file is passed on standard input, and
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   138
  the fixed file content is expected on standard output. Any output on standard
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   139
  error will be displayed as a warning. If the exit status is not zero, the file
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   140
  will not be affected. A placeholder warning is displayed if there is a non-
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   141
  zero exit status but no standard error output. Some values may be substituted
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   142
  into the command:
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   143
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   144
    {rootpath}  The path of the file being fixed, relative to the repo root
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   145
    {basename}  The name of the file being fixed, without the directory path
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   146
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   147
  If the :linerange suboption is set, the tool will only be run if there are
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   148
  changed lines in a file. The value of this suboption is appended to the shell
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   149
  command once for every range of changed lines in the file. Some values may be
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   150
  substituted into the command:
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   151
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   152
    {first}   The 1-based line number of the first line in the modified range
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   153
    {last}    The 1-based line number of the last line in the modified range
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   154
  
42756
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   155
  Deleted sections of a file will be ignored by :linerange, because there is no
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   156
  corresponding line range in the version being fixed.
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   157
  
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   158
  By default, tools that set :linerange will only be executed if there is at
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   159
  least one changed line range. This is meant to prevent accidents like running
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   160
  a code formatter in such a way that it unexpectedly reformats the whole file.
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   161
  If such a tool needs to operate on unchanged files, it should set the
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   162
  :skipclean suboption to false.
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
   163
  
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   164
  The :pattern suboption determines which files will be passed through each
43227
f02d3c0eed18 fix: match patterns relative to root
Martin von Zweigbergk <martinvonz@google.com>
parents: 43226
diff changeset
   165
  configured tool. See 'hg help patterns' for possible values. However, all
f02d3c0eed18 fix: match patterns relative to root
Martin von Zweigbergk <martinvonz@google.com>
parents: 43226
diff changeset
   166
  patterns are relative to the repo root, even if that text says they are
f02d3c0eed18 fix: match patterns relative to root
Martin von Zweigbergk <martinvonz@google.com>
parents: 43226
diff changeset
   167
  relative to the current working directory. If there are file arguments to 'hg
f02d3c0eed18 fix: match patterns relative to root
Martin von Zweigbergk <martinvonz@google.com>
parents: 43226
diff changeset
   168
  fix', the intersection of these patterns is used.
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   169
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   170
  There is also a configurable limit for the maximum size of file that will be
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   171
  processed by 'hg fix':
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   172
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   173
    [fix]
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   174
    maxfilesize = 2MB
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   175
  
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   176
  Normally, execution of configured tools will continue after a failure
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   177
  (indicated by a non-zero exit status). It can also be configured to abort
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   178
  after the first such failure, so that no files will be affected if any tool
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   179
  fails. This abort will also cause 'hg fix' to exit with a non-zero status:
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   180
  
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   181
    [fix]
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   182
    failure = abort
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   183
  
40566
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   184
  When multiple tools are configured to affect a file, they execute in an order
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   185
  defined by the :priority suboption. The priority suboption has a default value
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   186
  of zero for each tool. Tools are executed in order of descending priority. The
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   187
  execution order of tools with equal priority is unspecified. For example, you
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   188
  could use the 'sort' and 'head' utilities to keep only the 10 smallest numbers
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   189
  in a text file by ensuring that 'sort' runs before 'head':
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   190
  
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   191
    [fix]
41126
d8f5c615e811 tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents: 41010
diff changeset
   192
    sort:command = sort -n
d8f5c615e811 tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents: 41010
diff changeset
   193
    head:command = head -n 10
40566
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   194
    sort:pattern = numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   195
    head:pattern = numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   196
    sort:priority = 2
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   197
    head:priority = 1
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   198
  
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   199
  To account for changes made by each tool, the line numbers used for
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   200
  incremental formatting are recomputed before executing the next tool. So, each
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   201
  tool may see different values for the arguments added by the :linerange
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   202
  suboption.
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
   203
  
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   204
  Each fixer tool is allowed to return some metadata in addition to the fixed
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   205
  file content. The metadata must be placed before the file content on stdout,
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   206
  separated from the file content by a zero byte. The metadata is parsed as a
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   207
  JSON value (so, it should be UTF-8 encoded and contain no zero bytes). A fixer
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   208
  tool is expected to produce this metadata encoding if and only if the
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   209
  :metadata suboption is true:
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   210
  
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   211
    [fix]
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   212
    tool:command = tool --prepend-json-metadata
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   213
    tool:metadata = true
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   214
  
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   215
  The metadata values are passed to hooks, which can be used to print summaries
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   216
  or perform other post-fixing work. The supported hooks are:
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   217
  
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   218
    "postfixfile"
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   219
      Run once for each file in each revision where any fixer tools made changes
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   220
      to the file content. Provides "$HG_REV" and "$HG_PATH" to identify the file,
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   221
      and "$HG_METADATA" with a map of fixer names to metadata values from fixer
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   222
      tools that affected the file. Fixer tools that didn't affect the file have a
44048
61881b170140 fix: fix grammar/typos in hg help -e fix
timeless <timeless@mozdev.org>
parents: 43227
diff changeset
   223
      value of None. Only fixer tools that executed are present in the metadata.
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   224
  
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   225
    "postfix"
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   226
      Run once after all files and revisions have been handled. Provides
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   227
      "$HG_REPLACEMENTS" with information about what revisions were created and
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   228
      made obsolete. Provides a boolean "$HG_WDIRWRITTEN" to indicate whether any
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   229
      files in the working copy were updated. Provides a list "$HG_METADATA"
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   230
      mapping fixer tool names to lists of metadata values returned from
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   231
      executions that modified a file. This aggregates the same metadata
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   232
      previously passed to the "postfixfile" hook.
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents: 42008
diff changeset
   233
  
44048
61881b170140 fix: fix grammar/typos in hg help -e fix
timeless <timeless@mozdev.org>
parents: 43227
diff changeset
   234
  Fixer tools are run in the repository's root directory. This allows them to
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
   235
  read configuration files from the working copy, or even write to the working
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
   236
  copy. The working copy is not updated to match the revision being fixed. In
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
   237
  fact, several revisions may be fixed in parallel. Writes to the working copy
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
   238
  are not amended into the revision being fixed; fixer tools should always write
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
   239
  fixed file content back to stdout as documented above.
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
   240
  
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   241
  list of commands:
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   242
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   243
   fix           rewrite file content in changesets or working directory
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   244
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   245
  (use 'hg help -v -e fix' to show built-in aliases and global options)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   246
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   247
There is no default behavior in the absence of --rev and --working-dir.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   248
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   249
  $ hg init badusage
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   250
  $ cd badusage
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   251
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   252
  $ hg fix
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   253
  abort: no changesets specified
45807
f90943d753ef fix: suggest --source instead of --rev on empty revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 45771
diff changeset
   254
  (use --source or --working-dir)
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   255
  [255]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   256
  $ hg fix --whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   257
  abort: no changesets specified
45807
f90943d753ef fix: suggest --source instead of --rev on empty revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 45771
diff changeset
   258
  (use --source or --working-dir)
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   259
  [255]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   260
  $ hg fix --base 0
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   261
  abort: no changesets specified
45807
f90943d753ef fix: suggest --source instead of --rev on empty revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 45771
diff changeset
   262
  (use --source or --working-dir)
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   263
  [255]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   264
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   265
Fixing a public revision isn't allowed. It should abort early enough that
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   266
nothing happens, even to the working directory.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   267
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   268
  $ printf "hello\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   269
  $ hg commit -Aqm "hello"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   270
  $ hg phase -r 0 --public
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   271
  $ hg fix -r 0
47069
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47018
diff changeset
   272
  abort: cannot fix public changesets: 6470986d2e7b
43936
699d6be3820a fix: use rewriteutil.precheck() instead of reimplementing it
Martin von Zweigbergk <martinvonz@google.com>
parents: 43227
diff changeset
   273
  (see 'hg help phases' for details)
45853
b4694ef45db5 errors: raise more specific errors from rewriteutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 45840
diff changeset
   274
  [10]
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   275
  $ hg fix -r 0 --working-dir
47069
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47018
diff changeset
   276
  abort: cannot fix public changesets: 6470986d2e7b
43936
699d6be3820a fix: use rewriteutil.precheck() instead of reimplementing it
Martin von Zweigbergk <martinvonz@google.com>
parents: 43227
diff changeset
   277
  (see 'hg help phases' for details)
45853
b4694ef45db5 errors: raise more specific errors from rewriteutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 45840
diff changeset
   278
  [10]
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   279
  $ hg cat -r tip hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   280
  hello
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   281
  $ cat hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   282
  hello
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   283
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   284
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   285
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   286
Fixing a clean working directory should do nothing. Even the --whole flag
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   287
shouldn't cause any clean files to be fixed. Specifying a clean file explicitly
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   288
should only fix it if the fixer always fixes the whole file. The combination of
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   289
an explicit filename and --whole should format the entire file regardless.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   290
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   291
  $ hg init fixcleanwdir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   292
  $ cd fixcleanwdir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   293
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   294
  $ printf "hello\n" > hello.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   295
  $ printf "world\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   296
  $ hg commit -Aqm "foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   297
  $ hg fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   298
  $ hg diff
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   299
  $ hg fix --working-dir --whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   300
  $ hg diff
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   301
  $ hg fix --working-dir *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   302
  $ cat *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   303
  hello
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   304
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   305
  $ hg revert --all --no-backup
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   306
  reverting hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   307
  $ hg fix --working-dir * --whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   308
  $ cat *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   309
  HELLO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   310
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   311
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   312
The same ideas apply to fixing a revision, so we create a revision that doesn't
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   313
modify either of the files in question and try fixing it. This also tests that
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   314
we ignore a file that doesn't match any configured fixer.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   315
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   316
  $ hg revert --all --no-backup
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   317
  reverting hello.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   318
  reverting hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   319
  $ printf "unimportant\n" > some.file
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   320
  $ hg commit -Aqm "some other file"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   321
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   322
  $ hg fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   323
  $ hg cat -r tip *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   324
  hello
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   325
  world
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   326
  unimportant
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   327
  $ hg fix -r . --whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   328
  $ hg cat -r tip *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   329
  hello
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   330
  world
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   331
  unimportant
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   332
  $ hg fix -r . *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   333
  $ hg cat -r tip *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   334
  hello
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   335
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   336
  unimportant
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   337
  $ hg fix -r . * --whole --config experimental.evolution.allowdivergence=true
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   338
  2 new content-divergent changesets
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   339
  $ hg cat -r tip *
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   340
  HELLO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   341
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   342
  unimportant
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   343
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   344
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   345
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   346
Fixing the working directory should still work if there are no revisions.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   347
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   348
  $ hg init norevisions
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   349
  $ cd norevisions
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   350
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   351
  $ printf "something\n" > something.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   352
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   353
  adding something.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   354
  $ hg fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   355
  $ cat something.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   356
  SOMETHING
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   357
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   358
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   359
47765
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   360
Test that the working copy is reported clean if formatting of the parent makes
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   361
it clean.
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   362
  $ hg init wc-already-formatted
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   363
  $ cd wc-already-formatted
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   364
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   365
  $ printf "hello   world\n" > hello.whole
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   366
  $ hg commit -Am initial
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   367
  adding hello.whole
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   368
  $ hg fix -w *
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   369
  $ hg st
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   370
  M hello.whole
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   371
  $ hg fix -s . *
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   372
  $ hg st
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   373
  $ hg diff
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   374
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   375
  $ cd ..
184d83ef2e59 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy
Martin von Zweigbergk <martinvonz@google.com>
parents: 47128
diff changeset
   376
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   377
Test the effect of fixing the working directory for each possible status, with
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   378
and without providing explicit file arguments.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   379
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   380
  $ hg init implicitlyfixstatus
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   381
  $ cd implicitlyfixstatus
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   382
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   383
  $ printf "modified\n" > modified.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   384
  $ printf "removed\n" > removed.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   385
  $ printf "deleted\n" > deleted.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   386
  $ printf "clean\n" > clean.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   387
  $ printf "ignored.whole" > .hgignore
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   388
  $ hg commit -Aqm "stuff"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   389
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   390
  $ printf "modified!!!\n" > modified.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   391
  $ printf "unknown\n" > unknown.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   392
  $ printf "ignored\n" > ignored.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   393
  $ printf "added\n" > added.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   394
  $ hg add added.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   395
  $ hg remove removed.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   396
  $ rm deleted.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   397
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   398
  $ hg status --all
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   399
  M modified.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   400
  A added.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   401
  R removed.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   402
  ! deleted.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   403
  ? unknown.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   404
  I ignored.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   405
  C .hgignore
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   406
  C clean.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   407
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   408
  $ hg fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   409
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   410
  $ hg status --all
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   411
  M modified.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   412
  A added.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   413
  R removed.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   414
  ! deleted.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   415
  ? unknown.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   416
  I ignored.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   417
  C .hgignore
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   418
  C clean.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   419
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   420
  $ cat *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   421
  ADDED
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   422
  clean
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   423
  ignored
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   424
  MODIFIED!!!
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   425
  unknown
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   426
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   427
  $ printf "modified!!!\n" > modified.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   428
  $ printf "added\n" > added.whole
42008
7f6b375a8903 fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents: 41126
diff changeset
   429
7f6b375a8903 fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents: 41126
diff changeset
   430
Listing the files explicitly causes untracked files to also be fixed, but
7f6b375a8903 fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents: 41126
diff changeset
   431
ignored files are still unaffected.
7f6b375a8903 fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents: 41126
diff changeset
   432
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   433
  $ hg fix --working-dir *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   434
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   435
  $ hg status --all
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   436
  M clean.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   437
  M modified.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   438
  A added.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   439
  R removed.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   440
  ! deleted.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   441
  ? unknown.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   442
  I ignored.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   443
  C .hgignore
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   444
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   445
  $ cat *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   446
  ADDED
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   447
  CLEAN
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   448
  ignored
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   449
  MODIFIED!!!
42008
7f6b375a8903 fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents: 41126
diff changeset
   450
  UNKNOWN
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   451
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   452
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   453
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   454
Test that incremental fixing works on files with additions, deletions, and
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   455
changes in multiple line ranges. Note that deletions do not generally cause
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   456
neighboring lines to be fixed, so we don't return a line range for purely
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   457
deleted sections. In the future we should support a :deletion config that
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   458
allows fixers to know where deletions are located.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   459
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   460
  $ hg init incrementalfixedlines
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   461
  $ cd incrementalfixedlines
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   462
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   463
  $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.txt
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   464
  $ hg commit -Aqm "foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   465
  $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   466
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   467
  $ hg --config "fix.fail:command=echo" \
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   468
  >    --config "fix.fail:linerange={first}:{last}" \
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   469
  >    --config "fix.fail:pattern=foo.txt" \
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   470
  >    fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   471
  $ cat foo.txt
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   472
  1:1 4:6 8:8
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   473
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   474
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   475
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   476
Test that --whole fixes all lines regardless of the diffs present.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   477
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   478
  $ hg init wholeignoresdiffs
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   479
  $ cd wholeignoresdiffs
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   480
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   481
  $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   482
  $ hg commit -Aqm "foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   483
  $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.changed
42663
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   484
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   485
  $ hg fix --working-dir
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   486
  $ cat foo.changed
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   487
  ZZ
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   488
  a
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   489
  c
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   490
  DD
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   491
  EE
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   492
  FF
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   493
  f
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   494
  GG
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   495
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   496
  $ hg fix --working-dir --whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   497
  $ cat foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   498
  ZZ
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   499
  A
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   500
  C
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   501
  DD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   502
  EE
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   503
  FF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   504
  F
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   505
  GG
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   506
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   507
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   508
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   509
We should do nothing with symlinks, and their targets should be unaffected. Any
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   510
other behavior would be more complicated to implement and harder to document.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   511
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   512
#if symlink
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   513
  $ hg init dontmesswithsymlinks
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   514
  $ cd dontmesswithsymlinks
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   515
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   516
  $ printf "hello\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   517
  $ ln -s hello.whole hellolink
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   518
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   519
  adding hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   520
  adding hellolink
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   521
  $ hg fix --working-dir hellolink
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   522
  $ hg status
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   523
  A hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   524
  A hellolink
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   525
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   526
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   527
#endif
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   528
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   529
We should allow fixers to run on binary files, even though this doesn't sound
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   530
like a common use case. There's not much benefit to disallowing it, and users
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   531
can add "and not binary()" to their filesets if needed. The Mercurial
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   532
philosophy is generally to not handle binary files specially anyway.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   533
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   534
  $ hg init cantouchbinaryfiles
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   535
  $ cd cantouchbinaryfiles
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   536
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   537
  $ printf "hello\0\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   538
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   539
  adding hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   540
  $ hg fix --working-dir 'set:binary()'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   541
  $ cat hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   542
  HELLO\x00 (esc)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   543
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   544
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   545
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   546
We have a config for the maximum size of file we will attempt to fix. This can
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   547
be helpful to avoid running unsuspecting fixer tools on huge inputs, which
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   548
could happen by accident without a well considered configuration. A more
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   549
precise configuration could use the size() fileset function if one global limit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   550
is undesired.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   551
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   552
  $ hg init maxfilesize
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   553
  $ cd maxfilesize
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   554
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   555
  $ printf "this file is huge\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   556
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   557
  adding hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   558
  $ hg --config fix.maxfilesize=10 fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   559
  ignoring file larger than 10 bytes: hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   560
  $ cat hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   561
  this file is huge
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   562
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   563
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   564
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   565
If we specify a file to fix, other files should be left alone, even if they
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   566
have changes.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   567
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   568
  $ hg init fixonlywhatitellyouto
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   569
  $ cd fixonlywhatitellyouto
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   570
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   571
  $ printf "fix me!\n" > fixme.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   572
  $ printf "not me.\n" > notme.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   573
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   574
  adding fixme.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   575
  adding notme.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   576
  $ hg fix --working-dir fixme.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   577
  $ cat *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   578
  FIX ME!
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   579
  not me.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   580
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   581
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   582
42663
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   583
If we try to fix a missing file, we still fix other files.
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   584
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   585
  $ hg init fixmissingfile
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   586
  $ cd fixmissingfile
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   587
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   588
  $ printf "fix me!\n" > foo.whole
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   589
  $ hg add
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   590
  adding foo.whole
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   591
  $ hg fix --working-dir foo.whole bar.whole
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   592
  bar.whole: $ENOENT$
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   593
  $ cat *.whole
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   594
  FIX ME!
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   595
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   596
  $ cd ..
4b04244f2d5f fix: add some new test cases
Danny Hooper <hooper@google.com>
parents: 42655
diff changeset
   597
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   598
Specifying a directory name should fix all its files and subdirectories.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   599
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   600
  $ hg init fixdirectory
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   601
  $ cd fixdirectory
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   602
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   603
  $ mkdir -p dir1/dir2
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   604
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   605
  $ printf "bar\n" > dir1/bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   606
  $ printf "baz\n" > dir1/dir2/baz.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   607
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   608
  adding dir1/bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   609
  adding dir1/dir2/baz.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   610
  adding foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   611
  $ hg fix --working-dir dir1
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   612
  $ cat foo.whole dir1/bar.whole dir1/dir2/baz.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   613
  foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   614
  BAR
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   615
  BAZ
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   616
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   617
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   618
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   619
Fixing a file in the working directory that needs no fixes should not actually
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   620
write back to the file, so for example the mtime shouldn't change.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   621
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   622
  $ hg init donttouchunfixedfiles
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   623
  $ cd donttouchunfixedfiles
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   624
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   625
  $ printf "NO FIX NEEDED\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   626
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   627
  adding foo.whole
37798
8fa3396a832d test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Yuya Nishihara <yuya@tcha.org>
parents: 37791
diff changeset
   628
  $ cp -p foo.whole foo.whole.orig
37809
80695628adcb test-fix: normalize precision of mtime copied by 'cp -p'
Yuya Nishihara <yuya@tcha.org>
parents: 37798
diff changeset
   629
  $ cp -p foo.whole.orig foo.whole
37593
314f39e5fa86 tests: use `f --newer` instead of `stat -c` in test-fix.t
Augie Fackler <augie@google.com>
parents: 37560
diff changeset
   630
  $ sleep 2 # mtime has a resolution of one or two seconds.
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   631
  $ hg fix --working-dir
37798
8fa3396a832d test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Yuya Nishihara <yuya@tcha.org>
parents: 37791
diff changeset
   632
  $ f foo.whole.orig --newer foo.whole
8fa3396a832d test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Yuya Nishihara <yuya@tcha.org>
parents: 37791
diff changeset
   633
  foo.whole.orig: newer than foo.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   634
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   635
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   636
38967
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   637
When a fixer prints to stderr, we don't assume that it has failed. We show the
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   638
error messages to the user, and we still let the fixer affect the file it was
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   639
fixing if its exit code is zero. Some code formatters might emit error messages
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   640
on stderr and nothing on stdout, which would cause us the clear the file,
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   641
except that they also exit with a non-zero code. We show the user which fixer
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   642
emitted the stderr, and which revision, but we assume that the fixer will print
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   643
the filename if it is relevant (since the issue may be non-specific). There is
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   644
also a config to abort (without affecting any files whatsoever) if we see any
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   645
tool with a non-zero exit status.
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   646
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   647
  $ hg init showstderr
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   648
  $ cd showstderr
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   649
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   650
  $ printf "hello\n" > hello.txt
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   651
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   652
  adding hello.txt
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   653
  $ cat > $TESTTMP/work.sh <<'EOF'
37791
72ccb0716302 tests: stabilize test-fix.t for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 37595
diff changeset
   654
  > printf 'HELLO\n'
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   655
  > printf "$@: some\nerror that didn't stop the tool" >&2
38967
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   656
  > exit 0 # success despite the stderr output
37791
72ccb0716302 tests: stabilize test-fix.t for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 37595
diff changeset
   657
  > EOF
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   658
  $ hg --config "fix.work:command=sh $TESTTMP/work.sh {rootpath}" \
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   659
  >    --config "fix.work:pattern=hello.txt" \
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   660
  >    fix --working-dir
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   661
  [wdir] work: hello.txt: some
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   662
  [wdir] work: error that didn't stop the tool
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   663
  $ cat hello.txt
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   664
  HELLO
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   665
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   666
  $ printf "goodbye\n" > hello.txt
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   667
  $ printf "foo\n" > foo.whole
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   668
  $ hg add
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   669
  adding foo.whole
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   670
  $ cat > $TESTTMP/fail.sh <<'EOF'
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   671
  > printf 'GOODBYE\n'
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   672
  > printf "$@: some\nerror that did stop the tool\n" >&2
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   673
  > exit 42 # success despite the stdout output
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   674
  > EOF
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   675
  $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   676
  >    --config "fix.fail:pattern=hello.txt" \
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   677
  >    --config "fix.failure=abort" \
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   678
  >    fix --working-dir
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   679
  [wdir] fail: hello.txt: some
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   680
  [wdir] fail: error that did stop the tool
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   681
  abort: no fixes will be applied
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   682
  (use --config fix.failure=continue to apply any successful fixes anyway)
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   683
  [255]
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   684
  $ cat hello.txt
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   685
  goodbye
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   686
  $ cat foo.whole
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   687
  foo
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   688
38967
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   689
  $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   690
  >    --config "fix.fail:pattern=hello.txt" \
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   691
  >    fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   692
  [wdir] fail: hello.txt: some
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   693
  [wdir] fail: error that did stop the tool
38967
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   694
  $ cat hello.txt
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   695
  goodbye
40532
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   696
  $ cat foo.whole
93bab80993f4 fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents: 39707
diff changeset
   697
  FOO
38967
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   698
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   699
  $ hg --config "fix.fail:command=exit 42" \
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
   700
  >    --config "fix.fail:pattern=hello.txt" \
38967
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   701
  >    fix --working-dir
a009589cd32a fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents: 38590
diff changeset
   702
  [wdir] fail: exited with status 42
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   703
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   704
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   705
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   706
Fixing the working directory and its parent revision at the same time should
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   707
check out the replacement revision for the parent. This prevents any new
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   708
uncommitted changes from appearing. We test this for a clean working directory
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   709
and a dirty one. In both cases, all lines/files changed since the grandparent
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   710
will be fixed. The grandparent is the "baserev" for both the parent and the
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   711
working copy.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   712
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   713
  $ hg init fixdotandcleanwdir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   714
  $ cd fixdotandcleanwdir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   715
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   716
  $ printf "hello\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   717
  $ printf "world\n" > world.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   718
  $ hg commit -Aqm "the parent commit"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   719
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   720
  $ hg parents --template '{rev} {desc}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   721
  0 the parent commit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   722
  $ hg fix --working-dir -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   723
  $ hg parents --template '{rev} {desc}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   724
  1 the parent commit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   725
  $ hg cat -r . *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   726
  HELLO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   727
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   728
  $ cat *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   729
  HELLO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   730
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   731
  $ hg status
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   732
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   733
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   734
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   735
Same test with a dirty working copy.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   736
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   737
  $ hg init fixdotanddirtywdir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   738
  $ cd fixdotanddirtywdir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   739
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   740
  $ printf "hello\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   741
  $ printf "world\n" > world.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   742
  $ hg commit -Aqm "the parent commit"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   743
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   744
  $ printf "hello,\n" > hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   745
  $ printf "world!\n" > world.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   746
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   747
  $ hg parents --template '{rev} {desc}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   748
  0 the parent commit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   749
  $ hg fix --working-dir -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   750
  $ hg parents --template '{rev} {desc}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   751
  1 the parent commit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   752
  $ hg cat -r . *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   753
  HELLO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   754
  WORLD
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   755
  $ cat *.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   756
  HELLO,
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   757
  WORLD!
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   758
  $ hg status
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   759
  M hello.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   760
  M world.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   761
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   762
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   763
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   764
When we have a chain of commits that change mutually exclusive lines of code,
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   765
we should be able to do incremental fixing that causes each commit in the chain
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   766
to include fixes made to the previous commits. This prevents children from
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   767
backing out the fixes made in their parents. A dirty working directory is
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   768
conceptually similar to another commit in the chain.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   769
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   770
  $ hg init incrementallyfixchain
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   771
  $ cd incrementallyfixchain
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   772
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   773
  $ cat > file.changed <<EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   774
  > first
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   775
  > second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   776
  > third
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   777
  > fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   778
  > fifth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   779
  > EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   780
  $ hg commit -Aqm "the common ancestor (the baserev)"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   781
  $ cat > file.changed <<EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   782
  > first (changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   783
  > second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   784
  > third
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   785
  > fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   786
  > fifth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   787
  > EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   788
  $ hg commit -Aqm "the first commit to fix"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   789
  $ cat > file.changed <<EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   790
  > first (changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   791
  > second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   792
  > third (changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   793
  > fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   794
  > fifth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   795
  > EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   796
  $ hg commit -Aqm "the second commit to fix"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   797
  $ cat > file.changed <<EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   798
  > first (changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   799
  > second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   800
  > third (changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   801
  > fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   802
  > fifth (changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   803
  > EOF
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   804
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   805
  $ hg fix -r . -r '.^' --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   806
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   807
  $ hg parents --template '{rev}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   808
  4
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   809
  $ hg cat -r '.^^' file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   810
  first
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   811
  second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   812
  third
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   813
  fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   814
  fifth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   815
  $ hg cat -r '.^' file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   816
  FIRST (CHANGED)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   817
  second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   818
  third
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   819
  fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   820
  fifth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   821
  $ hg cat -r . file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   822
  FIRST (CHANGED)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   823
  second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   824
  THIRD (CHANGED)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   825
  fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   826
  fifth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   827
  $ cat file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   828
  FIRST (CHANGED)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   829
  second
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   830
  THIRD (CHANGED)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   831
  fourth
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   832
  FIFTH (CHANGED)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   833
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   834
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   835
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   836
If we incrementally fix a merge commit, we should fix any lines that changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   837
versus either parent. You could imagine only fixing the intersection or some
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   838
other subset, but this is necessary if either parent is being fixed. It
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   839
prevents us from forgetting fixes made in either parent.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   840
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   841
  $ hg init incrementallyfixmergecommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   842
  $ cd incrementallyfixmergecommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   843
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   844
  $ printf "a\nb\nc\n" > file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   845
  $ hg commit -Aqm "ancestor"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   846
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   847
  $ printf "aa\nb\nc\n" > file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   848
  $ hg commit -m "change a"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   849
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   850
  $ hg checkout '.^'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   851
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   852
  $ printf "a\nb\ncc\n" > file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   853
  $ hg commit -m "change c"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   854
  created new head
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   855
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   856
  $ hg merge
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   857
  merging file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   858
  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   859
  (branch merge, don't forget to commit)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   860
  $ hg commit -m "merge"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   861
  $ hg cat -r . file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   862
  aa
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   863
  b
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   864
  cc
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   865
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   866
  $ hg fix -r . --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   867
  $ hg cat -r . file.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   868
  AA
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   869
  b
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   870
  CC
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   871
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   872
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   873
47886
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   874
We should be allowed to fix the working (and only the working copy) while
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   875
merging.
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   876
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   877
  $ hg init fixworkingcopywhilemerging
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   878
  $ cd fixworkingcopywhilemerging
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   879
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   880
  $ printf "a\nb\nc\n" > file.changed
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   881
  $ hg commit -Aqm "ancestor"
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   882
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   883
  $ printf "aa\nb\nc\n" > file.changed
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   884
  $ hg commit -m "change a"
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   885
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   886
  $ hg checkout '.^'
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   887
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   888
  $ printf "a\nb\ncc\n" > file.changed
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   889
  $ hg commit -m "change c"
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   890
  created new head
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   891
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   892
  $ hg merge
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   893
  merging file.changed
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   894
  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   895
  (branch merge, don't forget to commit)
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   896
  $ cat file.changed
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   897
  aa
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   898
  b
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   899
  cc
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   900
Not allowed to fix a parent of the working copy while merging
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   901
  $ hg fix -r . --working-dir
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   902
  abort: outstanding uncommitted merge
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   903
  (use 'hg commit' or 'hg merge --abort')
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   904
  [20]
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   905
  $ hg fix --working-dir
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   906
  $ cat file.changed
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   907
  AA
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   908
  b
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   909
  CC
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   910
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   911
  $ cd ..
86a60679cf61 fix: again allow formatting the working copy while merging
Martin von Zweigbergk <martinvonz@google.com>
parents: 47767
diff changeset
   912
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   913
Abort fixing revisions if there is an unfinished operation. We don't want to
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   914
make things worse by editing files or stripping/obsoleting things. Also abort
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   915
fixing the working directory if there are unresolved merge conflicts.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   916
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   917
  $ hg init abortunresolved
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   918
  $ cd abortunresolved
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   919
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   920
  $ echo "foo1" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   921
  $ hg commit -Aqm "foo 1"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   922
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   923
  $ hg update null
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   924
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   925
  $ echo "foo2" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   926
  $ hg commit -Aqm "foo 2"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   927
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   928
  $ hg --config extensions.rebase= rebase -r 1 -d 0
45771
f90a5c211251 rebase: change and standarize template for rebase's one-line summary
Martin von Zweigbergk <martinvonz@google.com>
parents: 45218
diff changeset
   929
  rebasing 1:c3b6dc0e177a tip "foo 2"
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   930
  merging foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   931
  warning: conflicts while merging foo.whole! (edit, then use 'hg resolve --mark')
45150
dc5e5577af39 error: unify the error message formats for 'rebase' and 'unshelve'
Daniel Ploch <dploch@google.com>
parents: 44575
diff changeset
   932
  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
45826
21733e8c924f errors: add config that lets user get more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents: 45807
diff changeset
   933
  [240]
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   934
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   935
  $ hg --config extensions.rebase= fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   936
  abort: unresolved conflicts
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   937
  (use 'hg resolve')
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   938
  [255]
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   939
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   940
  $ hg --config extensions.rebase= fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   941
  abort: rebase in progress
45215
a253ded5b03d morestatus: mention --stop even if not using --verbose
Kyle Lippincott <spectral@google.com>
parents: 45150
diff changeset
   942
  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
45840
527ce85c2e60 errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 45826
diff changeset
   943
  [20]
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   944
42363
b02f3aa2fab5 test: add missing 'cd ..' to test case
Danny Hooper <hooper@google.com>
parents: 42194
diff changeset
   945
  $ cd ..
b02f3aa2fab5 test: add missing 'cd ..' to test case
Danny Hooper <hooper@google.com>
parents: 42194
diff changeset
   946
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   947
When fixing a file that was renamed, we should diff against the source of the
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   948
rename for incremental fixing and we should correctly reproduce the rename in
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   949
the replacement revision.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   950
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   951
  $ hg init fixrenamecommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   952
  $ cd fixrenamecommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   953
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   954
  $ printf "a\nb\nc\n" > source.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   955
  $ hg commit -Aqm "source revision"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   956
  $ hg move source.changed dest.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   957
  $ printf "a\nb\ncc\n" > dest.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   958
  $ hg commit -m "dest revision"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   959
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   960
  $ hg fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   961
  $ hg log -r tip --copies --template "{file_copies}\n"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   962
  dest.changed (source.changed)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   963
  $ hg cat -r tip dest.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   964
  a
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   965
  b
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   966
  CC
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   967
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   968
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   969
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   970
When fixing revisions that remove files we must ensure that the replacement
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   971
actually removes the file, whereas it could accidentally leave it unchanged or
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   972
write an empty string to it.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   973
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   974
  $ hg init fixremovedfile
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   975
  $ cd fixremovedfile
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   976
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   977
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   978
  $ printf "bar\n" > bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   979
  $ hg commit -Aqm "add files"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   980
  $ hg remove bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   981
  $ hg commit -m "remove file"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   982
  $ hg status --change .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   983
  R bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   984
  $ hg fix -r . foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   985
  $ hg status --change tip
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   986
  M foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   987
  R bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   988
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   989
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   990
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   991
If fixing a revision finds no fixes to make, no replacement revision should be
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   992
created.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   993
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   994
  $ hg init nofixesneeded
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   995
  $ cd nofixesneeded
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   996
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   997
  $ printf "FOO\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   998
  $ hg commit -Aqm "add file"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
   999
  $ hg log --template '{rev}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1000
  0
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1001
  $ hg fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1002
  $ hg log --template '{rev}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1003
  0
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1004
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1005
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1006
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1007
If fixing a commit reverts all the changes in the commit, we replace it with a
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1008
commit that changes no files.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1009
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1010
  $ hg init nochangesleft
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1011
  $ cd nochangesleft
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1012
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1013
  $ printf "FOO\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1014
  $ hg commit -Aqm "add file"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1015
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1016
  $ hg commit -m "edit file"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1017
  $ hg status --change .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1018
  M foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1019
  $ hg fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1020
  $ hg status --change tip
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1021
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1022
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1023
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1024
If we fix a parent and child revision together, the child revision must be
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1025
replaced if the parent is replaced, even if the diffs of the child needed no
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1026
fixes. However, we're free to not replace revisions that need no fixes and have
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1027
no ancestors that are replaced.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1028
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1029
  $ hg init mustreplacechild
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1030
  $ cd mustreplacechild
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1031
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1032
  $ printf "FOO\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1033
  $ hg commit -Aqm "add foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1034
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1035
  $ hg commit -m "edit foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1036
  $ printf "BAR\n" > bar.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1037
  $ hg commit -Aqm "add bar"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1038
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1039
  $ hg log --graph --template '{rev} {files}'
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1040
  @  2 bar.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1041
  |
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1042
  o  1 foo.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1043
  |
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1044
  o  0 foo.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1045
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1046
  $ hg fix -r 0:2
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1047
  $ hg log --graph --template '{rev} {files}'
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1048
  o  4 bar.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1049
  |
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1050
  o  3
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1051
  |
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1052
  | @  2 bar.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1053
  | |
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1054
  | x  1 foo.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1055
  |/
40569
19e1c26213f1 cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents: 40566
diff changeset
  1056
  o  0 foo.whole
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1057
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1058
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1059
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1060
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1061
It's also possible that the child needs absolutely no changes, but we still
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1062
need to replace it to update its parent. If we skipped replacing the child
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1063
because it had no file content changes, it would become an orphan for no good
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1064
reason.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1065
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1066
  $ hg init mustreplacechildevenifnop
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1067
  $ cd mustreplacechildevenifnop
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1068
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1069
  $ printf "Foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1070
  $ hg commit -Aqm "add a bad foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1071
  $ printf "FOO\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1072
  $ hg commit -m "add a good foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1073
  $ hg fix -r . -r '.^'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1074
  $ hg log --graph --template '{rev} {desc}'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1075
  o  3 add a good foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1076
  |
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1077
  o  2 add a bad foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1078
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1079
  @  1 add a good foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1080
  |
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1081
  x  0 add a bad foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1082
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1083
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1084
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1085
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1086
Similar to the case above, the child revision may become empty as a result of
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1087
fixing its parent. We should still create an empty replacement child.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1088
TODO: determine how this should interact with ui.allowemptycommit given that
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1089
the empty replacement could have children.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1090
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1091
  $ hg init mustreplacechildevenifempty
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1092
  $ cd mustreplacechildevenifempty
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1093
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1094
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1095
  $ hg commit -Aqm "add foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1096
  $ printf "Foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1097
  $ hg commit -m "edit foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1098
  $ hg fix -r . -r '.^'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1099
  $ hg log --graph --template '{rev} {desc}\n' --stat
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1100
  o  3 edit foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1101
  |
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1102
  o  2 add foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1103
      foo.whole |  1 +
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1104
      1 files changed, 1 insertions(+), 0 deletions(-)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1105
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1106
  @  1 edit foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1107
  |   foo.whole |  2 +-
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1108
  |   1 files changed, 1 insertions(+), 1 deletions(-)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1109
  |
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1110
  x  0 add foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1111
      foo.whole |  1 +
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1112
      1 files changed, 1 insertions(+), 0 deletions(-)
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1113
  
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1114
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1115
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1116
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1117
Fixing a secret commit should replace it with another secret commit.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1118
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1119
  $ hg init fixsecretcommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1120
  $ cd fixsecretcommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1121
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1122
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1123
  $ hg commit -Aqm "add foo" --secret
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1124
  $ hg fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1125
  $ hg log --template '{rev} {phase}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1126
  1 secret
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1127
  0 secret
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1128
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1129
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1130
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1131
We should also preserve phase when fixing a draft commit while the user has
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1132
their default set to secret.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1133
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1134
  $ hg init respectphasesnewcommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1135
  $ cd respectphasesnewcommit
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1136
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1137
  $ printf "foo\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1138
  $ hg commit -Aqm "add foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1139
  $ hg --config phases.newcommit=secret fix -r .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1140
  $ hg log --template '{rev} {phase}\n'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1141
  1 draft
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1142
  0 draft
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1143
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1144
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1145
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1146
Debug output should show what fixer commands are being subprocessed, which is
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1147
useful for anyone trying to set up a new config.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1148
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1149
  $ hg init debugoutput
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1150
  $ cd debugoutput
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1151
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1152
  $ printf "foo\nbar\nbaz\n" > foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1153
  $ hg commit -Aqm "foo"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1154
  $ printf "Foo\nbar\nBaz\n" > foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1155
  $ hg --debug fix --working-dir
49977
b5ecd0bcbcd7 fix: add more information to the debug output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48672
diff changeset
  1156
  fixing: f65cf3136d41+ - uppercase-changed-lines - foo.changed
37560
41ba336d9f1e fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents: 37183
diff changeset
  1157
  subprocess: * $TESTTMP/uppercase.py 1-1 3-3 (glob)
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1158
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1159
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1160
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1161
Fixing an obsolete revision can cause divergence, so we abort unless the user
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1162
configures to allow it. This is not yet smart enough to know whether there is a
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1163
successor, but even then it is not likely intentional or idiomatic to fix an
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1164
obsolete revision.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1165
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1166
  $ hg init abortobsoleterev
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1167
  $ cd abortobsoleterev
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1168
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1169
  $ printf "foo\n" > foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1170
  $ hg commit -Aqm "foo"
46838
d083c12032c6 tests: update divergence test for `hg fix` to actually result in divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 45853
diff changeset
  1171
  $ hg ci --amend -m rewritten
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1172
  $ hg --hidden fix -r 0
48672
657e490756e6 fix: remove unnecessary and overly strict check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 48346
diff changeset
  1173
  abort: cannot fix b87e30dbf19b, as that creates content-divergence with 2e007a78dfb8
657e490756e6 fix: remove unnecessary and overly strict check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 48346
diff changeset
  1174
  (add --verbose for details or see 'hg help evolution.instability')
657e490756e6 fix: remove unnecessary and overly strict check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 48346
diff changeset
  1175
  [10]
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1176
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1177
  $ hg --hidden fix -r 0 --config experimental.evolution.allowdivergence=true
46838
d083c12032c6 tests: update divergence test for `hg fix` to actually result in divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 45853
diff changeset
  1178
  2 new content-divergent changesets
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1179
  $ hg cat -r tip foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1180
  FOO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1181
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1182
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1184
Test all of the available substitution values for fixer commands.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1185
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1186
  $ hg init substitution
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1187
  $ cd substitution
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1188
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1189
  $ mkdir foo
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1190
  $ printf "hello\ngoodbye\n" > foo/bar
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1191
  $ hg add
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1192
  adding foo/bar
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1193
  $ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1194
  >    --config "fix.fail:linerange='{first}' '{last}'" \
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
  1195
  >    --config "fix.fail:pattern=foo/bar" \
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1196
  >    fix --working-dir
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1197
  $ cat foo/bar
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1198
  foo/bar
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1199
  bar
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1200
  1
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1201
  2
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1202
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1203
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1204
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1205
The --base flag should allow picking the revisions to diff against for changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1206
files and incremental line formatting.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1207
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1208
  $ hg init baseflag
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1209
  $ cd baseflag
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1210
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1211
  $ printf "one\ntwo\n" > foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1212
  $ printf "bar\n" > bar.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1213
  $ hg commit -Aqm "first"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1214
  $ printf "one\nTwo\n" > foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1215
  $ hg commit -m "second"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1216
  $ hg fix -w --base .
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1217
  $ hg status
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1218
  $ hg fix -w --base null
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1219
  $ cat foo.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1220
  ONE
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1221
  TWO
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1222
  $ cat bar.changed
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1223
  BAR
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1224
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1225
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1226
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1227
If the user asks to fix the parent of another commit, they are asking to create
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1228
an orphan. We must respect experimental.evolution.allowunstable.
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1229
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1230
  $ hg init allowunstable
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1231
  $ cd allowunstable
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1232
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1233
  $ printf "one\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1234
  $ hg commit -Aqm "first"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1235
  $ printf "two\n" > foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1236
  $ hg commit -m "second"
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1237
  $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
47070
d90f6237b3aa rewriteutil: say how many commits would become orphan if commit is rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47069
diff changeset
  1238
  abort: cannot fix changeset, as that will orphan 1 descendants
47018
7a90fddb13b0 rewriteutil: point to help about instability when rewriting creates orphan
Martin von Zweigbergk <martinvonz@google.com>
parents: 46838
diff changeset
  1239
  (see 'hg help evolution.instability')
45853
b4694ef45db5 errors: raise more specific errors from rewriteutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 45840
diff changeset
  1240
  [10]
37183
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1241
  $ hg fix -r '.^'
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1242
  1 new orphan changesets
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1243
  $ hg cat -r 2 foo.whole
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1244
  ONE
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1245
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1246
  $ cd ..
ded5ea279a93 fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff changeset
  1247
38590
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1248
The --base flag affects the set of files being fixed. So while the --whole flag
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1249
makes the base irrelevant for changed line ranges, it still changes the
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1250
meaning and effect of the command. In this example, no files or lines are fixed
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1251
until we specify the base, but then we do fix unchanged lines.
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1252
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1253
  $ hg init basewhole
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1254
  $ cd basewhole
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1255
  $ printf "foo1\n" > foo.changed
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1256
  $ hg commit -Aqm "first"
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1257
  $ printf "foo2\n" >> foo.changed
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1258
  $ printf "bar\n" > bar.changed
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1259
  $ hg commit -Aqm "second"
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1260
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1261
  $ hg fix --working-dir --whole
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1262
  $ cat *.changed
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1263
  bar
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1264
  foo1
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1265
  foo2
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1266
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1267
  $ hg fix --working-dir --base 0 --whole
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1268
  $ cat *.changed
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1269
  BAR
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1270
  FOO1
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1271
  FOO2
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1272
f068495a1c28 fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents: 37809
diff changeset
  1273
  $ cd ..
40533
2ecf5c24d0cd fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents: 40532
diff changeset
  1274
40566
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1275
The execution order of tools can be controlled. This example doesn't work if
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1276
you sort after truncating, but the config defines the correct order while the
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1277
definitions are out of order (which might imply the incorrect order given the
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1278
implementation of fix). The goal is to use multiple tools to select the lowest
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1279
5 numbers in the file.
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1280
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1281
  $ hg init priorityexample
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1282
  $ cd priorityexample
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1283
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1284
  $ cat >> .hg/hgrc <<EOF
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1285
  > [fix]
41126
d8f5c615e811 tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents: 41010
diff changeset
  1286
  > head:command = head -n 5
40566
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1287
  > head:pattern = numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1288
  > head:priority = 1
41126
d8f5c615e811 tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents: 41010
diff changeset
  1289
  > sort:command = sort -n
40566
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1290
  > sort:pattern = numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1291
  > sort:priority = 2
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1292
  > EOF
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1293
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1294
  $ printf "8\n2\n3\n6\n7\n4\n9\n5\n1\n0\n" > numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1295
  $ hg add -q
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1296
  $ hg fix -w
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1297
  $ cat numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1298
  0
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1299
  1
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1300
  2
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1301
  3
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1302
  4
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1303
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1304
And of course we should be able to break this by reversing the execution order.
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1305
Test negative priorities while we're at it.
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1306
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1307
  $ cat >> .hg/hgrc <<EOF
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1308
  > [fix]
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1309
  > head:priority = -1
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1310
  > sort:priority = -2
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1311
  > EOF
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1312
  $ printf "8\n2\n3\n6\n7\n4\n9\n5\n1\n0\n" > numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1313
  $ hg fix -w
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1314
  $ cat numbers.txt
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1315
  2
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1316
  3
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1317
  6
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1318
  7
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1319
  8
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1320
b9557567cc3f fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents: 40564
diff changeset
  1321
  $ cd ..
40570
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1322
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1323
It's possible for repeated applications of a fixer tool to create cycles in the
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1324
generated content of a file. For example, two users with different versions of
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1325
a code formatter might fight over the formatting when they run hg fix. In the
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1326
absence of other changes, this means we could produce commits with the same
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1327
hash in subsequent runs of hg fix. This is a problem unless we support
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1328
obsolescence cycles well. We avoid this by adding an extra field to the
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1329
successor which forces it to have a new hash. That's why this test creates
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1330
three revisions instead of two.
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1331
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1332
  $ hg init cyclictool
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1333
  $ cd cyclictool
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1334
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1335
  $ cat >> .hg/hgrc <<EOF
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1336
  > [fix]
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1337
  > swapletters:command = tr ab ba
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1338
  > swapletters:pattern = foo
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1339
  > EOF
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1340
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1341
  $ echo ab > foo
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1342
  $ hg commit -Aqm foo
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1343
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1344
  $ hg fix -r 0
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1345
  $ hg fix -r 1
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1346
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1347
  $ hg cat -r 0 foo --hidden
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1348
  ab
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1349
  $ hg cat -r 1 foo --hidden
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1350
  ba
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1351
  $ hg cat -r 2 foo
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1352
  ab
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1353
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1354
  $ cd ..
ad71c792a8d8 fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents: 40569
diff changeset
  1355
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1356
We run fixer tools in the repo root so they can look for config files or other
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1357
important things in the working directory. This does NOT mean we are
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1358
reconstructing a working copy of every revision being fixed; we're just giving
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1359
the tool knowledge of the repo's location in case it can do something
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1360
reasonable with that.
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1361
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1362
  $ hg init subprocesscwd
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1363
  $ cd subprocesscwd
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1364
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1365
  $ cat >> .hg/hgrc <<EOF
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1366
  > [fix]
42938
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1367
  > printcwd:command = "$PYTHON" -c "import os; print(os.getcwd())"
43226
5272bd7e7517 tests: add test showing that fixer patterns are currently relative to $PWD
Martin von Zweigbergk <martinvonz@google.com>
parents: 43220
diff changeset
  1368
  > printcwd:pattern = relpath:foo/bar
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1369
  > filesetpwd:command = "$PYTHON" -c "import os; print('fs: ' + os.getcwd())"
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1370
  > filesetpwd:pattern = set:**quux
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1371
  > EOF
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1372
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1373
  $ mkdir foo
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1374
  $ printf "bar\n" > foo/bar
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1375
  $ printf "quux\n" > quux
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1376
  $ hg commit -Aqm blah
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1377
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1378
  $ hg fix -w -r . foo/bar
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1379
  $ hg cat -r tip foo/bar
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1380
  $TESTTMP/subprocesscwd
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1381
  $ cat foo/bar
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1382
  $TESTTMP/subprocesscwd
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1383
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1384
  $ cd foo
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1385
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1386
  $ hg fix -w -r . bar
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1387
  $ hg cat -r tip bar ../quux
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1388
  $TESTTMP/subprocesscwd
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1389
  quux
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1390
  $ cat bar ../quux
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1391
  $TESTTMP/subprocesscwd
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1392
  quux
43226
5272bd7e7517 tests: add test showing that fixer patterns are currently relative to $PWD
Martin von Zweigbergk <martinvonz@google.com>
parents: 43220
diff changeset
  1393
  $ echo modified > bar
5272bd7e7517 tests: add test showing that fixer patterns are currently relative to $PWD
Martin von Zweigbergk <martinvonz@google.com>
parents: 43220
diff changeset
  1394
  $ hg fix -w bar
5272bd7e7517 tests: add test showing that fixer patterns are currently relative to $PWD
Martin von Zweigbergk <martinvonz@google.com>
parents: 43220
diff changeset
  1395
  $ cat bar
43227
f02d3c0eed18 fix: match patterns relative to root
Martin von Zweigbergk <martinvonz@google.com>
parents: 43226
diff changeset
  1396
  $TESTTMP/subprocesscwd
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1397
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1398
Apparently fixing p1() and its descendants doesn't include wdir() unless
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1399
explicitly stated.
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1400
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1401
  $ hg fix -r '.::'
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1402
  $ hg cat -r . ../quux
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1403
  quux
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1404
  $ hg cat -r tip ../quux
44009
e685fac56693 match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents: 43962
diff changeset
  1405
  fs: $TESTTMP/subprocesscwd
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1406
  $ cat ../quux
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1407
  quux
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1408
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1409
Clean files are not fixed unless explicitly named
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1410
  $ echo 'dirty' > ../quux
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1411
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1412
  $ hg fix --working-dir
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1413
  $ cat ../quux
44009
e685fac56693 match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents: 43962
diff changeset
  1414
  fs: $TESTTMP/subprocesscwd
43948
9595b6a9f0d5 tests: show that fileset patterns don't work with `fix` when not in repo root
Matt Harbison <matt_harbison@yahoo.com>
parents: 43936
diff changeset
  1415
42673
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1416
  $ cd ../..
74b4cd091e0d fix: run fixer tools in the repo root as cwd so they can use the working copy
Danny Hooper <hooper@google.com>
parents: 42663
diff changeset
  1417
42655
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1418
Tools configured without a pattern are ignored. It would be too dangerous to
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1419
run them on all files, because this might happen while testing a configuration
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1420
that also deletes all of the file content. There is no reasonable subset of the
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1421
files to use as a default. Users should be explicit about what files are
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1422
affected by a tool. This test also confirms that we don't crash when the
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1423
pattern config is missing, and that we only warn about it once.
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1424
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1425
  $ hg init nopatternconfigured
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1426
  $ cd nopatternconfigured
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1427
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1428
  $ printf "foo" > foo
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1429
  $ printf "bar" > bar
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1430
  $ hg add -q
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1431
  $ hg fix --debug --working-dir --config "fix.nopattern:command=echo fixed"
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1432
  fixer tool has no pattern configuration: nopattern
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1433
  $ cat foo bar
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1434
  foobar (no-eol)
43220
d3d1a3afe7aa fix: warn when a fixer doesn't have a configured command
Martin von Zweigbergk <martinvonz@google.com>
parents: 43058
diff changeset
  1435
  $ hg fix --debug --working-dir --config "fix.nocommand:pattern=foo.bar"
d3d1a3afe7aa fix: warn when a fixer doesn't have a configured command
Martin von Zweigbergk <martinvonz@google.com>
parents: 43058
diff changeset
  1436
  fixer tool has no command configuration: nocommand
42655
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1437
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1438
  $ cd ..
2987d015aba4 fix: ignore fixer tool configurations that are missing patterns
Danny Hooper <hooper@google.com>
parents: 42654
diff changeset
  1439
43058
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1440
Tools can be disabled. Disabled tools do nothing but print a debug message.
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1441
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1442
  $ hg init disabled
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1443
  $ cd disabled
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1444
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1445
  $ printf "foo\n" > foo
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1446
  $ hg add -q
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1447
  $ hg fix --debug --working-dir --config "fix.disabled:command=echo fixed" \
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1448
  >                              --config "fix.disabled:pattern=foo" \
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1449
  >                              --config "fix.disabled:enabled=false"
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1450
  ignoring disabled fixer tool: disabled
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1451
  $ cat foo
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1452
  foo
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1453
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1454
  $ cd ..
808a57a08470 fix: add :enabled sub-config for fixer tools
Danny Hooper <hooper@google.com>
parents: 42938
diff changeset
  1455
42654
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1456
Test that we can configure a fixer to affect all files regardless of the cwd.
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1457
The way we invoke matching must not prohibit this.
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1458
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1459
  $ hg init affectallfiles
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1460
  $ cd affectallfiles
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1461
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1462
  $ mkdir foo bar
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1463
  $ printf "foo" > foo/file
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1464
  $ printf "bar" > bar/file
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1465
  $ printf "baz" > baz_file
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1466
  $ hg add -q
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1467
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1468
  $ cd bar
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1469
  $ hg fix --working-dir --config "fix.cooltool:command=echo fixed" \
43226
5272bd7e7517 tests: add test showing that fixer patterns are currently relative to $PWD
Martin von Zweigbergk <martinvonz@google.com>
parents: 43220
diff changeset
  1470
  >                      --config "fix.cooltool:pattern=glob:**"
42654
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1471
  $ cd ..
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1472
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1473
  $ cat foo/file
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1474
  fixed
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1475
  $ cat bar/file
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1476
  fixed
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1477
  $ cat baz_file
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1478
  fixed
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1479
22c4bd7d1cbf fix: add a test case around the effect of cwd on pattern matching
Danny Hooper <hooper@google.com>
parents: 42653
diff changeset
  1480
  $ cd ..
42756
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1481
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1482
Tools should be able to run on unchanged files, even if they set :linerange.
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1483
This includes a corner case where deleted chunks of a file are not considered
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1484
changes.
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1485
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1486
  $ hg init skipclean
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1487
  $ cd skipclean
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1488
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1489
  $ printf "a\nb\nc\n" > foo
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1490
  $ printf "a\nb\nc\n" > bar
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1491
  $ printf "a\nb\nc\n" > baz
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1492
  $ hg commit -Aqm "base"
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1493
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1494
  $ printf "a\nc\n" > foo
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1495
  $ printf "a\nx\nc\n" > baz
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1496
42938
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1497
  $ cat >> print.py <<EOF
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1498
  > import sys
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1499
  > for a in sys.argv[1:]:
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1500
  >    print(a)
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1501
  > EOF
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1502
42756
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1503
  $ hg fix --working-dir foo bar baz \
42938
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1504
  >        --config "fix.changedlines:command=\"$PYTHON\" print.py \"Line ranges:\"" \
a2dffe68b4ea tests: stabilize test-fix.t on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 42893
diff changeset
  1505
  >        --config 'fix.changedlines:linerange="{first} through {last}"' \
43226
5272bd7e7517 tests: add test showing that fixer patterns are currently relative to $PWD
Martin von Zweigbergk <martinvonz@google.com>
parents: 43220
diff changeset
  1506
  >        --config 'fix.changedlines:pattern=glob:**' \
42756
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1507
  >        --config 'fix.changedlines:skipclean=false'
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1508
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1509
  $ cat foo
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1510
  Line ranges:
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1511
  $ cat bar
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1512
  Line ranges:
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1513
  $ cat baz
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1514
  Line ranges:
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1515
  2 through 2
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1516
ed0da6e0d6ee fix: allow tools to use :linerange, but also run if a file is unchanged
Danny Hooper <hooper@google.com>
parents: 42673
diff changeset
  1517
  $ cd ..
43962
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1518
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1519
Test various cases around merges. We were previously dropping files if they were
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1520
created on only the p2 side of the merge, so let's test permutations of:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1521
*   added, was fixed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1522
*   added, considered for fixing but was already good
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1523
*   added, not considered for fixing
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1524
*   modified, was fixed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1525
*   modified, considered for fixing but was already good
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1526
*   modified, not considered for fixing
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1527
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1528
Before the bug was fixed where we would drop files, this test demonstrated the
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1529
following issues:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1530
*   new_in_r1.ignored, new_in_r1_already_good.changed, and
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1531
>   mod_in_r1_already_good.changed were NOT in the manifest for the merge commit
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1532
*   mod_in_r1.ignored had its contents from r0, NOT r1.
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1533
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1534
We're also setting a named branch for every commit to demonstrate that the
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1535
branch is kept intact and there aren't issues updating to another branch in the
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1536
middle of fix.
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1537
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1538
  $ hg init merge_keeps_files
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1539
  $ cd merge_keeps_files
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1540
  $ for f in r0 mod_in_r1 mod_in_r2 mod_in_merge mod_in_child; do
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1541
  >   for c in changed whole ignored; do
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1542
  >     printf "hello\n" > $f.$c
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1543
  >   done
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1544
  >   printf "HELLO\n" > "mod_in_${f}_already_good.changed"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1545
  > done
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1546
  $ hg branch -q r0
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1547
  $ hg ci -Aqm 'r0'
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1548
  $ hg phase -p
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1549
  $ make_test_files() {
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1550
  >   printf "world\n" >> "mod_in_$1.changed"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1551
  >   printf "world\n" >> "mod_in_$1.whole"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1552
  >   printf "world\n" >> "mod_in_$1.ignored"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1553
  >   printf "WORLD\n" >> "mod_in_$1_already_good.changed"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1554
  >   printf "new in $1\n" > "new_in_$1.changed"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1555
  >   printf "new in $1\n" > "new_in_$1.whole"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1556
  >   printf "new in $1\n" > "new_in_$1.ignored"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1557
  >   printf "ALREADY GOOD, NEW IN THIS REV\n" > "new_in_$1_already_good.changed"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1558
  > }
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1559
  $ make_test_commit() {
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1560
  >   make_test_files "$1"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1561
  >   hg branch -q "$1"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1562
  >   hg ci -Aqm "$2"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1563
  > }
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1564
  $ make_test_commit r1 "merge me, pt1"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1565
  $ hg co -q ".^"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1566
  $ make_test_commit r2 "merge me, pt2"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1567
  $ hg merge -qr 1
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1568
  $ make_test_commit merge "evil merge"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1569
  $ make_test_commit child "child of merge"
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1570
  $ make_test_files wdir
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1571
  $ hg fix -r 'not public()' -w
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1572
  $ hg log -G -T'{rev}:{shortest(node,8)}: branch:{branch} desc:{desc}'
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1573
  @  8:c22ce900: branch:child desc:child of merge
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1574
  |
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1575
  o    7:5a30615a: branch:merge desc:evil merge
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1576
  |\
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1577
  | o  6:4e5acdc4: branch:r2 desc:merge me, pt2
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1578
  | |
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1579
  o |  5:eea01878: branch:r1 desc:merge me, pt1
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1580
  |/
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1581
  o  0:0c548d87: branch:r0 desc:r0
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1582
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1583
  $ hg files -r tip
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1584
  mod_in_child.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1585
  mod_in_child.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1586
  mod_in_child.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1587
  mod_in_child_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1588
  mod_in_merge.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1589
  mod_in_merge.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1590
  mod_in_merge.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1591
  mod_in_merge_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1592
  mod_in_mod_in_child_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1593
  mod_in_mod_in_merge_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1594
  mod_in_mod_in_r1_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1595
  mod_in_mod_in_r2_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1596
  mod_in_r0_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1597
  mod_in_r1.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1598
  mod_in_r1.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1599
  mod_in_r1.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1600
  mod_in_r1_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1601
  mod_in_r2.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1602
  mod_in_r2.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1603
  mod_in_r2.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1604
  mod_in_r2_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1605
  new_in_child.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1606
  new_in_child.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1607
  new_in_child.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1608
  new_in_child_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1609
  new_in_merge.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1610
  new_in_merge.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1611
  new_in_merge.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1612
  new_in_merge_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1613
  new_in_r1.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1614
  new_in_r1.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1615
  new_in_r1.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1616
  new_in_r1_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1617
  new_in_r2.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1618
  new_in_r2.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1619
  new_in_r2.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1620
  new_in_r2_already_good.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1621
  r0.changed
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1622
  r0.ignored
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1623
  r0.whole
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1624
  $ for f in "$(hg files -r tip)"; do hg cat -r tip $f -T'{path}:\n{data}\n'; done
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1625
  mod_in_child.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1626
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1627
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1628
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1629
  mod_in_child.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1630
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1631
  world
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1632
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1633
  mod_in_child.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1634
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1635
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1636
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1637
  mod_in_child_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1638
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1639
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1640
  mod_in_merge.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1641
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1642
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1643
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1644
  mod_in_merge.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1645
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1646
  world
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1647
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1648
  mod_in_merge.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1649
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1650
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1651
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1652
  mod_in_merge_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1653
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1654
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1655
  mod_in_mod_in_child_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1656
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1657
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1658
  mod_in_mod_in_merge_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1659
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1660
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1661
  mod_in_mod_in_r1_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1662
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1663
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1664
  mod_in_mod_in_r2_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1665
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1666
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1667
  mod_in_r0_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1668
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1669
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1670
  mod_in_r1.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1671
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1672
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1673
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1674
  mod_in_r1.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1675
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1676
  world
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1677
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1678
  mod_in_r1.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1679
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1680
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1681
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1682
  mod_in_r1_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1683
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1684
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1685
  mod_in_r2.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1686
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1687
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1688
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1689
  mod_in_r2.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1690
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1691
  world
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1692
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1693
  mod_in_r2.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1694
  HELLO
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1695
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1696
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1697
  mod_in_r2_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1698
  WORLD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1699
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1700
  new_in_child.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1701
  NEW IN CHILD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1702
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1703
  new_in_child.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1704
  new in child
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1705
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1706
  new_in_child.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1707
  NEW IN CHILD
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1708
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1709
  new_in_child_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1710
  ALREADY GOOD, NEW IN THIS REV
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1711
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1712
  new_in_merge.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1713
  NEW IN MERGE
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1714
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1715
  new_in_merge.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1716
  new in merge
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1717
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1718
  new_in_merge.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1719
  NEW IN MERGE
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1720
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1721
  new_in_merge_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1722
  ALREADY GOOD, NEW IN THIS REV
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1723
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1724
  new_in_r1.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1725
  NEW IN R1
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1726
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1727
  new_in_r1.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1728
  new in r1
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1729
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1730
  new_in_r1.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1731
  NEW IN R1
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1732
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1733
  new_in_r1_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1734
  ALREADY GOOD, NEW IN THIS REV
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1735
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1736
  new_in_r2.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1737
  NEW IN R2
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1738
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1739
  new_in_r2.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1740
  new in r2
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1741
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1742
  new_in_r2.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1743
  NEW IN R2
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1744
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1745
  new_in_r2_already_good.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1746
  ALREADY GOOD, NEW IN THIS REV
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1747
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1748
  r0.changed:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1749
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1750
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1751
  r0.ignored:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1752
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1753
  
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1754
  r0.whole:
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1755
  hello
eebdd6709868 fix: fix handling of merge commits by using overlayworkingctx
Kyle Lippincott <spectral@google.com>
parents: 43948
diff changeset
  1756
  
48177
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1757
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1758
We should execute the fixer tools as few times as possible, because they might
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1759
be slow or expensive to execute. The inputs to each execution are effectively
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1760
the file path, file content, and line ranges. So, we should be able to re-use
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1761
results whenever those inputs are repeated. That saves a lot of work when
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1762
fixing chains of commits that all have the same file revision for a path being
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1763
fixed.
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1764
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1765
  $ hg init numberofinvocations
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1766
  $ cd numberofinvocations
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1767
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1768
  $ printf "bar1" > bar.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1769
  $ printf "baz1" > baz.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1770
  $ printf "foo1" > foo.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1771
  $ printf "qux1" > qux.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1772
  $ hg commit -Aqm "commit1"
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1773
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1774
  $ printf "bar2" > bar.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1775
  $ printf "baz2" > baz.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1776
  $ printf "foo2" > foo.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1777
  $ hg commit -Aqm "commit2"
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1778
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1779
  $ printf "bar3" > bar.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1780
  $ printf "baz3" > baz.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1781
  $ hg commit -Aqm "commit3"
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1782
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1783
  $ printf "bar4" > bar.log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1784
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1785
  $ LOGFILE=$TESTTMP/log
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1786
  $ LOGGER=$TESTTMP/log.py
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1787
  $ cat >> $LOGGER <<EOF
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1788
  > # Appends the input file's name to the log file.
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1789
  > import sys
48293
7a4d187479b6 windows: use raw string in test log paths
Raphaël Gomès <rgomes@octobus.net>
parents: 48178
diff changeset
  1790
  > with open(r'$LOGFILE', 'a') as f:
48177
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1791
  >     f.write(sys.argv[1] + '\n')
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1792
  > sys.stdout.write(sys.stdin.read())
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1793
  > EOF
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1794
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1795
  $ hg fix --working-dir -r "all()" \
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1796
  >        --config "fix.log:command=\"$PYTHON\" \"$LOGGER\" {rootpath}" \
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1797
  >        --config "fix.log:pattern=glob:**.log"
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1798
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1799
  $ cat $LOGFILE | sort | uniq -c
48346
e6aecc37bfbf tests: fix test-fix on NetBSD
Thomas Klausner <wiz@gatalith.at>
parents: 48293
diff changeset
  1800
  \s*4 bar.log (re)
e6aecc37bfbf tests: fix test-fix on NetBSD
Thomas Klausner <wiz@gatalith.at>
parents: 48293
diff changeset
  1801
  \s*4 baz.log (re)
e6aecc37bfbf tests: fix test-fix on NetBSD
Thomas Klausner <wiz@gatalith.at>
parents: 48293
diff changeset
  1802
  \s*3 foo.log (re)
e6aecc37bfbf tests: fix test-fix on NetBSD
Thomas Klausner <wiz@gatalith.at>
parents: 48293
diff changeset
  1803
  \s*2 qux.log (re)
48177
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1804
066cdec8f74f fix: add test to demonstrate how many times tools are executed
Danny Hooper <hooper@google.com>
parents: 47886
diff changeset
  1805
  $ cd ..
48178
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1806
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1807
For tools that support line ranges, it's wrong to blindly re-use fixed file
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1808
content for the same file revision if it appears twice with different baserevs,
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1809
because the line ranges could be different. Since computing line ranges is
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1810
ambiguous, this isn't a matter of correctness, but it affects the usability of
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1811
this extension. It could maybe be simpler if baserevs were computed on a
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1812
per-file basis to make this situation impossible to construct.
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1813
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1814
In the following example, we construct two subgraphs with the same file
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1815
revisions, and fix different sub-subgraphs to get different baserevs and
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1816
different changed line ranges. The key precondition is that revisions 1 and 4
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1817
have the same file revision, and the key result is that their successors don't
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1818
have the same file content, because we want to fix different areas of that same
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1819
file revision's content.
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1820
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1821
  $ hg init differentlineranges
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1822
  $ cd differentlineranges
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1823
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1824
  $ printf "a\nb\n" > file.changed
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1825
  $ hg commit -Aqm "0 ab"
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1826
  $ printf "a\nx\n" > file.changed
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1827
  $ hg commit -Aqm "1 ax"
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1828
  $ hg remove file.changed
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1829
  $ hg commit -Aqm "2 removed"
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1830
  $ hg revert file.changed -r 0
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1831
  $ hg commit -Aqm "3 ab (reverted)"
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1832
  $ hg revert file.changed -r 1
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1833
  $ hg commit -Aqm "4 ax (reverted)"
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1834
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1835
  $ hg manifest --debug --template "{hash}\n" -r 0; \
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1836
  > hg manifest --debug --template "{hash}\n" -r 3
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1837
  418f692145676128d2fb518b027ddbac624be76e
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1838
  418f692145676128d2fb518b027ddbac624be76e
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1839
  $ hg manifest --debug --template "{hash}\n" -r 1; \
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1840
  > hg manifest --debug --template "{hash}\n" -r 4
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1841
  09b8b3ce5a507caaa282f7262679e6d04091426c
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1842
  09b8b3ce5a507caaa282f7262679e6d04091426c
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1843
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1844
  $ hg fix --working-dir -r 1+3+4
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1845
  3 new orphan changesets
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1846
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1847
  $ hg cat file.changed -r "successors(1)" --hidden
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1848
  a
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1849
  X
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1850
  $ hg cat file.changed -r "successors(4)" --hidden
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1851
  A
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1852
  X
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1853
f12a19d03d2c fix: reduce number of tool executions
Danny Hooper <hooper@google.com>
parents: 48177
diff changeset
  1854
  $ cd ..