diff options
author | Shawn O. Pearce <sop@google.com> | 2009-03-03 17:51:01 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-03-03 17:51:01 -0800 |
commit | 44469464d2e4ddbb217f92e962ff85dfd736772e (patch) | |
tree | d699677e5583ee7b193f1c868bba43285fcbe61f | |
parent | c95583bf4f17b8467f815b6391ffc6c7add08804 (diff) | |
download | git-repo-44469464d2e4ddbb217f92e962ff85dfd736772e.tar.gz |
Allow repo forall -c on a mirror by using GIT_DIR as pwd
We can permit a forall on a mirror, but only if we put
the command into the git repository.
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r-- | subcmds/forall.py | 16 |
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 | |||
17 | import os | 17 | import os |
18 | import sys | 18 | import sys |
19 | import subprocess | 19 | import subprocess |
20 | from command import Command | 20 | from command import Command, MirrorSafeCommand |
21 | 21 | ||
22 | class Forall(Command): | 22 | class 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 | ||
31 | Environment | 31 | Environment |
32 | ----------- | 32 | ----------- |
33 | pwd is the project's working directory. | 33 | pwd is the project's working directory. If the current client is |
34 | a mirror client, then pwd is the Git repository. | ||
34 | 35 | ||
35 | REPO_PROJECT is set to the unique name of the project. | 36 | REPO_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() |