[go: up one dir, main page]

repocutter: filecopy stashes every blob regardless of range restriction

The repocutter filecopy command is supposed to stash the content of node-paths for each node in the given revision range. The documentation mentions that restricting the revision range will prevent the tool from storing every blob of the repository.

However, the -r flag does not seem to have an influence on whether a node content is stashed.

Attached below is an example dump from a dummy repository, in which a file is moved around while two other files are just created:

$ repocutter see <testdump
1.1   add      file1.txt
2.1   copy     file2.txt from 1:file1.txt
2.2   delete   file1.txt
3.1   add      file3.txt
3.2   add      file4.txt
4.1   copy     file5.txt from 3:file2.txt
4.2   delete   file2.txt

test dump file: testdump

Using the debug output, one can see that the contents of file3.txt and file4.txt are stashed even when restricting the command to revisions 1 to 2:

$ repocutter -d 1 -r 1:2 -f filecopy file1.txt <testdump >/dev/null
Resolve filecopy operations on a stream....
<r0.0: filecopy investigates this revision>
<r0.0: passthrough = true>
<r1.1: filecopy investigates this revision>
<r1.1: for file1.txt, stashed content "File 1\n">
<r2.1: filecopy investigates this revision>
<r2.1: filecopy investigates file1.txt>
    <r2.1 replacement is '"File 1\n"'>
  <r2.1 replacing with "File 1\n">
<r2.1: for file1.txt, stashed content "File 1\n">
<r2.2: filecopy investigates this revision>
<r3.1: filecopy investigates this revision>
<r3.1: for file1.txt, stashed content "File 3\n">
<r3.2: filecopy investigates this revision>
<r3.2: for file1.txt, stashed content "File 4\n">
<r4.1: filecopy investigates this revision>
<r4.2: filecopy investigates this revision>
...(429.591µs) done.

I took a quick look at the code, I unfortunately don't understand much Go, but there doesn't seem to be any range check in the contenthook part of filecopy. I can also testify that on an actual repository, the entire size of the dump is loaded into memory.

I also checked that I used the -r flag correctly: if I restrict the command to revisions 3 to 4, the copy is not replaced by add, which is expected.