Compare commits

..

7 Commits

Author SHA1 Message Date
87636f2ac2 Fix for failures with repo upload for projects that have a SHA1 for a revision; instead use the default manifest revision
Change-Id: Ie5ef5a45ed6b0ca1a52a550df3cd7bd72e745f5f
2012-06-14 16:54:32 -07:00
337aee0a9c Single quote http.proxy in GIT_CONFIG_PARAMETERS
Git requires the values in this environment variable to be
single quoted. repo must wrap the expression into '' before
adding it to the environment.

Change-Id: I20a1fb8772f9aa6e9fd5a0516c981c2ca020ef05
2012-06-13 10:42:16 -07:00
7cf1b36bcd Detach branch even when already on the latest revision using sync -d
This patch fixes repo behaviour when running sync -d with unmodified
topic branches.

Prior to this patch sync -d would see the latest revision is already
checked out, thus staying on the branch. Since "-d" means detach we
should follow git's behaviour and actually detach from the branch in
that case.

Basic test case - after a fresh repo init + sync -
        * repo start --all testdetach
        * repo sync -d
        * repo status
-> status shows active topic branch "testdetach",
   should show :
nothing to commit (working directory clean)

Change-Id: Ic1351e6b5721b76557a51ab09f9dd42c38a4b415
2012-06-13 10:36:17 -07:00
5e57234ec6 Support automatically stashing local modifications during repo-rebase.
Currently repo-rebase requires that all modifications be committed
locally before it will allow the rebase. In high-velocity environments,
you may want to just pull in newer code without explicitly creating
local commits, which is typically achieved using git-stash.

If called with the --auto-stash command line argument, and it is
determined that the current index is dirty, the local modifications
are stashed, and the rebase continues.  If a stash was performed, that
stash is popped once the rebase completes.

Note that there is still a possibility that the git-stash pop will
result in a merge conflict.

Change-Id: Ibe3da96f0b4486cb7ce8d040639187e26501f6af
2012-06-13 10:34:41 -07:00
5d016502eb Fix switching manifest branches using repo init -b
See repo issue #46 :
	https://code.google.com/p/git-repo/issues/detail?id=46

When using repo init -b on an already existing repository,
the next sync will try to rebase changes coming from the old manifest
branch onto the new, leading in the best case scenario to conflicts
and in the worst case scenario to an incorrect "mixed up" manifest.

This patch fixes this by deleting the "default" branch in the local
manifest repository when the -d init switch is used, thus forcing
repo to perform a fresh checkout of the new manifest branch

Change-Id: I379e4875ec5357d8614d1197b6afbe58f9606751
2012-06-13 10:00:57 -07:00
475a47d531 Restore include support.
Calculation of where the include file lives was broken by 23acdd3f14
since it resulted in looking for the first include in .repo, rather
than .repo/manifests.

While people can work around it via setting their includes to
manifests/<include-target>, that breaks down since each layer of
includes would then have to be relative.

As such, restore the behaviour back to 2644874d; manifests includes
are calculated relative to the manifest root (ie, .repo/manifests);
local manifests includes are calculated relative to .repo/ .

Change-Id: I74c19ba614c41d2f08cd3e9fd094f3c510e3bfd1
2012-06-07 20:19:04 -07:00
62d0b10a7b Use GIT_CONFIG_PARAMETERS instead of -c for http.proxy
Ancient versions of Git don't understand the -c command line flag
that we tried to use to pass http_proxy down into Git on Darwin.
Use the environment variable instead, to more gracefully degrade
with these old versions.

Change-Id: Iffffa32088c1fd803895b990b3377ecfec6a1b14
2012-06-05 15:11:15 -07:00
6 changed files with 64 additions and 11 deletions

View File

@ -147,6 +147,12 @@ class GitCommand(object):
if ssh_proxy: if ssh_proxy:
_setenv(env, 'REPO_SSH_SOCK', ssh_sock()) _setenv(env, 'REPO_SSH_SOCK', ssh_sock())
_setenv(env, 'GIT_SSH', _ssh_proxy()) _setenv(env, 'GIT_SSH', _ssh_proxy())
if 'http_proxy' in env and 'darwin' == sys.platform:
s = "'http.proxy=%s'" % (env['http_proxy'],)
p = env.get('GIT_CONFIG_PARAMETERS')
if p is not None:
s = p + ' ' + s
_setenv(env, 'GIT_CONFIG_PARAMETERS', s)
if project: if project:
if not cwd: if not cwd:
@ -155,8 +161,6 @@ class GitCommand(object):
gitdir = project.gitdir gitdir = project.gitdir
command = [GIT] command = [GIT]
if 'http_proxy' in env and 'darwin' == sys.platform:
command.extend(['-c', 'http.proxy=' + env['http_proxy']])
if bare: if bare:
if gitdir: if gitdir:
_setenv(env, GIT_DIR, gitdir) _setenv(env, GIT_DIR, gitdir)

View File

@ -283,11 +283,12 @@ class XmlManifest(object):
self.branch = b self.branch = b
nodes = [] nodes = []
nodes.append(self._ParseManifestXml(self.manifestFile)) nodes.append(self._ParseManifestXml(self.manifestFile,
self.manifestProject.worktree))
local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME)
if os.path.exists(local): if os.path.exists(local):
nodes.append(self._ParseManifestXml(local)) nodes.append(self._ParseManifestXml(local, self.repodir))
self._ParseManifest(nodes) self._ParseManifest(nodes)
@ -297,7 +298,7 @@ class XmlManifest(object):
self._loaded = True self._loaded = True
def _ParseManifestXml(self, path): def _ParseManifestXml(self, path, include_root):
root = xml.dom.minidom.parse(path) root = xml.dom.minidom.parse(path)
if not root or not root.childNodes: if not root or not root.childNodes:
raise ManifestParseError("no root node in %s" % (path,)) raise ManifestParseError("no root node in %s" % (path,))
@ -310,13 +311,13 @@ class XmlManifest(object):
for node in config.childNodes: for node in config.childNodes:
if node.nodeName == 'include': if node.nodeName == 'include':
name = self._reqatt(node, 'name') name = self._reqatt(node, 'name')
fp = os.path.join(os.path.dirname(path), name) fp = os.path.join(include_root, name)
if not os.path.isfile(fp): if not os.path.isfile(fp):
raise ManifestParseError, \ raise ManifestParseError, \
"include %s doesn't exist or isn't a file" % \ "include %s doesn't exist or isn't a file" % \
(name,) (name,)
try: try:
nodes.extend(self._ParseManifestXml(fp)) nodes.extend(self._ParseManifestXml(fp, include_root))
# should isolate this to the exact exception, but that's # should isolate this to the exact exception, but that's
# tricky. actual parsing implementation may vary. # tricky. actual parsing implementation may vary.
except (KeyboardInterrupt, RuntimeError, SystemExit): except (KeyboardInterrupt, RuntimeError, SystemExit):

View File

@ -1044,12 +1044,15 @@ class Project(object):
if head == revid: if head == revid:
# No changes; don't do anything further. # No changes; don't do anything further.
# Except if the head needs to be detached
# #
return if not syncbuf.detach_head:
return
else:
lost = self._revlist(not_rev(revid), HEAD)
if lost:
syncbuf.info(self, "discarding %d commits", len(lost))
lost = self._revlist(not_rev(revid), HEAD)
if lost:
syncbuf.info(self, "discarding %d commits", len(lost))
try: try:
self._Checkout(revid, quiet=True) self._Checkout(revid, quiet=True)
except GitError, e: except GitError, e:
@ -2167,6 +2170,22 @@ class MetaProject(Project):
self.revisionExpr = base self.revisionExpr = base
self.revisionId = None self.revisionId = None
def MetaBranchSwitch(self, target):
""" Prepare MetaProject for manifest branch switch
"""
# detach and delete manifest branch, allowing a new
# branch to take over
syncbuf = SyncBuffer(self.config, detach_head = True)
self.Sync_LocalHalf(syncbuf)
syncbuf.Finish()
return GitCommand(self,
['branch', '-D', 'default'],
capture_stdout = True,
capture_stderr = True).Wait() == 0
@property @property
def LastFetch(self): def LastFetch(self):
try: try:

View File

@ -187,6 +187,9 @@ to update the working directory files.
shutil.rmtree(m.gitdir) shutil.rmtree(m.gitdir)
sys.exit(1) sys.exit(1)
if opt.manifest_branch:
m.MetaBranchSwitch(opt.manifest_branch)
syncbuf = SyncBuffer(m.config) syncbuf = SyncBuffer(m.config)
m.Sync_LocalHalf(syncbuf) m.Sync_LocalHalf(syncbuf)
syncbuf.Finish() syncbuf.Finish()

View File

@ -52,6 +52,9 @@ branch but need to incorporate new upstream changes "underneath" them.
p.add_option('--whitespace', p.add_option('--whitespace',
dest='whitespace', action='store', metavar='WS', dest='whitespace', action='store', metavar='WS',
help='Pass --whitespace to git rebase') help='Pass --whitespace to git rebase')
p.add_option('--auto-stash',
dest='auto_stash', action='store_true',
help='Stash local modifications before starting')
def Execute(self, opt, args): def Execute(self, opt, args):
all = self.GetProjects(args) all = self.GetProjects(args)
@ -103,5 +106,23 @@ branch but need to incorporate new upstream changes "underneath" them.
print >>sys.stderr, '# %s: rebasing %s -> %s' % \ print >>sys.stderr, '# %s: rebasing %s -> %s' % \
(project.relpath, cb, upbranch.LocalMerge) (project.relpath, cb, upbranch.LocalMerge)
needs_stash = False
if opt.auto_stash:
stash_args = ["update-index", "--refresh", "-q"]
if GitCommand(project, stash_args).Wait() != 0:
needs_stash = True
# Dirty index, requires stash...
stash_args = ["stash"]
if GitCommand(project, stash_args).Wait() != 0:
return -1
if GitCommand(project, args).Wait() != 0: if GitCommand(project, args).Wait() != 0:
return -1 return -1
if needs_stash:
stash_args.append('pop')
stash_args.append('--quiet')
if GitCommand(project, stash_args).Wait() != 0:
return -1

View File

@ -15,6 +15,7 @@
import sys import sys
from command import Command from command import Command
from git_config import IsId
from git_command import git from git_command import git
from progress import Progress from progress import Progress
@ -56,6 +57,10 @@ revision specified in the manifest.
pm = Progress('Starting %s' % nb, len(all)) pm = Progress('Starting %s' % nb, len(all))
for project in all: for project in all:
pm.update() pm.update()
# If the current revision is a specific SHA1 then we can't push back
# to it so substitute the manifest default revision instead.
if IsId(project.revisionExpr):
project.revisionExpr = self.manifest.default.revisionExpr
if not project.StartBranch(nb): if not project.StartBranch(nb):
err.append(project) err.append(project)
pm.end() pm.end()