+ 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
+ """
+ args = [location]
+ if head:
+ args += [head]
+ elif tag:
+ args += ['tag', tag]
+
+ if __run('git pull', args) != 0:
+ raise GitException, 'Failed "git fetch %s"' % location
+
+def apply_patch(filename = None):
+ """Apply a patch onto the current index. There must not be any
+ local changes in the tree, otherwise the command fails
+ """
+ os.system('git-update-cache --refresh > /dev/null')
+
+ if filename:
+ if __run('git-apply --index', [filename]) != 0:
+ raise GitException, 'Patch does not apply cleanly'
+ else:
+ _input('git-apply --index', sys.stdin)
+
+def clone(repository, local_dir):
+ """Clone a remote repository. At the moment, just use the
+ 'git clone' script
+ """
+ if __run('git clone', [repository, local_dir]) != 0:
+ raise GitException, 'Failed "git clone %s %s"' \
+ % (repository, local_dir)