Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGce52377102db: amend: stop committing unrequested file reverts (issue6157)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/cmdutil.py (4 lines) | |||
| M | tests/test-amend.t (5 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Valentin Gatien-Baron | Jul 22 2019, 6:33 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | valentin.gatienbaron | ||
| Closed | valentin.gatienbaron |
| # Prune files which were reverted by the updates: if old | # Prune files which were reverted by the updates: if old | ||||
| # introduced file X and the file was renamed in the working | # introduced file X and the file was renamed in the working | ||||
| # copy, then those two files are the same and | # copy, then those two files are the same and | ||||
| # we can discard X from our list of files. Likewise if X | # we can discard X from our list of files. Likewise if X | ||||
| # was removed, it's no longer relevant. If X is missing (aka | # was removed, it's no longer relevant. If X is missing (aka | ||||
| # deleted), old X must be preserved. | # deleted), old X must be preserved. | ||||
| files.update(filestoamend) | files.update(filestoamend) | ||||
| files = [f for f in files if (not samefile(f, wctx, base) | files = [f for f in files if (f not in filestoamend | ||||
| or f in wctx.deleted())] | or not samefile(f, wctx, base))] | ||||
| def filectxfn(repo, ctx_, path): | def filectxfn(repo, ctx_, path): | ||||
| try: | try: | ||||
| # If the file being considered is not amongst the files | # If the file being considered is not amongst the files | ||||
| # to be amended, we should return the file context from the | # to be amended, we should return the file context from the | ||||
| # old changeset. This avoids issues when only some files in | # old changeset. This avoids issues when only some files in | ||||
| # the working copy are being amended but there are also | # the working copy are being amended but there are also | ||||
| # changes to other files from the old changeset. | # changes to other files from the old changeset. | ||||
| [255] | [255] | ||||
| $ cd .. | $ cd .. | ||||
| Corner case of amend from issue6157: | Corner case of amend from issue6157: | ||||
| - working copy parent has a change to file `a` | - working copy parent has a change to file `a` | ||||
| - working copy has the inverse change | - working copy has the inverse change | ||||
| - we amend the working copy parent for files other than `a` | - we amend the working copy parent for files other than `a` | ||||
| hg includes the changes to `a` anyway. | hg used to include the changes to `a` anyway. | ||||
| $ hg init 6157; cd 6157 | $ hg init 6157; cd 6157 | ||||
| $ echo a > a; echo b > b; hg commit -qAm_ | $ echo a > a; echo b > b; hg commit -qAm_ | ||||
| $ echo a2 > a; hg commit -qm_ | $ echo a2 > a; hg commit -qm_ | ||||
| $ hg diff --stat -c . | $ hg diff --stat -c . | ||||
| a | 2 +- | a | 2 +- | ||||
| 1 files changed, 1 insertions(+), 1 deletions(-) | 1 files changed, 1 insertions(+), 1 deletions(-) | ||||
| $ echo a > a; echo b2 > b; hg amend -q b | $ echo a > a; echo b2 > b; hg amend -q b | ||||
| $ hg diff --stat -c . | $ hg diff --stat -c . | ||||
| a | 2 +- | |||||
| b | 2 +- | b | 2 +- | ||||
| 1 files changed, 1 insertions(+), 1 deletions(-) | 2 files changed, 2 insertions(+), 2 deletions(-) | ||||