Skip to content

Commit 5f859eb

Browse files
author
Matthias Putz
committed
Update: google git-repo v1.12.37
1 parent 451d58f commit 5f859eb

19 files changed

+629
-218
lines changed

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length=80
3+
ignore=E111,E114,E402

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Prevent /bin/sh scripts from being clobbered by autocrlf=true
22
git_ssh text eol=lf
3-
main.py text eol=lf
43
repo text eol=lf
4+
hooks/* text eol=lf

.mailmap

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Anthony Newnam <[email protected]> Anthony <[email protected]>
2+
Hu Xiuyun <[email protected]> Hu xiuyun <[email protected]>
3+
Hu Xiuyun <[email protected]> Hu Xiuyun <[email protected]>
4+
Jelly Chen <[email protected]> chenguodong <[email protected]>
5+
6+
JoonCheol Park <[email protected]> Jooncheol Park <[email protected]>
7+
Sergii Pylypenko <[email protected]> pelya <[email protected]>
8+
Shawn Pearce <[email protected]> Shawn O. Pearce <[email protected]>
9+
Ulrik Sjölin <[email protected]> Ulrik Sjolin <[email protected]>
10+
Ulrik Sjölin <[email protected]> Ulrik Sjolin <[email protected]>
11+
Ulrik Sjölin <[email protected]> Ulrik Sjölin <[email protected]>

SUBMITTING_PATCHES.md

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Short Version
2+
3+
- Make small logical changes.
4+
- Provide a meaningful commit message.
5+
- Check for coding errors and style nits with pyflakes and flake8
6+
- Make sure all code is under the Apache License, 2.0.
7+
- Publish your changes for review.
8+
- Make corrections if requested.
9+
- Verify your changes on gerrit so they can be submitted.
10+
11+
`git push https://gerrit-review.googlesource.com/git-repo HEAD:refs/for/master`
12+
13+
14+
# Long Version
15+
16+
I wanted a file describing how to submit patches for repo,
17+
so I started with the one found in the core Git distribution
18+
(Documentation/SubmittingPatches), which itself was based on the
19+
patch submission guidelines for the Linux kernel.
20+
21+
However there are some differences, so please review and familiarize
22+
yourself with the following relevant bits.
23+
24+
25+
## Make separate commits for logically separate changes.
26+
27+
Unless your patch is really trivial, you should not be sending
28+
out a patch that was generated between your working tree and your
29+
commit head. Instead, always make a commit with complete commit
30+
message and generate a series of patches from your repository.
31+
It is a good discipline.
32+
33+
Describe the technical detail of the change(s).
34+
35+
If your description starts to get too long, that's a sign that you
36+
probably need to split up your commit to finer grained pieces.
37+
38+
39+
## Check for coding errors and style nits with pyflakes and flake8
40+
41+
### Coding errors
42+
43+
Run `pyflakes` on changed modules:
44+
45+
pyflakes file.py
46+
47+
Ideally there should be no new errors or warnings introduced.
48+
49+
### Style violations
50+
51+
Run `flake8` on changes modules:
52+
53+
flake8 file.py
54+
55+
Note that repo generally follows [Google's python style guide]
56+
(https://google.github.io/styleguide/pyguide.html) rather than [PEP 8]
57+
(https://www.python.org/dev/peps/pep-0008/), so it's possible that
58+
the output of `flake8` will be quite noisy. It's not mandatory to
59+
avoid all warnings, but at least the maximum line length should be
60+
followed.
61+
62+
If there are many occurrences of the same warning that cannot be
63+
avoided without going against the Google style guide, these may be
64+
suppressed in the included `.flake8` file.
65+
66+
## Check the license
67+
68+
repo is licensed under the Apache License, 2.0.
69+
70+
Because of this licensing model *every* file within the project
71+
*must* list the license that covers it in the header of the file.
72+
Any new contributions to an existing file *must* be submitted under
73+
the current license of that file. Any new files *must* clearly
74+
indicate which license they are provided under in the file header.
75+
76+
Please verify that you are legally allowed and willing to submit your
77+
changes under the license covering each file *prior* to submitting
78+
your patch. It is virtually impossible to remove a patch once it
79+
has been applied and pushed out.
80+
81+
82+
## Sending your patches.
83+
84+
Do not email your patches to anyone.
85+
86+
Instead, login to the Gerrit Code Review tool at:
87+
88+
https://gerrit-review.googlesource.com/
89+
90+
Ensure you have completed one of the necessary contributor
91+
agreements, providing documentation to the project maintainers that
92+
they have right to redistribute your work under the Apache License:
93+
94+
https://gerrit-review.googlesource.com/#/settings/agreements
95+
96+
Ensure you have obtained an HTTP password to authenticate:
97+
98+
https://gerrit-review.googlesource.com/new-password
99+
100+
Ensure that you have the local commit hook installed to automatically
101+
add a ChangeId to your commits:
102+
103+
curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://gerrit-review.googlesource.com/tools/hooks/commit-msg
104+
chmod +x `git rev-parse --git-dir`/hooks/commit-msg
105+
106+
If you have already committed your changes you will need to amend the commit
107+
to get the ChangeId added.
108+
109+
git commit --amend
110+
111+
Push your patches over HTTPS to the review server, possibly through
112+
a remembered remote to make this easier in the future:
113+
114+
git config remote.review.url https://gerrit-review.googlesource.com/git-repo
115+
git config remote.review.push HEAD:refs/for/master
116+
117+
git push review
118+
119+
You will be automatically emailed a copy of your commits, and any
120+
comments made by the project maintainers.
121+
122+
123+
## Make changes if requested
124+
125+
The project maintainer who reviews your changes might request changes to your
126+
commit. If you make the requested changes you will need to amend your commit
127+
and push it to the review server again.
128+
129+
130+
## Verify your changes on gerrit
131+
132+
After you receive a Code-Review+2 from the maintainer, select the Verified
133+
button on the gerrit page for the change. This verifies that you have tested
134+
your changes and notifies the maintainer that they are ready to be submitted.
135+
The maintainer will then submit your changes to the repository.

command.py

+29-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Command(object):
3131
manifest = None
3232
_optparse = None
3333

34-
def WantPager(self, opt):
34+
def WantPager(self, _opt):
3535
return False
3636

3737
def ReadEnvironmentOptions(self, opts):
@@ -63,7 +63,7 @@ def OptionParser(self):
6363
usage = self.helpUsage.strip().replace('%prog', me)
6464
except AttributeError:
6565
usage = 'repo %s' % self.NAME
66-
self._optparse = optparse.OptionParser(usage = usage)
66+
self._optparse = optparse.OptionParser(usage=usage)
6767
self._Options(self._optparse)
6868
return self._optparse
6969

@@ -110,15 +110,20 @@ def _GetProjectByPath(self, manifest, path):
110110
project = None
111111
if os.path.exists(path):
112112
oldpath = None
113-
while path \
114-
and path != oldpath \
115-
and path != manifest.topdir:
113+
while path and \
114+
path != oldpath and \
115+
path != manifest.topdir:
116116
try:
117117
project = self._by_path[path]
118118
break
119119
except KeyError:
120120
oldpath = path
121121
path = os.path.dirname(path)
122+
if not project and path == manifest.topdir:
123+
try:
124+
project = self._by_path[path]
125+
except KeyError:
126+
pass
122127
else:
123128
try:
124129
project = self._by_path[path]
@@ -138,7 +143,7 @@ def GetProjects(self, args, manifest=None, groups='', missing_ok=False,
138143
mp = manifest.manifestProject
139144

140145
if not groups:
141-
groups = mp.config.GetString('manifest.groups')
146+
groups = mp.config.GetString('manifest.groups')
142147
if not groups:
143148
groups = 'default,platform-' + platform.system().lower()
144149
groups = [x for x in re.split(r'[,\s]+', groups) if x]
@@ -151,8 +156,7 @@ def GetProjects(self, args, manifest=None, groups='', missing_ok=False,
151156
for p in project.GetDerivedSubprojects())
152157
all_projects_list.extend(derived_projects.values())
153158
for project in all_projects_list:
154-
if ((missing_ok or project.Exists) and
155-
project.MatchesGroups(groups)):
159+
if (missing_ok or project.Exists) and project.MatchesGroups(groups):
156160
result.append(project)
157161
else:
158162
self._ResetPathToProjectMap(all_projects_list)
@@ -166,8 +170,8 @@ def GetProjects(self, args, manifest=None, groups='', missing_ok=False,
166170

167171
# If it's not a derived project, update path->project mapping and
168172
# search again, as arg might actually point to a derived subproject.
169-
if (project and not project.Derived and
170-
(submodules_ok or project.sync_s)):
173+
if (project and not project.Derived and (submodules_ok or
174+
project.sync_s)):
171175
search_again = False
172176
for subproject in project.GetDerivedSubprojects():
173177
self._UpdatePathToProjectMap(subproject)
@@ -194,17 +198,24 @@ def _getpath(x):
194198
result.sort(key=_getpath)
195199
return result
196200

197-
def FindProjects(self, args):
201+
def FindProjects(self, args, inverse=False):
198202
result = []
199203
patterns = [re.compile(r'%s' % a, re.IGNORECASE) for a in args]
200204
for project in self.GetProjects(''):
201205
for pattern in patterns:
202-
if pattern.search(project.name) or pattern.search(project.relpath):
206+
match = pattern.search(project.name) or pattern.search(project.relpath)
207+
if not inverse and match:
203208
result.append(project)
204209
break
210+
if inverse and match:
211+
break
212+
else:
213+
if inverse:
214+
result.append(project)
205215
result.sort(key=lambda project: project.relpath)
206216
return result
207217

218+
208219
# pylint: disable=W0223
209220
# Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not
210221
# override method `Execute` which is abstract in `Command`. Since that method
@@ -214,28 +225,32 @@ class InteractiveCommand(Command):
214225
"""Command which requires user interaction on the tty and
215226
must not run within a pager, even if the user asks to.
216227
"""
217-
def WantPager(self, opt):
228+
def WantPager(self, _opt):
218229
return False
219230

231+
220232
class PagedCommand(Command):
221233
"""Command which defaults to output in a pager, as its
222234
display tends to be larger than one screen full.
223235
"""
224-
def WantPager(self, opt):
236+
def WantPager(self, _opt):
225237
return True
226238

227239
# pylint: enable=W0223
228240

241+
229242
class MirrorSafeCommand(object):
230243
"""Command permits itself to run within a mirror,
231244
and does not require a working directory.
232245
"""
233246

247+
234248
class GitcAvailableCommand(object):
235249
"""Command that requires GITC to be available, but does
236250
not require the local client to be a GITC client.
237251
"""
238252

253+
239254
class GitcClientCommand(object):
240255
"""Command that requires the local client to be a GITC
241256
client.

docs/manifest-format.txt

+11-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ following DTD:
3535
<!ATTLIST remote name ID #REQUIRED>
3636
<!ATTLIST remote alias CDATA #IMPLIED>
3737
<!ATTLIST remote fetch CDATA #REQUIRED>
38+
<!ATTLIST remote pushurl CDATA #IMPLIED>
3839
<!ATTLIST remote review CDATA #IMPLIED>
3940
<!ATTLIST remote revision CDATA #IMPLIED>
4041

@@ -125,6 +126,12 @@ Attribute `fetch`: The Git URL prefix for all projects which use
125126
this remote. Each project's name is appended to this prefix to
126127
form the actual URL used to clone the project.
127128

129+
Attribute `pushurl`: The Git "push" URL prefix for all projects
130+
which use this remote. Each project's name is appended to this
131+
prefix to form the actual URL used to "git push" the project.
132+
This attribute is optional; if not specified then "git push"
133+
will use the same URL as the `fetch` attribute.
134+
128135
Attribute `review`: Hostname of the Gerrit server where reviews
129136
are uploaded to by `repo upload`. This attribute is optional;
130137
if not specified then `repo upload` will not function.
@@ -175,7 +182,8 @@ The manifest server should implement the following RPC methods:
175182
GetApprovedManifest(branch, target)
176183

177184
Return a manifest in which each project is pegged to a known good revision
178-
for the current branch and target.
185+
for the current branch and target. This is used by repo sync when the
186+
--smart-sync option is given.
179187

180188
The target to use is defined by environment variables TARGET_PRODUCT
181189
and TARGET_BUILD_VARIANT. These variables are used to create a string
@@ -187,7 +195,8 @@ should choose a reasonable default target.
187195
GetManifest(tag)
188196

189197
Return a manifest in which each project is pegged to the revision at
190-
the specified tag.
198+
the specified tag. This is used by repo sync when the --smart-tag option
199+
is given.
191200

192201

193202
Element project

git_config.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,13 @@ def _open_ssh(host, port=None):
464464
% (host,port, str(e)), file=sys.stderr)
465465
return False
466466

467+
time.sleep(1)
468+
ssh_died = (p.poll() is not None)
469+
if ssh_died:
470+
return False
471+
467472
_master_processes.append(p)
468473
_master_keys.add(key)
469-
time.sleep(1)
470474
return True
471475
finally:
472476
_master_keys_lock.release()
@@ -568,6 +572,7 @@ def __init__(self, config, name):
568572
self._config = config
569573
self.name = name
570574
self.url = self._Get('url')
575+
self.pushUrl = self._Get('pushurl')
571576
self.review = self._Get('review')
572577
self.projectname = self._Get('projectname')
573578
self.fetch = list(map(RefSpec.FromString,
@@ -700,6 +705,10 @@ def Save(self):
700705
"""Save this remote to the configuration.
701706
"""
702707
self._Set('url', self.url)
708+
if self.pushUrl is not None:
709+
self._Set('pushurl', self.pushUrl + '/' + self.projectname)
710+
else:
711+
self._Set('pushurl', self.pushUrl)
703712
self._Set('review', self.review)
704713
self._Set('projectname', self.projectname)
705714
self._Set('fetch', list(map(str, self.fetch)))

gitc_utils.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import git_config
2525
import wrapper
2626

27-
NUM_BATCH_RETRIEVE_REVISIONID = 300
27+
from error import ManifestParseError
28+
29+
NUM_BATCH_RETRIEVE_REVISIONID = 32
2830

2931
def get_gitc_manifest_dir():
3032
return wrapper.Wrapper().get_gitc_manifest_dir()
@@ -54,7 +56,11 @@ def _set_project_revisions(projects):
5456
if gitcmd.Wait():
5557
print('FATAL: Failed to retrieve revisionExpr for %s' % proj)
5658
sys.exit(1)
57-
proj.revisionExpr = gitcmd.stdout.split('\t')[0]
59+
revisionExpr = gitcmd.stdout.split('\t')[0]
60+
if not revisionExpr:
61+
raise(ManifestParseError('Invalid SHA-1 revision project %s (%s)' %
62+
(proj.remote.url, proj.revisionExpr)))
63+
proj.revisionExpr = revisionExpr
5864

5965
def _manifest_groups(manifest):
6066
"""Returns the manifest group string that should be synced
@@ -127,7 +133,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None):
127133
repo_proj.revisionExpr = None
128134

129135
# Convert URLs from relative to absolute.
130-
for name, remote in manifest.remotes.iteritems():
136+
for _name, remote in manifest.remotes.iteritems():
131137
remote.fetchUrl = remote.resolvedFetchUrl
132138

133139
# Save the manifest.

0 commit comments

Comments
 (0)