1
0
mirror of https://github.com/git/git.git synced 2024-09-28 08:49:45 +02:00
git/vcs-svn
Jonathan Nieder 9d2f5ddfe5 vcs-svn: learn to maintain a sliding view of a file
Each section of a Subversion-format delta only requires examining (and
keeping in random-access memory) a small portion of the preimage.  At
any moment, this portion starts at a certain file offset and has a
well-defined length, and as the delta is applied, the portion advances
from the beginning to the end of the preimage.  Add a move_window
function to keep track of this view into the preimage.

You can use it like this:

	buffer_init(f, NULL);
	struct sliding_view window = SLIDING_VIEW_INIT(f);
	move_window(&window, 3, 7);	/* (1) */
	move_window(&window, 5, 5);	/* (2) */
	move_window(&window, 12, 2);	/* (3) */
	strbuf_release(&window.buf);
	buffer_deinit(f);

The data structure is called sliding_view instead of _window to
prevent confusion with svndiff0 Windows.

In this example, (1) reads 10 bytes and discards the first 3;
(2) discards the first 2, which are not needed any more; and (3) skips
2 bytes and reads 2 new bytes to work with.

When move_window returns, the file position indicator is at position
window->off + window->width and the data from positions window->off to
the current file position are stored in window->buf.

This function performs only sequential access from the input file and
never seeks, so it can be safely used on pipes and sockets.

On end-of-file, move_window silently reads less than the caller
requested.  On other errors, it prints a message and returns -1.

Helped-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2011-03-27 20:23:32 -05:00
..
fast_export.c vcs-svn: add missing cast to printf argument 2011-03-27 12:21:12 -05:00
fast_export.h vcs-svn: handle log message with embedded NUL 2011-03-26 00:49:37 -05:00
LICENSE vcs-svn: learn to maintain a sliding view of a file 2011-03-27 20:23:32 -05:00
line_buffer.c
line_buffer.h
line_buffer.txt
obj_pool.h
repo_tree.c vcs-svn: handle log message with embedded NUL 2011-03-26 00:49:37 -05:00
repo_tree.h vcs-svn: handle log message with embedded NUL 2011-03-26 00:49:37 -05:00
sliding_window.c vcs-svn: learn to maintain a sliding view of a file 2011-03-27 20:23:32 -05:00
sliding_window.h vcs-svn: learn to maintain a sliding view of a file 2011-03-27 20:23:32 -05:00
string_pool.c
string_pool.h
string_pool.txt
svndump.c vcs-svn: handle log message with embedded NUL 2011-03-26 00:49:37 -05:00
svndump.h
trp.h
trp.txt