commit: improve the files field of changelog for merges
Currently, the files list of merge commits repeats all the deletions
(either actual deletions, or files that got renamed) that happened
between base and p2 of the merge. If p2 is the main branch, the list
can easily be much bigger than the change being merged.
This results in various problems worth improving:
- changelog is bigger than necessary
- `hg log directory` lists many unrelated merge commits, and `hg log
-v -r commit` frequently fills multiple screens worth of files
- it possibly slows down adjustlinkrev, by forcing it to read more
manifests, and that function can certainly be a bottleneck
- the server side of pulls can waste a lot of time simply opening the
filelogs for pointless files (the constant factors for opening even
a tiny filelog is apparently pretty bad)
So stop listing such files as described in the code. Impacted merge
commits and their descendants get a different hash than they would
have without this. This doesn't seem problematic, except for
convert. The previous commit helped with that in the hg->hg case (but
if you do svn->hg twice from scratch, hashes can still change).
The rest of the description is numbers. I don't have much to report,
because recreating the files list of existing repositories is not
easy:
- debugupgradeformat and bundle/unbundle don't recreate the list
- export/import tends to choke quickly applying patches or on
description that contain diffs,
- merge commits from the convert extension don't have the right files
list for reasons orthogonal to the current commit
- replaying the merge with hg update/hg merge/hg revert --all/hg
commit can end up failing in hg revert
- I wasn't sure that using debugsetparents + debugrebuilddirstate
would really build the right thing
I measured commit time before and after this change, in a case with no
files filtered out, several files filtered out (no difference) and 5k
files filtered out (+1% time).
Recreating the 100 more recent merges in a private repo, the
concatenated uncompressed files lists goes from 1.12MB to
0.52MB. Excluding 3 merges that are not representative, then the size
goes from 570k to 15k.
I converted part of mozilla-central, and observed file list shrinking
quite a bit too, starting at the very first merge,
733641d9feaf, going
from 550 files to 10 files (although they have relatively few merges,
so they probably wouldn't care).
Differential Revision: https://phab.mercurial-scm.org/D6613
$ hg init
$ echo a > a
$ hg ci -qAm 'add a'
$ hg init subrepo
$ echo 'subrepo = http://example.net/libfoo' > .hgsub
$ hg ci -qAm 'added subrepo'
$ hg up -qC 0
$ echo ax > a
$ hg ci -m 'changed a'
created new head
$ hg up -qC 1
$ cd subrepo
$ echo b > b
$ hg add b
$ cd ..
Should fail, since there are added files to subrepo:
$ hg merge
abort: uncommitted changes in subrepository "subrepo"
[255]
Deleted files trigger a '+' marker in top level repos. Deleted files are also
noticed by `update --check` in the top level repo.
$ hg ci -Sqm 'add b'
$ echo change > subrepo/b
$ hg ci -Sm 'change b'
committing subrepository subrepo
$ rm a
$ hg id
9bfe45a197d7+ tip
$ hg sum
parent: 4:9bfe45a197d7 tip
change b
branch: default
commit: 1 deleted (clean)
update: 1 new changesets, 2 branch heads (merge)
phases: 5 draft
$ hg up --check -r '.^'
abort: uncommitted changes
[255]
$ hg st -S
! a
$ hg up -Cq .
Test that dirty is consistent through subrepos
$ rm subrepo/b
A deleted subrepo file is flagged as dirty, like the top level repo
$ hg id --config extensions.blackbox= --config blackbox.dirty=True \
> --config blackbox.track='command commandfinish'
9bfe45a197d7+ tip
$ cat .hg/blackbox.log
* @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> serve --cmdserver chgunix * (glob) (chg !)
* @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> id --config *extensions.blackbox=* --config *blackbox.dirty=True* (glob)
* @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> id --config *extensions.blackbox=* --config *blackbox.dirty=True* exited 0 * (glob)
TODO: a deleted file should be listed as such, like the top level repo
$ hg sum
parent: 4:9bfe45a197d7 tip
change b
branch: default
commit: (clean)
update: 1 new changesets, 2 branch heads (merge)
phases: 5 draft
Modified subrepo files are noticed by `update --check` and `summary`
$ echo mod > subrepo/b
$ hg st -S
M subrepo/b
$ hg up -r '.^' --check
abort: uncommitted changes in subrepository "subrepo"
[255]
$ hg sum
parent: 4:9bfe45a197d7 tip
change b
branch: default
commit: 1 subrepos
update: 1 new changesets, 2 branch heads (merge)
phases: 5 draft
TODO: why is -R needed here? If it's because the subrepo is treated as a
discrete unit, then this should probably warn or something.
$ hg revert -R subrepo --no-backup subrepo/b -r .
$ rm subrepo/b
$ hg st -S
! subrepo/b
`hg update --check` notices a subrepo with a missing file, like it notices a
missing file in the top level repo.
$ hg up -r '.^' --check
abort: uncommitted changes in subrepository "subrepo"
[255]
$ hg up -r '.^' --config ui.interactive=True << EOF
> d
> EOF
file 'b' was deleted in local [working copy] but was modified in other [destination].
You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
What do you want to do? d
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
XXX: There's a difference between wdir() and '.', so there should be a status.
`hg files -S` from the top is also missing 'subrepo/b'.
$ hg st -S
$ hg st -R subrepo
$ hg files -R subrepo
[1]
$ hg files -R subrepo -r '.'
subrepo/b
$ hg bookmark -r tip @other
$ echo xyz > subrepo/c
$ hg ci -SAm 'add c'
adding subrepo/c
committing subrepository subrepo
created new head
$ rm subrepo/c
Merge sees deleted subrepo files as an uncommitted change
$ hg merge @other
abort: uncommitted changes in subrepository "subrepo"
[255]