From a5b29a1c486dc8f6b3080356296dfed25c210a74 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Tue, 23 Aug 2005 13:41:41 +0100 Subject: [PATCH] Optimise the git.switch() function By default it checks the tree status and checks out the given tree id. This can be done with 'git-read-tree -m old new'. Signed-off-by: Catalin Marinas --- stgit/git.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/stgit/git.py b/stgit/git.py index c1c20c7..ae29eb8 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -452,16 +452,11 @@ def checkout(files = [], tree_id = None, force = False): def switch(tree_id): """Switch the tree to the given id """ - to_delete = filter(lambda x: x[0] in ['N', 'A'], - __tree_status(tree_id = tree_id)) + if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0: + raise GitException, 'git-read-tree failed (local changes maybe?)' - checkout(tree_id = tree_id, force = True) __set_head(tree_id) - # checkout doesn't remove files - for fs in to_delete: - os.remove(fs[1]) - def pull(location, head = None, tag = None): """Fetch changes from the remote repository. At the moment, just use the 'git fetch' scripts -- 2.11.0