From ba42541c45596435812de4bd1e9fba3a9fe9b82b Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 4 Aug 2010 02:01:01 +0200 Subject: refactoring initial-merge --- src/pyfedpkg/initial_merge.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/pyfedpkg/initial_merge.py') diff --git a/src/pyfedpkg/initial_merge.py b/src/pyfedpkg/initial_merge.py index 22134ad..8a3cf6d 100755 --- a/src/pyfedpkg/initial_merge.py +++ b/src/pyfedpkg/initial_merge.py @@ -1,7 +1,7 @@ #!/usr/bin/python -"""initial-merge.py - perform initial merge after dist-git migration +"""initial_merge.py - perform initial merge after dist-git migration -initial-merge.py performs a merge of all git branches with the same +initial_merge.py performs a merge of all git branches with the same content in the directory tree, i.e. with the same packages. This is useful after Fedora's dist-cvs to dist-git migration, as often @@ -11,8 +11,9 @@ filesystem. After these merges, future merges between the branches will be a lot easier. -Note that this is a standalone script which calls fedpkg via subprocess.Popen, -as fedpkg has a bunch of issues with changing CWD. +Note that this also works as a standalone script which calls fedpkg +via subprocess.Popen, as fedpkg has a bunch of issues with changing +CWD. """ import sys @@ -127,8 +128,7 @@ class Consumer: self.__flush() -def handle_directory(): - +def handle_curdir(): git_branch_cmd = """for branch in $(git branch -r | grep -v '/HEAD'); do echo "$(git rev-parse "$branch^{tree}") $branch"; done""" retcode, stdout, stderr = run_cmd_out(git_branch_cmd, dry_run=False, shell=True) @@ -155,17 +155,23 @@ def handle_directory(): print "FINISHED." +def handle_path(path=None): + if not path: + path = os.getcwd() + oldcwd = os.getcwd() + os.chdir(d) + print "########", "Entering", d, "########" + handle_curdir() + print "Leaving", os.getcwd() + os.chdir(oldcwd) + + def main(args): if args: for d in args: - oldcwd = os.getcwd() - os.chdir(d) - print "########", "Entering", d, "########" - handle_directory() - print "Leaving", os.getcwd() - os.chdir(oldcwd) + handle_path(d) else: - handle_directory() + handle_curdir() if __name__ == '__main__': -- cgit