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
test merging things outside of the sparse checkout
$ hg init myrepo
$ cd myrepo
$ cat > .hg/hgrc <<EOF
> [extensions]
> sparse=
> EOF
$ echo foo > foo
$ echo bar > bar
$ hg add foo bar
$ hg commit -m initial
$ hg branch feature
marked working directory as branch feature
(branches are permanent and global, did you want a bookmark?)
$ echo bar2 >> bar
$ hg commit -m 'feature - bar2'
$ hg update -q default
$ hg debugsparse --exclude 'bar**'
$ hg merge feature
temporarily included 1 file(s) in the sparse checkout for merging
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
Verify bar was merged temporarily
$ ls
bar
foo
$ hg status
M bar
Verify bar disappears automatically when the working copy becomes clean
$ hg commit -m "merged"
cleaned up 1 temporarily added file(s) from the sparse checkout
$ hg status
$ ls
foo
$ hg cat -r . bar
bar
bar2
Test merging things outside of the sparse checkout that are not in the working
copy
$ hg strip -q -r . --config extensions.strip=
$ hg up -q feature
$ touch branchonly
$ hg ci -Aqm 'add branchonly'
$ hg up -q default
$ hg debugsparse -X branchonly
$ hg merge feature
temporarily included 2 file(s) in the sparse checkout for merging
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cd ..
Tests merging a file which is modified in one branch and deleted in another and
file is excluded from sparse checkout
$ hg init ytest
$ cd ytest
$ echo "syntax: glob" >> .hgignore
$ echo "*.orig" >> .hgignore
$ hg ci -Aqm "added .hgignore"
$ for ch in a d; do echo foo > $ch; hg ci -Aqm "added "$ch; done;
$ cat >> .hg/hgrc <<EOF
> [alias]
> glog = log -GT "{rev}:{node|short} {desc}"
> [extensions]
> sparse =
> EOF
$ hg glog
@ 2:f29feff37cfc added d
|
o 1:617125d27d6b added a
|
o 0:53f3774ed939 added .hgignore
$ hg rm d
$ hg ci -m "removed d"
$ hg up '.^'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg debugsparse --reset
$ echo bar >> d
$ hg ci -Am "added bar to d"
created new head
$ hg glog
@ 4:6527874a90e4 added bar to d
|
| o 3:372c8558de45 removed d
|/
o 2:f29feff37cfc added d
|
o 1:617125d27d6b added a
|
o 0:53f3774ed939 added .hgignore
$ hg debugsparse --exclude "d"
$ ls
a
$ hg merge
temporarily included 1 file(s) in the sparse checkout for merging
file 'd' was deleted in other [merge rev] but was modified in local [working copy].
You can use (c)hanged version, (d)elete, or leave (u)nresolved.
What do you want to do? u
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
[1]
$ cd ..
Testing merging of a file which is renamed+modified on one side and modified on
another
$ hg init mvtest
$ cd mvtest
$ echo "syntax: glob" >> .hgignore
$ echo "*.orig" >> .hgignore
$ hg ci -Aqm "added .hgignore"
$ for ch in a d; do echo foo > $ch; hg ci -Aqm "added "$ch; done;
$ cat >> .hg/hgrc <<EOF
> [alias]
> glog = log -GT "{rev}:{node|short} {desc}"
> [extensions]
> sparse =
> EOF
$ hg glog
@ 2:f29feff37cfc added d
|
o 1:617125d27d6b added a
|
o 0:53f3774ed939 added .hgignore
$ echo babar >> a
$ hg ci -m "added babar to a"
$ hg up '.^'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg mv a amove
$ hg ci -m "moved a to amove"
created new head
$ hg up 3
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg glog
o 4:5d1e85955f6d moved a to amove
|
| @ 3:a06e41a6c16c added babar to a
|/
o 2:f29feff37cfc added d
|
o 1:617125d27d6b added a
|
o 0:53f3774ed939 added .hgignore
$ hg debugsparse --exclude "a"
$ ls
d
$ hg merge
temporarily included 1 file(s) in the sparse checkout for merging
merging a and amove to amove
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg up -C 4
cleaned up 1 temporarily added file(s) from the sparse checkout
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg merge
merging amove and a to amove
abort: cannot add 'a' - it is outside the sparse checkout
(include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding)
[255]