Merge "GITC: Add gitc-init subcommand to repo."
diff --git a/command.py b/command.py
index 207ef46..38cacd3 100644
--- a/command.py
+++ b/command.py
@@ -126,7 +126,7 @@
pass
return project
- def GetProjects(self, args, missing_ok=False, submodules_ok=False):
+ def GetProjects(self, args, groups='', missing_ok=False, submodules_ok=False):
"""A list of projects that match the arguments.
"""
all_projects_list = self.manifest.projects
@@ -134,7 +134,8 @@
mp = self.manifest.manifestProject
- groups = mp.config.GetString('manifest.groups')
+ if not groups:
+ groups = mp.config.GetString('manifest.groups')
if not groups:
groups = 'default,platform-' + platform.system().lower()
groups = [x for x in re.split(r'[,\s]+', groups) if x]
diff --git a/manifest_xml.py b/manifest_xml.py
index 130e17c..7e71960 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -202,6 +202,9 @@
if d.revisionExpr:
have_default = True
e.setAttribute('revision', d.revisionExpr)
+ if d.destBranchExpr:
+ have_default = True
+ e.setAttribute('dest-branch', d.destBranchExpr)
if d.sync_j > 1:
have_default = True
e.setAttribute('sync-j', '%d' % d.sync_j)
@@ -267,6 +270,9 @@
if p.upstream and p.upstream != p.revisionExpr:
e.setAttribute('upstream', p.upstream)
+ if p.dest_branch and p.dest_branch != d.destBranchExpr:
+ e.setAttribute('dest-branch', p.dest_branch)
+
for c in p.copyfiles:
ce = doc.createElement('copyfile')
ce.setAttribute('src', c.src)
diff --git a/project.py b/project.py
index 868425c..a117f4d 100644
--- a/project.py
+++ b/project.py
@@ -1877,6 +1877,13 @@
if depth:
cmd.append('--depth=%s' % depth)
+ else:
+ # If this repo has shallow objects, then we don't know which refs have
+ # shallow objects or not. Tell git to unshallow all fetched refs. Don't
+ # do this with projects that don't have shallow objects, since it is less
+ # efficient.
+ if os.path.exists(os.path.join(self.gitdir, 'shallow')):
+ cmd.append('--depth=2147483647')
if quiet:
cmd.append('--quiet')
@@ -1914,16 +1921,6 @@
spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch)))
cmd.extend(spec)
- shallowfetch = self.config.GetString('repo.shallowfetch')
- if shallowfetch and shallowfetch != ' '.join(spec):
- GitCommand(self, ['fetch', '--depth=2147483647', name]
- + shallowfetch.split(),
- bare=True, ssh_proxy=ssh_proxy).Wait()
- if depth:
- self.config.SetString('repo.shallowfetch', ' '.join(spec))
- else:
- self.config.SetString('repo.shallowfetch', None)
-
ok = False
for _i in range(2):
gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy)
@@ -2347,10 +2344,11 @@
if copy_all:
to_copy = os.listdir(gitdir)
+ dotgit = os.path.realpath(dotgit)
for name in set(to_copy).union(to_symlink):
try:
src = os.path.realpath(os.path.join(gitdir, name))
- dst = os.path.realpath(os.path.join(dotgit, name))
+ dst = os.path.join(dotgit, name)
if os.path.lexists(dst):
continue
diff --git a/subcmds/forall.py b/subcmds/forall.py
index b93cd6d..96dc99d 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -120,6 +120,9 @@
p.add_option('-r', '--regex',
dest='regex', action='store_true',
help="Execute the command only on projects matching regex or wildcard expression")
+ p.add_option('-g', '--groups',
+ dest='groups',
+ help="Execute the command only on projects matching the specified groups")
p.add_option('-c', '--command',
help='Command (and arguments) to execute',
dest='command',
@@ -213,7 +216,7 @@
self.manifest.Override(smart_sync_manifest_path)
if not opt.regex:
- projects = self.GetProjects(args)
+ projects = self.GetProjects(args, groups=opt.groups)
else:
projects = self.FindProjects(args)
diff --git a/subcmds/list.py b/subcmds/list.py
index 945c28d..ca51c5f 100644
--- a/subcmds/list.py
+++ b/subcmds/list.py
@@ -35,6 +35,9 @@
p.add_option('-r', '--regex',
dest='regex', action='store_true',
help="Filter the project list based on regex or wildcard matching of strings")
+ p.add_option('-g', '--groups',
+ dest='groups',
+ help="Filter the project list based on the groups the project is in")
p.add_option('-f', '--fullpath',
dest='fullpath', action='store_true',
help="Display the full work tree path instead of the relative path")
@@ -62,7 +65,7 @@
sys.exit(1)
if not opt.regex:
- projects = self.GetProjects(args)
+ projects = self.GetProjects(args, groups=opt.groups)
else:
projects = self.FindProjects(args)
diff --git a/subcmds/sync.py b/subcmds/sync.py
index a8074a4..43d450b 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -314,7 +314,9 @@
pm.update()
except _FetchError:
err_event.set()
- except:
+ except Exception as e:
+ print('error: Cannot fetch %s (%s: %s)' \
+ % (project.name, type(e).__name__, str(e)), file=sys.stderr)
err_event.set()
raise
finally: