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
#testcases flat tree
$ . "$TESTDIR/narrow-library.sh"
#if tree
$ cat << EOF >> $HGRCPATH
> [experimental]
> treemanifest = 1
> EOF
#endif
create full repo
$ hg init master
$ cd master
$ cat >> .hg/hgrc <<EOF
> [narrow]
> serveellipses=True
> EOF
$ mkdir inside
$ echo inside1 > inside/f1
$ echo inside2 > inside/f2
$ mkdir outside
$ echo outside1 > outside/f1
$ echo outside2 > outside/f2
$ hg ci -Aqm 'initial'
$ echo modified > inside/f1
$ hg ci -qm 'modify inside/f1'
$ hg update -q 0
$ echo modified > inside/f2
$ hg ci -qm 'modify inside/f2'
$ hg update -q 0
$ echo modified2 > inside/f1
$ hg ci -qm 'conflicting inside/f1'
$ hg update -q 0
$ echo modified > outside/f1
$ hg ci -qm 'modify outside/f1'
$ hg update -q 0
$ echo modified2 > outside/f1
$ hg ci -qm 'conflicting outside/f1'
$ cd ..
$ hg clone --narrow ssh://user@dummy/master narrow --include inside
requesting all changes
adding changesets
adding manifests
adding file changes
added 6 changesets with 5 changes to 2 files (+4 heads)
new changesets *:* (glob)
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd narrow
$ hg update -q 0
Can merge in when no files outside narrow spec are involved
$ hg update -q 'desc("modify inside/f1")'
$ hg merge 'desc("modify inside/f2")'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg commit -m 'merge inside changes'
Can merge conflicting changes inside narrow spec
$ hg update -q 'desc("modify inside/f1")'
$ hg merge 'desc("conflicting inside/f1")' 2>&1 | egrep -v '(warning:|incomplete!)'
merging inside/f1
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
$ echo modified3 > inside/f1
$ hg resolve -m
(no more unresolved files)
$ hg commit -m 'merge inside/f1'
TODO: Can merge non-conflicting changes outside narrow spec
$ hg update -q 'desc("modify inside/f1")'
$ hg merge 'desc("modify outside/f1")'
abort: merge affects file 'outside/f1' outside narrow, which is not yet supported (flat !)
abort: merge affects file 'outside/' outside narrow, which is not yet supported (tree !)
(merging in the other direction may work)
[255]
$ hg update -q 'desc("modify outside/f1")'
$ hg merge 'desc("modify inside/f1")'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m 'merge from inside to outside'
Refuses merge of conflicting outside changes
$ hg update -q 'desc("modify outside/f1")'
$ hg merge 'desc("conflicting outside/f1")'
abort: conflict in file 'outside/f1' is outside narrow clone (flat !)
abort: conflict in file 'outside/' is outside narrow clone (tree !)
[255]