Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 261382
Collapse All | Expand All

(-)a/main/tags/2.2_rc23/pym/_emerge/__init__.py (-11 / +56 lines)
Lines 12093-12102 def action_sync(settings, trees, mtimedb, myopts, myaction): Link Here
12093
		print "skipping sync"
12093
		print "skipping sync"
12094
		updatecache_flg = True
12094
		updatecache_flg = True
12095
	elif sync_method == "git":
12095
	elif sync_method == "git":
12096
		# Update existing git repository, and ignore the syncuri. We are
12096
		gitmethod = settings.get("PORTAGE_GIT_METHOD", None)
12097
		# going to trust the user and assume that the user is in the branch
12097
		gitlocal = settings.get("PORTAGE_GIT_LOCAL", None)
12098
		# that he/she wants updated. We'll let the user manage branches with
12098
		gitremote = settings.get("PORTAGE_GIT_REMOTE", None)
12099
		# git directly.
12099
12100
		if portage.process.find_binary("git") is None:
12100
		if portage.process.find_binary("git") is None:
12101
			msg = ["Command not found: git",
12101
			msg = ["Command not found: git",
12102
			"Type \"emerge dev-util/git\" to enable git support."]
12102
			"Type \"emerge dev-util/git\" to enable git support."]
Lines 12104-12120 def action_sync(settings, trees, mtimedb, myopts, myaction): Link Here
12104
				writemsg_level("!!! %s\n" % l,
12104
				writemsg_level("!!! %s\n" % l,
12105
					level=logging.ERROR, noiselevel=-1)
12105
					level=logging.ERROR, noiselevel=-1)
12106
			return 1
12106
			return 1
12107
		msg = ">>> Starting git pull in %s..." % myportdir
12107
12108
		emergelog(xterm_titles, msg )
12108
		if not os.path.exists( myportdir + "/.git"):
12109
		writemsg_level(msg + "\n")
12109
			msg = ">>> Starting git clone in %s..." % myportdir
12110
		exitcode = portage.process.spawn_bash("cd %s ; git pull" % \
12110
			emergelog(xterm_titles, msg )
12111
			(portage._shell_quote(myportdir),), **spawn_kwargs)
12111
			# go through the process of cloning git manually as git is unable 
12112
			# to clone into existing directories
12113
			exitcode = portage.process.spawn_bash("cd %s ; \
12114
				git init ; git remote add origin %s ; git fetch ; \
12115
				git checkout %s -b %s ;" % (
12116
				portage._shell_quote(myportdir),
12117
				portage._shell_quote(syncuri),
12118
				portage._shell_quote(gitremote),
12119
				portage._shell_quote(gitlocal),
12120
				), **spawn_kwargs)
12121
		else:
12122
			# fetch all remotes
12123
			exitcode = portage.process.spawn_bash(
12124
				"cd %s ; git remote update ;" % ( 
12125
				portage._shell_quote(myportdir),
12126
				), **spawn_kwargs )
12127
			if gitmethod == "merge":
12128
				msg = ">>> Starting git merge in %s..." % myportdir
12129
				emergelog(xterm_titles, msg )
12130
				writemsg_level(msg + "\n")
12131
				exitcode = portage.process.spawn_bash(
12132
					"cd %s ; git checkout %s ; git merge %s ;" % (
12133
					portage._shell_quote(myportdir),
12134
					portage._shell_quote(gitlocal),
12135
					portage._shell_quote(gitremote),
12136
					), **spawn_kwargs)
12137
			elif gitmethod == "rebase":
12138
				msg = ">>> Starting git rebase in %s..." % myportdir
12139
				emergelog(xterm_titles, msg )
12140
				writemsg_level(msg + "\n")
12141
				exitcode = portage.process.spawn_bash(
12142
					"cd %s ; git checkout %s ; git rebase %s ;" % (
12143
					portage._shell_quote(myportdir),
12144
					portage._shell_quote(gitlocal),
12145
					portage._shell_quote(gitremote),
12146
					), **spawn_kwargs)
12147
			elif gitmethod == "checkout":
12148
				msg = ">>> Starting git checkout in %s..." % myportdir
12149
				emergelog(xterm_titles, msg )
12150
				writemsg_level(msg + "\n")
12151
				exitcode = portage.process.spawn_bash(
12152
					"cd %s ; git checkout %s ;" %  ( 
12153
					portage._shell_quote(myportdir), 
12154
					portage._shell_quote(gitremote),
12155
					), **spawn_kwargs)
12156
12112
		if exitcode != os.EX_OK:
12157
		if exitcode != os.EX_OK:
12113
			msg = "!!! git pull error in %s." % myportdir
12158
			msg = "!!! git error in %s." % myportdir
12114
			emergelog(xterm_titles, msg)
12159
			emergelog(xterm_titles, msg)
12115
			writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
12160
			writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
12116
			return exitcode
12161
			return exitcode
12117
		msg = ">>> Git pull in %s successful" % myportdir
12162
		msg = ">>> Git in %s successful" % myportdir
12118
		emergelog(xterm_titles, msg)
12163
		emergelog(xterm_titles, msg)
12119
		writemsg_level(msg + "\n")
12164
		writemsg_level(msg + "\n")
12120
		exitcode = git_sync_timestamps(settings, myportdir)
12165
		exitcode = git_sync_timestamps(settings, myportdir)

Return to bug 261382