diff options
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | .mailmap | 8 | ||||
| -rw-r--r-- | .pylintrc | 2 | ||||
| -rw-r--r-- | docs/manifest-format.txt | 6 | ||||
| -rw-r--r-- | gitc_utils.py | 10 | ||||
| -rwxr-xr-x | main.py | 2 | ||||
| -rw-r--r-- | manifest_xml.py | 15 | ||||
| -rw-r--r-- | project.py | 22 | ||||
| -rw-r--r-- | subcmds/diffmanifests.py | 21 | ||||
| -rw-r--r-- | subcmds/sync.py | 2 |
10 files changed, 64 insertions, 26 deletions
diff --git a/.gitattributes b/.gitattributes index d65028a4..cdd8546d 100644 --- a/.gitattributes +++ b/.gitattributes | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # Prevent /bin/sh scripts from being clobbered by autocrlf=true | 1 | # Prevent /bin/sh scripts from being clobbered by autocrlf=true |
| 2 | git_ssh text eol=lf | 2 | git_ssh text eol=lf |
| 3 | main.py text eol=lf | ||
| 4 | repo text eol=lf | 3 | repo text eol=lf |
| 4 | hooks/* text eol=lf | ||
diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..f070b494 --- /dev/null +++ b/.mailmap | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | Anthony Newnam <anthony.newnam@garmin.com> Anthony <anthony@bnovc.com> | ||
| 2 | Shawn Pearce <sop@google.com> Shawn O. Pearce <sop@google.com> | ||
| 3 | Jia Bi <bijia@xiaomi.com> bijia <bijia@xiaomi.com> | ||
| 4 | JoonCheol Park <jooncheol@gmail.com> Jooncheol Park <jooncheol@gmail.com> | ||
| 5 | Sergii Pylypenko <x.pelya.x@gmail.com> pelya <x.pelya.x@gmail.com> | ||
| 6 | Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> Ulrik Sjolin <ulrik.sjolin@gmail.com> | ||
| 7 | Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> Ulrik Sjolin <ulrik.sjolin@sonyericsson.com> | ||
| 8 | Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> | ||
| @@ -53,7 +53,7 @@ load-plugins= | |||
| 53 | enable=RP0004 | 53 | enable=RP0004 |
| 54 | 54 | ||
| 55 | # Disable the message(s) with the given id(s). | 55 | # Disable the message(s) with the given id(s). |
| 56 | disable=R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011 | 56 | disable=C0326,R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011 |
| 57 | 57 | ||
| 58 | [REPORTS] | 58 | [REPORTS] |
| 59 | 59 | ||
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index 140a782f..8fd9137c 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt | |||
| @@ -175,7 +175,8 @@ The manifest server should implement the following RPC methods: | |||
| 175 | GetApprovedManifest(branch, target) | 175 | GetApprovedManifest(branch, target) |
| 176 | 176 | ||
| 177 | Return a manifest in which each project is pegged to a known good revision | 177 | Return a manifest in which each project is pegged to a known good revision |
| 178 | for the current branch and target. | 178 | for the current branch and target. This is used by repo sync when the |
| 179 | --smart-sync option is given. | ||
| 179 | 180 | ||
| 180 | The target to use is defined by environment variables TARGET_PRODUCT | 181 | The target to use is defined by environment variables TARGET_PRODUCT |
| 181 | and TARGET_BUILD_VARIANT. These variables are used to create a string | 182 | and TARGET_BUILD_VARIANT. These variables are used to create a string |
| @@ -187,7 +188,8 @@ should choose a reasonable default target. | |||
| 187 | GetManifest(tag) | 188 | GetManifest(tag) |
| 188 | 189 | ||
| 189 | Return a manifest in which each project is pegged to the revision at | 190 | Return a manifest in which each project is pegged to the revision at |
| 190 | the specified tag. | 191 | the specified tag. This is used by repo sync when the --smart-tag option |
| 192 | is given. | ||
| 191 | 193 | ||
| 192 | 194 | ||
| 193 | Element project | 195 | Element project |
diff --git a/gitc_utils.py b/gitc_utils.py index 0f3e1818..7a35e7a0 100644 --- a/gitc_utils.py +++ b/gitc_utils.py | |||
| @@ -24,6 +24,8 @@ import git_command | |||
| 24 | import git_config | 24 | import git_config |
| 25 | import wrapper | 25 | import wrapper |
| 26 | 26 | ||
| 27 | from error import ManifestParseError | ||
| 28 | |||
| 27 | NUM_BATCH_RETRIEVE_REVISIONID = 300 | 29 | NUM_BATCH_RETRIEVE_REVISIONID = 300 |
| 28 | 30 | ||
| 29 | def get_gitc_manifest_dir(): | 31 | def get_gitc_manifest_dir(): |
| @@ -54,7 +56,11 @@ def _set_project_revisions(projects): | |||
| 54 | if gitcmd.Wait(): | 56 | if gitcmd.Wait(): |
| 55 | print('FATAL: Failed to retrieve revisionExpr for %s' % proj) | 57 | print('FATAL: Failed to retrieve revisionExpr for %s' % proj) |
| 56 | sys.exit(1) | 58 | 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 | ||
| 58 | 64 | ||
| 59 | def _manifest_groups(manifest): | 65 | def _manifest_groups(manifest): |
| 60 | """Returns the manifest group string that should be synced | 66 | """Returns the manifest group string that should be synced |
| @@ -127,7 +133,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None): | |||
| 127 | repo_proj.revisionExpr = None | 133 | repo_proj.revisionExpr = None |
| 128 | 134 | ||
| 129 | # Convert URLs from relative to absolute. | 135 | # Convert URLs from relative to absolute. |
| 130 | for name, remote in manifest.remotes.iteritems(): | 136 | for _name, remote in manifest.remotes.iteritems(): |
| 131 | remote.fetchUrl = remote.resolvedFetchUrl | 137 | remote.fetchUrl = remote.resolvedFetchUrl |
| 132 | 138 | ||
| 133 | # Save the manifest. | 139 | # Save the manifest. |
| @@ -379,7 +379,7 @@ class _KerberosAuthHandler(urllib.request.BaseHandler): | |||
| 379 | self.context = None | 379 | self.context = None |
| 380 | self.handler_order = urllib.request.BaseHandler.handler_order - 50 | 380 | self.handler_order = urllib.request.BaseHandler.handler_order - 50 |
| 381 | 381 | ||
| 382 | def http_error_401(self, req, fp, code, msg, headers): | 382 | def http_error_401(self, req, fp, code, msg, headers): # pylint:disable=unused-argument |
| 383 | host = req.get_host() | 383 | host = req.get_host() |
| 384 | retry = self.http_error_auth_reqed('www-authenticate', host, req, headers) | 384 | retry = self.http_error_auth_reqed('www-authenticate', host, req, headers) |
| 385 | return retry | 385 | return retry |
diff --git a/manifest_xml.py b/manifest_xml.py index 3ac607ec..295493de 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -102,7 +102,10 @@ class _XmlRemote(object): | |||
| 102 | remoteName = self.name | 102 | remoteName = self.name |
| 103 | if self.remoteAlias: | 103 | if self.remoteAlias: |
| 104 | remoteName = self.remoteAlias | 104 | remoteName = self.remoteAlias |
| 105 | return RemoteSpec(remoteName, url, self.reviewUrl) | 105 | return RemoteSpec(remoteName, |
| 106 | url=url, | ||
| 107 | review=self.reviewUrl, | ||
| 108 | orig_name=self.name) | ||
| 106 | 109 | ||
| 107 | class XmlManifest(object): | 110 | class XmlManifest(object): |
| 108 | """manages the repo configuration file""" | 111 | """manages the repo configuration file""" |
| @@ -249,9 +252,9 @@ class XmlManifest(object): | |||
| 249 | e.setAttribute('path', relpath) | 252 | e.setAttribute('path', relpath) |
| 250 | remoteName = None | 253 | remoteName = None |
| 251 | if d.remote: | 254 | if d.remote: |
| 252 | remoteName = d.remote.remoteAlias or d.remote.name | 255 | remoteName = d.remote.name |
| 253 | if not d.remote or p.remote.name != remoteName: | 256 | if not d.remote or p.remote.orig_name != remoteName: |
| 254 | remoteName = p.remote.name | 257 | remoteName = p.remote.orig_name |
| 255 | e.setAttribute('remote', remoteName) | 258 | e.setAttribute('remote', remoteName) |
| 256 | if peg_rev: | 259 | if peg_rev: |
| 257 | if self.IsMirror: | 260 | if self.IsMirror: |
| @@ -267,7 +270,7 @@ class XmlManifest(object): | |||
| 267 | # isn't our value | 270 | # isn't our value |
| 268 | e.setAttribute('upstream', p.revisionExpr) | 271 | e.setAttribute('upstream', p.revisionExpr) |
| 269 | else: | 272 | else: |
| 270 | revision = self.remotes[remoteName].revision or d.revisionExpr | 273 | revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr |
| 271 | if not revision or revision != p.revisionExpr: | 274 | if not revision or revision != p.revisionExpr: |
| 272 | e.setAttribute('revision', p.revisionExpr) | 275 | e.setAttribute('revision', p.revisionExpr) |
| 273 | if p.upstream and p.upstream != p.revisionExpr: | 276 | if p.upstream and p.upstream != p.revisionExpr: |
| @@ -969,5 +972,5 @@ class GitcManifest(XmlManifest): | |||
| 969 | def _output_manifest_project_extras(self, p, e): | 972 | def _output_manifest_project_extras(self, p, e): |
| 970 | """Output GITC Specific Project attributes""" | 973 | """Output GITC Specific Project attributes""" |
| 971 | if p.old_revision: | 974 | if p.old_revision: |
| 972 | e.setAttribute('old-revision', str(p.old_revision)) | 975 | e.setAttribute('old-revision', str(p.old_revision)) |
| 973 | 976 | ||
| @@ -315,11 +315,13 @@ class RemoteSpec(object): | |||
| 315 | name, | 315 | name, |
| 316 | url=None, | 316 | url=None, |
| 317 | review=None, | 317 | review=None, |
| 318 | revision=None): | 318 | revision=None, |
| 319 | orig_name=None): | ||
| 319 | self.name = name | 320 | self.name = name |
| 320 | self.url = url | 321 | self.url = url |
| 321 | self.review = review | 322 | self.review = review |
| 322 | self.revision = revision | 323 | self.revision = revision |
| 324 | self.orig_name = orig_name | ||
| 323 | 325 | ||
| 324 | 326 | ||
| 325 | class RepoHook(object): | 327 | class RepoHook(object): |
| @@ -1858,7 +1860,10 @@ class Project(object): | |||
| 1858 | # will fail. | 1860 | # will fail. |
| 1859 | # * otherwise, fetch all branches to make sure we end up with the | 1861 | # * otherwise, fetch all branches to make sure we end up with the |
| 1860 | # specific commit. | 1862 | # specific commit. |
| 1861 | current_branch_only = self.upstream and not ID_RE.match(self.upstream) | 1863 | if self.upstream: |
| 1864 | current_branch_only = not ID_RE.match(self.upstream) | ||
| 1865 | else: | ||
| 1866 | current_branch_only = False | ||
| 1862 | 1867 | ||
| 1863 | if not name: | 1868 | if not name: |
| 1864 | name = self.remote.name | 1869 | name = self.remote.name |
| @@ -2437,7 +2442,7 @@ class Project(object): | |||
| 2437 | def _allrefs(self): | 2442 | def _allrefs(self): |
| 2438 | return self.bare_ref.all | 2443 | return self.bare_ref.all |
| 2439 | 2444 | ||
| 2440 | def _getLogs(self, rev1, rev2, oneline=False, color=True): | 2445 | def _getLogs(self, rev1, rev2, oneline=False, color=True, pretty_format=None): |
| 2441 | """Get logs between two revisions of this project.""" | 2446 | """Get logs between two revisions of this project.""" |
| 2442 | comp = '..' | 2447 | comp = '..' |
| 2443 | if rev1: | 2448 | if rev1: |
| @@ -2448,6 +2453,8 @@ class Project(object): | |||
| 2448 | out = DiffColoring(self.config) | 2453 | out = DiffColoring(self.config) |
| 2449 | if out.is_on and color: | 2454 | if out.is_on and color: |
| 2450 | cmd.append('--color') | 2455 | cmd.append('--color') |
| 2456 | if pretty_format is not None: | ||
| 2457 | cmd.append('--pretty=format:%s' % pretty_format) | ||
| 2451 | if oneline: | 2458 | if oneline: |
| 2452 | cmd.append('--oneline') | 2459 | cmd.append('--oneline') |
| 2453 | 2460 | ||
| @@ -2464,14 +2471,17 @@ class Project(object): | |||
| 2464 | raise | 2471 | raise |
| 2465 | return None | 2472 | return None |
| 2466 | 2473 | ||
| 2467 | def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True): | 2474 | def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True, |
| 2475 | pretty_format=None): | ||
| 2468 | """Get the list of logs from this revision to given revisionId""" | 2476 | """Get the list of logs from this revision to given revisionId""" |
| 2469 | logs = {} | 2477 | logs = {} |
| 2470 | selfId = self.GetRevisionId(self._allrefs) | 2478 | selfId = self.GetRevisionId(self._allrefs) |
| 2471 | toId = toProject.GetRevisionId(toProject._allrefs) | 2479 | toId = toProject.GetRevisionId(toProject._allrefs) |
| 2472 | 2480 | ||
| 2473 | logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color) | 2481 | logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color, |
| 2474 | logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color) | 2482 | pretty_format=pretty_format) |
| 2483 | logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color, | ||
| 2484 | pretty_format=pretty_format) | ||
| 2475 | return logs | 2485 | return logs |
| 2476 | 2486 | ||
| 2477 | class _GitGetByExec(object): | 2487 | class _GitGetByExec(object): |
diff --git a/subcmds/diffmanifests.py b/subcmds/diffmanifests.py index 05998681..751a2026 100644 --- a/subcmds/diffmanifests.py +++ b/subcmds/diffmanifests.py | |||
| @@ -71,6 +71,10 @@ synced and their revisions won't be found. | |||
| 71 | p.add_option('--no-color', | 71 | p.add_option('--no-color', |
| 72 | dest='color', action='store_false', default=True, | 72 | dest='color', action='store_false', default=True, |
| 73 | help='does not display the diff in color.') | 73 | help='does not display the diff in color.') |
| 74 | p.add_option('--pretty-format', | ||
| 75 | dest='pretty_format', action='store', | ||
| 76 | metavar='<FORMAT>', | ||
| 77 | help='print the log using a custom git pretty format string') | ||
| 74 | 78 | ||
| 75 | def _printRawDiff(self, diff): | 79 | def _printRawDiff(self, diff): |
| 76 | for project in diff['added']: | 80 | for project in diff['added']: |
| @@ -92,7 +96,7 @@ synced and their revisions won't be found. | |||
| 92 | otherProject.revisionExpr)) | 96 | otherProject.revisionExpr)) |
| 93 | self.out.nl() | 97 | self.out.nl() |
| 94 | 98 | ||
| 95 | def _printDiff(self, diff, color=True): | 99 | def _printDiff(self, diff, color=True, pretty_format=None): |
| 96 | if diff['added']: | 100 | if diff['added']: |
| 97 | self.out.nl() | 101 | self.out.nl() |
| 98 | self.printText('added projects : \n') | 102 | self.printText('added projects : \n') |
| @@ -124,7 +128,8 @@ synced and their revisions won't be found. | |||
| 124 | self.printText(' to ') | 128 | self.printText(' to ') |
| 125 | self.printRevision(otherProject.revisionExpr) | 129 | self.printRevision(otherProject.revisionExpr) |
| 126 | self.out.nl() | 130 | self.out.nl() |
| 127 | self._printLogs(project, otherProject, raw=False, color=color) | 131 | self._printLogs(project, otherProject, raw=False, color=color, |
| 132 | pretty_format=pretty_format) | ||
| 128 | self.out.nl() | 133 | self.out.nl() |
| 129 | 134 | ||
| 130 | if diff['unreachable']: | 135 | if diff['unreachable']: |
| @@ -139,9 +144,13 @@ synced and their revisions won't be found. | |||
| 139 | self.printText(' not found') | 144 | self.printText(' not found') |
| 140 | self.out.nl() | 145 | self.out.nl() |
| 141 | 146 | ||
| 142 | def _printLogs(self, project, otherProject, raw=False, color=True): | 147 | def _printLogs(self, project, otherProject, raw=False, color=True, |
| 143 | logs = project.getAddedAndRemovedLogs(otherProject, oneline=True, | 148 | pretty_format=None): |
| 144 | color=color) | 149 | |
| 150 | logs = project.getAddedAndRemovedLogs(otherProject, | ||
| 151 | oneline=(pretty_format is None), | ||
| 152 | color=color, | ||
| 153 | pretty_format=pretty_format) | ||
| 145 | if logs['removed']: | 154 | if logs['removed']: |
| 146 | removedLogs = logs['removed'].split('\n') | 155 | removedLogs = logs['removed'].split('\n') |
| 147 | for log in removedLogs: | 156 | for log in removedLogs: |
| @@ -192,4 +201,4 @@ synced and their revisions won't be found. | |||
| 192 | if opt.raw: | 201 | if opt.raw: |
| 193 | self._printRawDiff(diff) | 202 | self._printRawDiff(diff) |
| 194 | else: | 203 | else: |
| 195 | self._printDiff(diff, color=opt.color) | 204 | self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 4af411c9..9124a653 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -242,7 +242,7 @@ later is required to fix a server side protocol bug. | |||
| 242 | if show_smart: | 242 | if show_smart: |
| 243 | p.add_option('-s', '--smart-sync', | 243 | p.add_option('-s', '--smart-sync', |
| 244 | dest='smart_sync', action='store_true', | 244 | dest='smart_sync', action='store_true', |
| 245 | help='smart sync using manifest from a known good build') | 245 | help='smart sync using manifest from the latest known good build') |
| 246 | p.add_option('-t', '--smart-tag', | 246 | p.add_option('-t', '--smart-tag', |
| 247 | dest='smart_tag', action='store', | 247 | dest='smart_tag', action='store', |
| 248 | help='smart sync using manifest from a known tag') | 248 | help='smart sync using manifest from a known tag') |
