diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-12-11 20:15:16 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-12-11 20:15:16 +0000 |
commit | ba797c11c5a510758b6bf6fab03d511ac32d9041 (patch) | |
tree | 6528758ca1b97ddcf2b470459dc559a344337211 | |
parent | 094530a98c556ceee76ef9c7243e45e40ff16d26 (diff) | |
download | portage-ba797c11c5a510758b6bf6fab03d511ac32d9041.tar.gz portage-ba797c11c5a510758b6bf6fab03d511ac32d9041.tar.bz2 portage-ba797c11c5a510758b6bf6fab03d511ac32d9041.zip |
Add --sync support for `git pull`, and also add a failsafe to prevent rsync
from being called if $PORTDIR appears to be under revision control. Thanks
to Daniel Robbins for the initial patch.
svn path=/main/trunk/; revision=12205
-rw-r--r-- | pym/_emerge/__init__.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index de3ab6279..788b30e25 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -11736,12 +11736,39 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): noiselevel=-1, level=logging.ERROR) return 1 + vcs_dirs = frozenset([".git", ".svn", "CVS", ".hg"]) + vcs_dirs = vcs_dirs.intersection(os.listdir(myportdir)) + os.umask(0022) updatecache_flg = False if myaction == "metadata": print "skipping sync" updatecache_flg = True + elif ".git" in vcs_dirs: + # Update existing git repository, and ignore the syncuri. We are + # going to trust the user and assume that the user is in the branch + # that he/she wants updated. We'll let the user manage branches with + # git directly. + msg = ">>> Starting git pull in %s..." % myportdir + emergelog(xterm_titles, msg ) + writemsg_level(msg + "\n") + exitcode = portage.spawn("cd %s ; git pull" % \ + (portage._shell_quote(myportdir),), settings, free=1) + if exitcode != os.EX_OK: + msg = "!!! git pull error in %s." % myportdir + emergelog(xterm_titles, msg) + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) + return exitcode + msg = ">>> Git pull in %s successful" % myportdir + emergelog(xterm_titles, msg) + writemsg_level(msg + "\n") + return exitcode elif syncuri[:8]=="rsync://": + for vcs_dir in vcs_dirs: + writemsg_level(("!!! %s appears to be under revision " + \ + "control (contains %s).\n!!! Aborting rsync sync.\n") % \ + (myportdir, vcs_dir), level=logging.ERROR, noiselevel=-1) + return 1 if not os.path.exists("/usr/bin/rsync"): print "!!! /usr/bin/rsync does not exist, so rsync support is disabled." print "!!! Type \"emerge net-misc/rsync\" to enable rsync support." |