From 05d593c088d335e86573a2d4bc63ff308bde759b Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Wed, 24 Aug 2005 14:52:43 +0100 Subject: [PATCH] Fix push --undo to remove the local changes Without this patch, the command would fail if there are local changes because of git-read-tree -m -u. Signed-off-by: Catalin Marinas --- stgit/git.py | 16 ++++++++++++++++ stgit/stack.py | 1 + 2 files changed, 17 insertions(+) diff --git a/stgit/git.py b/stgit/git.py index fb75a85..5abe902 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -434,6 +434,22 @@ def switch(tree_id): __set_head(tree_id) +def reset(tree_id = None): + """Revert the tree changes relative to the given tree_id. It removes + any local changes + """ + if not tree_id: + tree_id = get_head() + + cache_files = __tree_status(tree_id = tree_id) + rm_files = [x[1] for x in cache_files if x[0] in ['D']] + + checkout(tree_id = tree_id, force = True) + __set_head(tree_id) + + # checkout doesn't remove files + map(os.remove, rm_files) + def pull(location, head = None, tag = None): """Fetch changes from the remote repository. At the moment, just use the 'git fetch' scripts diff --git a/stgit/stack.py b/stgit/stack.py index 46d6ee5..1e68b99 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -496,6 +496,7 @@ class Series: assert(name) patch = Patch(name, self.__patch_dir) + git.reset() self.pop_patch(name) patch.restore_old_boundaries() -- 2.11.0