mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
82cd0ac475
Summary: Running `hg log --traceback --template '{file_copies}' -r XXXX` on a file with long history is slow for 2 reasons - p4 fast importer preserves full history for deleted and re-added files - p4 fast importer records the wrong parent of a file This diff tries to fix these two issues. In mercurial, if a file is added, deleted, and then added back, it should start a new file history when the file is added again. For example, commits commit1 commit2 commit3 actions add a.txt delete a.txt add a.txt timeline ------------X------------X------------------------X------------ `hg debugindex a.txt` at commit3 shows a.txt as a new file without previous history rev offset length delta linkrev nodeid p1 p2 0 0 3 -1 0 b789fdd96dc2 000000000000 000000000000 However, this is different in p4. `p4 filelog test.txt` gives you //depot/Software/Apps/Main/Native/.castle/test.txt ... #3 change 523261 add on 2018/01/23 by zhihuih@devbig415 (text) 'test:add-again-same-file' ... #2 change 523254 delete on 2018/01/23 by zhihuih@devbig415 (text) 'testfile:delete' ... #1 change 523253 add on 2018/01/23 by zhihuih@devbig415 (text) 'testfile:add' Currently, p4 fast importer preserves history the same way as p4, and this causes slowness (even timeout) in hg when it runs `hg log --traceback --template '{file_copies}' -r XXXX` on a revision that contains files with long history in p4 (mostly contributed by automation). To mitigate this, we want the p4 fast importer to behave the same way as hg, and starts a new history for a file that's added again. Currently, p4 fast importer takes the tip of a filelog and treats that as the parent of the newly written entry diffusion/FBS/browse/master/fbcode/scm/hg/hgext/p4fastimport/importer.py;19ad9b05f50e3ff0265cdc7b4b45174dcf820343$468-469. This can be wrong when there are revisions from branches. For example, if I edit file a in master in CL1, 2, 4, and I branch at CL3, and edit the file in branch in CL5, the current importer implementation will take filenode at CL4 as the parent of CL3 (CL1,2,3,4,5 corresponds to rev0,1,3,2,4) {F120393661} However, the correct behavior is to take filenode at CL2 as the parent of CL3 (CL1,2,3,4,5 corresponds to rev0,1,3,2,4) {F120393662} (This is also the example I use in `test-fb-hgext-p4fastimport-import-branch-filelogorder.t`, so if the description here looks confusing, please refer to the test) Reviewed By: dsp Differential Revision: D6962019 fbshipit-source-id: 24de76ae009e0d6f976d247087fe4702c99e0f82
98 lines
3.0 KiB
Raku
98 lines
3.0 KiB
Raku
#require p4
|
|
|
|
$ . $TESTDIR/p4setup.sh
|
|
|
|
populate the depot
|
|
$ mkdir Main
|
|
$ mkdir Main/b
|
|
$ echo a > Main/a
|
|
$ echo c > Main/b/c
|
|
$ echo d > Main/d
|
|
$ p4 add Main/a Main/b/c Main/d
|
|
//depot/Main/a#1 - opened for add
|
|
//depot/Main/b/c#1 - opened for add
|
|
//depot/Main/d#1 - opened for add
|
|
$ p4 submit -d initial
|
|
Submitting change 1.
|
|
Locking 3 files ...
|
|
add //depot/Main/a#1
|
|
add //depot/Main/b/c#1
|
|
add //depot/Main/d#1
|
|
Change 1 submitted.
|
|
|
|
$ p4 delete Main/a
|
|
//depot/Main/a#1 - opened for delete
|
|
$ p4 submit -d second
|
|
Submitting change 2.
|
|
Locking 1 files ...
|
|
delete //depot/Main/a#2
|
|
Change 2 submitted.
|
|
|
|
$ echo a > Main/a
|
|
$ p4 add Main/a
|
|
//depot/Main/a#2 - opened for add
|
|
$ p4 submit -d third
|
|
Submitting change 3.
|
|
Locking 1 files ...
|
|
add //depot/Main/a#3
|
|
Change 3 submitted.
|
|
|
|
Simple import
|
|
|
|
$ cd $hgwd
|
|
$ hg init --config 'format.usefncache=False'
|
|
$ hg p4fastimport --debug -P $P4ROOT hg-p4-import
|
|
loading changelist numbers.
|
|
3 changelists to import.
|
|
loading list of files.
|
|
3 files to import.
|
|
reading filelog * (glob)
|
|
reading filelog * (glob)
|
|
reading filelog * (glob)
|
|
importing repository.
|
|
writing filelog: b789fdd96dc2, p1 000000000000, linkrev 0, 2 bytes, src: *, path: Main/a (glob)
|
|
writing filelog: b789fdd96dc2, p1 000000000000, linkrev 2, 2 bytes, src: *, path: Main/a (glob)
|
|
writing filelog: 149da44f2a4e, p1 000000000000, linkrev 0, 2 bytes, src: *, path: Main/b/c (glob)
|
|
writing filelog: a9092a3d84a3, p1 000000000000, linkrev 0, 2 bytes, src: *, path: Main/d (glob)
|
|
changelist 1: writing manifest. node: * p1: 000000000000 p2: 000000000000 linkrev: 0 (glob)
|
|
changelist 1: writing changelog: initial
|
|
changelist 2: writing manifest. node: * p1: * p2: 000000000000 linkrev: 1 (glob)
|
|
updating the branch cache (?)
|
|
changelist 2: writing changelog: second
|
|
changelist 3: writing manifest. node: * p1: * p2: 000000000000 linkrev: 2 (glob)
|
|
changelist 3: writing changelog: third
|
|
updating the branch cache
|
|
3 revision(s), 3 file(s) imported.
|
|
|
|
Verify
|
|
|
|
$ hg verify
|
|
checking changesets
|
|
checking manifests
|
|
crosschecking files in changesets and manifests
|
|
checking files
|
|
3 files, 3 changesets, 3 total revisions
|
|
|
|
$ hg update tip
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
Check hg debug data
|
|
$ hg debugdata -m 0
|
|
Main/a\x00b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 (esc)
|
|
Main/b/c\x00149da44f2a4e14f488b7bd4157945a9837408c00 (esc)
|
|
Main/d\x00a9092a3d84a37b9993b5c73576f6de29b7ea50f6 (esc)
|
|
$ hg debugdata -m 1
|
|
Main/b/c\x00149da44f2a4e14f488b7bd4157945a9837408c00 (esc)
|
|
Main/d\x00a9092a3d84a37b9993b5c73576f6de29b7ea50f6 (esc)
|
|
$ hg debugdata -m 2
|
|
Main/a\x00b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 (esc)
|
|
Main/b/c\x00149da44f2a4e14f488b7bd4157945a9837408c00 (esc)
|
|
Main/d\x00a9092a3d84a37b9993b5c73576f6de29b7ea50f6 (esc)
|
|
$ hg debugindex Main/a
|
|
rev offset length delta linkrev nodeid p1 p2
|
|
0 0 3 -1 0 b789fdd96dc2 000000000000 000000000000
|
|
|
|
End Test
|
|
|
|
stopping the p4 server
|