mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
87636f2ac2 | |||
337aee0a9c | |||
7cf1b36bcd | |||
5e57234ec6 | |||
5d016502eb | |||
475a47d531 | |||
62d0b10a7b |
@ -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)
|
||||||
|
@ -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):
|
||||||
|
27
project.py
27
project.py
@ -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:
|
||||||
|
@ -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()
|
||||||
|
@ -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
|
||||||
|
@ -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()
|
||||||
|
Reference in New Issue
Block a user