Skip to content

Commit 2d50ed8

Browse files
authored
Revert "Pytorch allow patching which submodule rev is checked out" (#1196)
Reverts #1092 This breaks 'base' patches by incorrectly applying the `THEROCK_UPSTREAM_DIFFBASE` tag, see #1092 (comment). When I run what should be a no-op: ``` python pytorch_torch_repo.py checkout python pytorch_torch_repo.py save-patches ``` instead I get this diff, which deletes all the 'base/' patches: ScottTodd@7718788. We could also fix forward, but I haven't received a response on the PR after 2 weeks and this has bit me a few times since reporting the issue.
1 parent 4b31640 commit 2d50ed8

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

external-builds/pytorch/repo_management.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -171,33 +171,19 @@ def apply_repo_patches(repo_path: Path, patches_path: Path):
171171
)
172172

173173

174-
def apply_main_repository_patches(
175-
root_repo_path: Path, patches_path: Path, repo_name: str, patchset_name: str
176-
):
177-
# Apply patches to main repository.
178-
apply_repo_patches(root_repo_path, patches_path / repo_name / patchset_name)
179-
180-
181-
def apply_submodule_patches(
174+
def apply_all_patches(
182175
root_repo_path: Path, patches_path: Path, repo_name: str, patchset_name: str
183176
):
184177
relative_sm_paths = list_submodules(root_repo_path, relative=True)
178+
# Apply base patches.
179+
apply_repo_patches(root_repo_path, patches_path / repo_name / patchset_name)
185180
for relative_sm_path in relative_sm_paths:
186181
apply_repo_patches(
187182
root_repo_path / relative_sm_path,
188183
patches_path / relative_sm_path / patchset_name,
189184
)
190185

191186

192-
def apply_all_patches(
193-
root_repo_path: Path, patches_path: Path, repo_name: str, patchset_name: str
194-
):
195-
apply_main_repository_patches(
196-
root_repo_path, patches_path, repo_name, patchset_name
197-
)
198-
apply_submodule_patches(root_repo_path, patches_path, repo_name, patchset_name)
199-
200-
201187
# repo_hashtag_to_patches_dir_name('2.7.0-rc9') -> '2.7.0'
202188
def repo_hashtag_to_patches_dir_name(version_ref: str) -> str:
203189
pos = version_ref.find("-")
@@ -266,17 +252,6 @@ def do_checkout(args: argparse.Namespace, custom_hipify=do_hipify):
266252
fetch_args.extend(["-j", str(args.jobs)])
267253
exec(["git", "fetch"] + fetch_args + ["origin", args.repo_hashtag], cwd=repo_dir)
268254
exec(["git", "checkout", "FETCH_HEAD"], cwd=repo_dir)
269-
if args.patch and patches_dir_name:
270-
# Apply base patches to main repository. Patches to
271-
# submodules will be applied later. This enables patches
272-
# to modify submodule version to be checked out.
273-
apply_main_repository_patches(
274-
repo_dir,
275-
repo_patch_dir_base / patches_dir_name,
276-
args.repo_name,
277-
"base",
278-
)
279-
280255
exec(["git", "tag", "-f", TAG_UPSTREAM_DIFFBASE, "--no-sign"], cwd=repo_dir)
281256
try:
282257
exec(
@@ -299,9 +274,9 @@ def do_checkout(args: argparse.Namespace, custom_hipify=do_hipify):
299274
)
300275
git_config_ignore_submodules(repo_dir)
301276

277+
# Base patches.
302278
if args.patch and patches_dir_name:
303-
# Apply base patches to submodules.
304-
apply_submodule_patches(
279+
apply_all_patches(
305280
repo_dir,
306281
repo_patch_dir_base / patches_dir_name,
307282
args.repo_name,
@@ -313,7 +288,7 @@ def do_checkout(args: argparse.Namespace, custom_hipify=do_hipify):
313288
custom_hipify(args)
314289
commit_hipify(args)
315290

316-
# Apply hipified patches to main repository and submodules.
291+
# Hipified patches.
317292
if args.hipify and args.patch and patches_dir_name:
318293
apply_all_patches(
319294
repo_dir,

0 commit comments

Comments
 (0)