From c083f3d0b853e723d0d4b00ff2f1ec5f65f05cba Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 10 May 2010 22:04:40 +0200 Subject: index.add: added index path rewrite functionality, which allows to store a different path in the index than the actual one on disk ( from which the object will be created ) Fixed bug the way newlines were handled, which hopefully fixes occasional hangs as well. It works fine with git 1.7.1 Most of the changes are due to the tab-space conversion - its weird once more as I thought it was all in spaces before ... . --- test/git/test_index.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/git/test_index.py') diff --git a/test/git/test_index.py b/test/git/test_index.py index 9eed5678..95f2b519 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -527,3 +527,33 @@ class TestIndex(TestBase): # dir into dir rval = index.move(['doc', 'test']) assert_mv_rval(rval) + + + # TEST PATH REWRITING + ###################### + count = [0] + def rewriter(entry): + rval = str(count[0]) + count[0] += 1 + return rval + # END rewriter + + def make_paths(): + # two existing ones, one new one + yield 'CHANGES' + yield 'ez_setup.py' + yield index.entries[index.get_entries_key('README', 0)] + yield index.entries[index.get_entries_key('.gitignore', 0)] + + for fid in range(3): + fname = 'newfile%i' % fid + open(fname, 'wb').write("abcd") + yield Blob(rw_repo, Blob.NULL_HEX_SHA, 0100644, fname) + # END for each new file + # END path producer + paths = list(make_paths()) + index.add(paths, path_rewriter=rewriter) + + for filenum in range(len(paths)): + assert index.get_entries_key(str(filenum), 0) in index.entries + -- cgit v1.2.3