Revert "[jj] Make JjWrapper support secondary JJ workspaces"

This reverts commit e16ce5a52d.

Reason for revert: Caused https://groups.google.com/d/msgid/chromium-jj-users/CAAME5gBqMx3UaddA2DvM9rhrf7aNAswB4kskK66eNzTpD7YQCg%40mail.gmail.com

Original change's description:
> [jj] Make JjWrapper support secondary JJ workspaces
>
> This change makes JjWrapper a no-op for secondary JJ workspaces that do not have a .git directory or worktree. It now holds an instance of GitWrapper and forwards commands to it only if a .git directory or worktree exists.
>
> In particular, this allows gclient sync to run in secondary workspaces without fetching the git repository for the root.
>
> Change-Id: Id89a83d7ce193304847dd75bbffa133e6a6a6964
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7780501
> Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
> Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
> Reviewed-by: Matt Stark <msta@google.com>
> Commit-Queue: Matt Stark <msta@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iabcf380e1bb78d40fced6eefc0e22ee5db389fbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7782568
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Matt Stark <msta@google.com>
changes/68/7782568/2
Matt Stark 15 hours ago committed by infra-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 1ea94929dc
commit 8c234a70d9

@ -7,61 +7,14 @@ import subprocess
import gclient_scm
class JjWrapper(gclient_scm.SCMWrapper):
class JjWrapper(gclient_scm.GitWrapper):
"""JjWrapper handles repos that are intended to be used with jj.
The repo does not yet need to be using jj, and does not even need to exist.
"""
def __init__(self, url=None, *args, **kwargs):
super(JjWrapper, self).__init__(url, *args, **kwargs)
git_path = pathlib.Path(self.checkout_path, '.git')
if git_path.exists():
self._git_wrapper = gclient_scm.GitWrapper(url, *args, **kwargs)
else:
self._git_wrapper = None
def _check_git_wrapper(self, command):
if not self._git_wrapper:
self.Print(
f"Command '{command}' is not supported on JJ workspaces "
"without a .git directory or worktree file"
)
return False
return True
def update(self, options, args, file_list):
if self._check_git_wrapper('update'):
self._git_wrapper.update(options, args, file_list)
def revert(self, options, args, file_list):
if self._check_git_wrapper('revert'):
self._git_wrapper.revert(options, args, file_list)
def revinfo(self, options, args, file_list):
if self._check_git_wrapper('revinfo'):
self._git_wrapper.revinfo(options, args, file_list)
def status(self, options, args, file_list):
if self._check_git_wrapper('status'):
self._git_wrapper.status(options, args, file_list)
def diff(self, options, args, file_list):
if self._check_git_wrapper('diff'):
self._git_wrapper.diff(options, args, file_list)
def pack(self, options, args, file_list):
if self._check_git_wrapper('pack'):
self._git_wrapper.pack(options, args, file_list)
def runhooks(self, options, args, file_list):
if self._check_git_wrapper('runhooks'):
self._git_wrapper.runhooks(options, args, file_list)
def _GetSubmodulePaths(self):
gitmodules_path = pathlib.Path(self.checkout_path, '.gitmodules')
with gitmodules_path.open('r', encoding='utf-8') as f:
with pathlib.Path(self.checkout_path, '.gitmodules').open('r') as f:
for line in f:
line = line.strip()
if not line.startswith('path = '):

Loading…
Cancel
Save