summarylogtreecommitdiffstats
path: root/0001-bootstrap-without-vcs.firefox.patch
blob: b4295b80c9fcda14e30eb533aa70b281fc718b86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# LibreWolf bootstrap-without-vcs.patch
#
# Author:        Malte Jürgens <maltejur@dismail.de>
# Description:   Allow mach bootstrapping without a VCS checkout
# Last Updated:  2023-03-15
# License:       MPL 2.0
#
# This patch allows you to use `./mach bootstrap` without a VCS checkout.
# You can use that command to bootstrap a Firefox build environment.
# This patch works by adding a stub `LocalRepository`, which suprisingly
# is enough to make the bootstrapping process work. This may break other
# things in mach, but we don't use those.
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -628,10 +628,7 @@ def current_firefox_checkout(env, hg: Optional[Path] = None):
             break
         path = path.parent
 
-    raise UserError(
-        "Could not identify the root directory of your checkout! "
-        "Are you running `mach bootstrap` in an hg or git clone?"
-    )
+    return ("local", Path.cwd())
 
 
 def update_git_tools(git: Optional[Path], root_state_dir: Path):
--- a/python/mozversioncontrol/mozversioncontrol/__init__.py
+++ b/python/mozversioncontrol/mozversioncontrol/__init__.py
@@ -744,7 +744,30 @@ class GitRepository(Repository):
         self._run("config", name, value)
 
 
+class LocalRepository(Repository):
+
+    def __init__(self, path):
+        super(LocalRepository, self).__init__(path, tool="true")
+
+    @property
+    def head_ref(self):
+        return ""
+
+    def get_outgoing_files(self):
+        return []
+
+    def get_changed_files(self):
+        return []
+
+    def get_tracked_files_finder(self):
+        files = [os.path.relpath(os.path.join(dp, f), self.path).replace("\\","/") for dp, dn, fn in os.walk(self.path) for f in fn]
+        files.sort()
+        return FileListFinder(files)
+
+
+        
+
 def get_repository_object(
     path: Optional[Union[str, Path]], hg="hg", git="git", src="src"
 ):
     """Get a repository object for the repository at `path`.
@@ -757,7 +780,7 @@ def get_repository_object(path: Optional[Union[str, Path]], hg="hg", git="git"):
     elif (path / ".git").exists():
         return GitRepository(path, git=git)
     else:
-        raise InvalidRepoPath(f"Unknown VCS, or not a source checkout: {path}")
+        return LocalRepository(path)
 
 
 def get_repository_from_build_config(config):
@@ -781,6 +804,8 @@ def get_repository_from_build_config(config):
         return HgRepository(Path(config.topsrcdir), hg=config.substs["HG"])
     elif flavor == "git":
         return GitRepository(Path(config.topsrcdir), git=config.substs["GIT"])
+    elif flavor == "local":
+        return LocalRepository(config.topsrcdir)
     elif flavor == "src":
         return SrcRepository(Path(config.topsrcdir), src=config.substs["SRC"])
     else:
--- a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py
@@ -9,22 +9,7 @@ for i, platform in enumerate(ADDITIONAL_PLATFORMS):
     giturlparse.platforms.PLATFORMS.insert(i, platform)
 
 
-_SUPPORTED_PLATFORMS = ("hgmo", "github")
-
-
-SUPPORTED_HOSTS = tuple(
-    sorted(
-        [
-            host
-            for domains in [
-                platform[1].DOMAINS
-                for platform in giturlparse.platforms.PLATFORMS
-                if platform[0] in _SUPPORTED_PLATFORMS
-            ]
-            for host in domains
-        ]
-    )
-)
+SUPPORTED_HOSTS = ("hg.mozilla.org", "github.com", "gitlab.com")
 
 
 def parse(url_string):
--- a/third_party/python/taskcluster_taskgraph/taskgraph/util/vcs.py
+++ b/third_party/python/taskcluster_taskgraph/taskgraph/util/vcs.py
@@ -495,6 +495,64 @@ class GitRepository(Repository):
             raise
 
 
+class LocalRepository(Repository):
+    @property
+    def tool(self):
+        return "true"
+
+    @property
+    def head_rev(self) -> str:
+        return ""
+
+    @property
+    def base_rev(self):
+        return ""
+
+    @property
+    def branch(self):
+        return ""
+
+    @property
+    def all_remote_names(self):
+        return ""
+
+    @property
+    def default_remote_name(self):
+        return ""
+
+    @property
+    def remote_name(self):
+        return ""
+
+    @property
+    def default_branch(self):
+        return ""
+
+    def get_url(self, remote=None):
+        return ""
+
+    def get_commit_message(self, revision=None):
+        raise Exception("Unimplemented")
+
+    def get_changed_files(self, diff_filter, mode="unstaged", rev=None, base_rev=None):
+        raise Exception("Unimplemented")
+
+    def get_outgoing_files(self, diff_filter, upstream):
+        raise Exception("Unimplemented")
+
+    def working_directory_clean(self, untracked=False, ignored=False):
+        raise Exception("Unimplemented")
+
+    def update(self, ref):
+        raise Exception("Unimplemented")
+
+    def find_latest_common_revision(self, base_ref_or_rev, head_rev):
+        raise Exception("Unimplemented")
+
+    def does_revision_exist_locally(self, revision):
+        raise Exception("Unimplemented")
+
+
 def get_repository(path):
     """Get a repository object for the repository at `path`.
     If `path` is not a known VCS repository, raise an exception.
@@ -505,7 +563,7 @@ def get_repository(path):
         elif os.path.exists(os.path.join(path, ".git")):
             return GitRepository(path)
 
-    raise RuntimeError("Current directory is neither a git or hg repository")
+    return LocalRepository(path)
 
 
 def find_hg_revision_push_info(repository, revision):