summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--subcmds/forall.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py
index acbf18bc..bc0d455d 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -17,9 +17,9 @@ import re
17import os 17import os
18import sys 18import sys
19import subprocess 19import subprocess
20from command import Command 20from command import Command, MirrorSafeCommand
21 21
22class Forall(Command): 22class Forall(Command, MirrorSafeCommand):
23 common = False 23 common = False
24 helpSummary = "Run a shell command in each project" 24 helpSummary = "Run a shell command in each project"
25 helpUsage = """ 25 helpUsage = """
@@ -30,7 +30,8 @@ Executes the same shell command in each project.
30 30
31Environment 31Environment
32----------- 32-----------
33pwd is the project's working directory. 33pwd is the project's working directory. If the current client is
34a mirror client, then pwd is the Git repository.
34 35
35REPO_PROJECT is set to the unique name of the project. 36REPO_PROJECT is set to the unique name of the project.
36 37
@@ -77,6 +78,7 @@ not redirected.
77 cmd.append(cmd[0]) 78 cmd.append(cmd[0])
78 cmd.extend(opt.command[1:]) 79 cmd.extend(opt.command[1:])
79 80
81 mirror = self.manifest.IsMirror
80 rc = 0 82 rc = 0
81 for project in self.GetProjects(args): 83 for project in self.GetProjects(args):
82 env = dict(os.environ.iteritems()) 84 env = dict(os.environ.iteritems())
@@ -88,8 +90,14 @@ not redirected.
88 .ToLocal(project.revision) 90 .ToLocal(project.revision)
89 env['REPO_RREV'] = project.revision 91 env['REPO_RREV'] = project.revision
90 92
93 if mirror:
94 env['GIT_DIR'] = project.gitdir
95 cwd = project.gitdir
96 else:
97 cwd = project.worktree
98
91 p = subprocess.Popen(cmd, 99 p = subprocess.Popen(cmd,
92 cwd = project.worktree, 100 cwd = cwd,
93 shell = shell, 101 shell = shell,
94 env = env) 102 env = env)
95 r = p.wait() 103 r = p.wait()