diff options
| author | Shawn O. Pearce <sop@google.com> | 2010-03-06 19:29:56 -0800 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2010-03-06 19:29:56 -0800 |
| commit | 69b1e8aa65ab933fa919166d88aec90c86852beb (patch) | |
| tree | 0a8635a835abfd8c05a04bd03639ab2d07e70d5f | |
| parent | 840ed0fab7cb4c2ab296c7d7d45f13e2523bae1c (diff) | |
| parent | 9452e4ec0941fbee163e35ebdcd6ca6ee7df55cb (diff) | |
| download | git-repo-69b1e8aa65ab933fa919166d88aec90c86852beb.tar.gz | |
Merge branch 'stable'
* stable:
Automatically install Gerrit Code Review's commit-msg hook
Fail sync when encountering "N commits behind."
Check that we are not overwriting a local repository when syncing.
Honor url.insteadOf when setting up SSH control master connection
sync: Fix split call on malformed email addresses
Fixing project renaming bug.
Conflicts:
hooks/commit-msg
project.py
subcmds/sync.py
Change-Id: I5eaf8fef8cbe4a95d124368112293a9ca64325bf
| -rw-r--r-- | git_config.py | 24 | ||||
| -rwxr-xr-x | hooks/commit-msg | 64 | ||||
| -rw-r--r-- | project.py | 14 | ||||
| -rw-r--r-- | subcmds/sync.py | 11 |
4 files changed, 83 insertions, 30 deletions
diff --git a/git_config.py b/git_config.py index b6288219..4a42c047 100644 --- a/git_config.py +++ b/git_config.py | |||
| @@ -461,8 +461,30 @@ class Remote(object): | |||
| 461 | self._Get('fetch', all=True)) | 461 | self._Get('fetch', all=True)) |
| 462 | self._review_protocol = None | 462 | self._review_protocol = None |
| 463 | 463 | ||
| 464 | def _InsteadOf(self): | ||
| 465 | globCfg = GitConfig.ForUser() | ||
| 466 | urlList = globCfg.GetSubSections('url') | ||
| 467 | longest = "" | ||
| 468 | longestUrl = "" | ||
| 469 | |||
| 470 | for url in urlList: | ||
| 471 | key = "url." + url + ".insteadOf" | ||
| 472 | insteadOfList = globCfg.GetString(key, all=True) | ||
| 473 | |||
| 474 | for insteadOf in insteadOfList: | ||
| 475 | if self.url.startswith(insteadOf) \ | ||
| 476 | and len(insteadOf) > len(longest): | ||
| 477 | longest = insteadOf | ||
| 478 | longestUrl = url | ||
| 479 | |||
| 480 | if len(longest) == 0: | ||
| 481 | return self.url | ||
| 482 | |||
| 483 | return self.url.replace(longest, longestUrl, 1) | ||
| 484 | |||
| 464 | def PreConnectFetch(self): | 485 | def PreConnectFetch(self): |
| 465 | return _preconnect(self.url) | 486 | connectionUrl = self._InsteadOf() |
| 487 | return _preconnect(connectionUrl) | ||
| 466 | 488 | ||
| 467 | @property | 489 | @property |
| 468 | def ReviewProtocol(self): | 490 | def ReviewProtocol(self): |
diff --git a/hooks/commit-msg b/hooks/commit-msg index fd76c074..712921c9 100755 --- a/hooks/commit-msg +++ b/hooks/commit-msg | |||
| @@ -1,23 +1,24 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # From Gerrit Code Review v2.0.19.1-4-g21d307b | 2 | # From Gerrit Code Review 2.1.2-rc2-33-g7e30c72 |
| 3 | # | 3 | # |
| 4 | # Part of Gerrit Code Review (http://code.google.com/p/gerrit/) | 4 | # Part of Gerrit Code Review (http://code.google.com/p/gerrit/) |
| 5 | # | 5 | # |
| 6 | # Copyright (C) 2009 The Android Open Source Project | 6 | # Copyright (C) 2009 The Android Open Source Project |
| 7 | # | 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); | 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. | 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at | 10 | # You may obtain a copy of the License at |
| 11 | # | 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 | 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # | 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software | 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, | 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and | 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. | 18 | # limitations under the License. |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | CHANGE_ID_AFTER="Bug|Issue" | ||
| 21 | MSG="$1" | 22 | MSG="$1" |
| 22 | 23 | ||
| 23 | # Check for, and add if missing, a unique Change-Id | 24 | # Check for, and add if missing, a unique Change-Id |
| @@ -42,22 +43,43 @@ add_ChangeId() { | |||
| 42 | fi | 43 | fi |
| 43 | 44 | ||
| 44 | id=$(_gen_ChangeId) | 45 | id=$(_gen_ChangeId) |
| 45 | out="$MSG.OUT" | 46 | perl -e ' |
| 46 | ftt="$MSG.FTT" | 47 | $MSG = shift; |
| 47 | sed -e '2,${ | 48 | $id = shift; |
| 48 | /^[A-Za-z][A-Za-z0-9-]*: /,$d | 49 | $CHANGE_ID_AFTER = shift; |
| 49 | }' <"$MSG" >"$out" | 50 | |
| 50 | sed -ne '2,${ | 51 | undef $/; |
| 51 | /^[A-Za-z][A-Za-z0-9-]*: /,$p | 52 | open(I, $MSG); $_ = <I>; close I; |
| 52 | }' <"$MSG" >"$ftt" | 53 | s|^diff --git a/.*||ms; |
| 53 | if ! test -s "$ftt" | 54 | s|^#.*$||mg; |
| 54 | then | 55 | exit unless $_; |
| 55 | echo >>"$out" | 56 | |
| 56 | fi | 57 | @message = split /\n/; |
| 57 | echo "Change-Id: I$id" >>"$out" | 58 | $haveFooter = 0; |
| 58 | cat "$ftt" >>"$out" | 59 | $startFooter = @message; |
| 59 | mv -f "$out" "$MSG" | 60 | for($line = @message - 1; $line >= 0; $line--) { |
| 60 | rm -f "$out" "$ftt" | 61 | $_ = $message[$line]; |
| 62 | |||
| 63 | ($haveFooter++, next) if /^[a-zA-Z0-9-]+:/; | ||
| 64 | next if /^[ []/; | ||
| 65 | $startFooter = $line if ($haveFooter && /^\r?$/); | ||
| 66 | last; | ||
| 67 | } | ||
| 68 | |||
| 69 | @footer = @message[$startFooter+1..@message]; | ||
| 70 | @message = @message[0..$startFooter]; | ||
| 71 | push(@footer, "") unless @footer; | ||
| 72 | |||
| 73 | for ($line = 0; $line < @footer; $line++) { | ||
| 74 | $_ = $footer[$line]; | ||
| 75 | next if /^($CHANGE_ID_AFTER):/i; | ||
| 76 | last; | ||
| 77 | } | ||
| 78 | splice(@footer, $line, 0, "Change-Id: I$id"); | ||
| 79 | |||
| 80 | $_ = join("\n", @message, @footer); | ||
| 81 | open(O, ">$MSG"); print O; close O; | ||
| 82 | ' "$MSG" "$id" "$CHANGE_ID_AFTER" | ||
| 61 | } | 83 | } |
| 62 | _gen_ChangeIdInput() { | 84 | _gen_ChangeIdInput() { |
| 63 | echo "tree $(git write-tree)" | 85 | echo "tree $(git write-tree)" |
| @@ -706,10 +706,9 @@ class Project(object): | |||
| 706 | # commits are not yet merged upstream. We do not want | 706 | # commits are not yet merged upstream. We do not want |
| 707 | # to rewrite the published commits so we punt. | 707 | # to rewrite the published commits so we punt. |
| 708 | # | 708 | # |
| 709 | syncbuf.info(self, | 709 | syncbuf.fail(self, |
| 710 | "branch %s is published but is now %d commits behind", | 710 | "branch %s is published (but not merged) and is now %d commits behind" |
| 711 | branch.name, | 711 | % (branch.name, len(upstream_gain))) |
| 712 | len(upstream_gain)) | ||
| 713 | return | 712 | return |
| 714 | elif pub == head: | 713 | elif pub == head: |
| 715 | # All published commits are merged, and thus we are a | 714 | # All published commits are merged, and thus we are a |
| @@ -728,7 +727,7 @@ class Project(object): | |||
| 728 | last_mine = None | 727 | last_mine = None |
| 729 | cnt_mine = 0 | 728 | cnt_mine = 0 |
| 730 | for commit in local_changes: | 729 | for commit in local_changes: |
| 731 | commit_id, committer_email = commit.split(' ', 2) | 730 | commit_id, committer_email = commit.split(' ', 1) |
| 732 | if committer_email == self.UserEmail: | 731 | if committer_email == self.UserEmail: |
| 733 | last_mine = commit_id | 732 | last_mine = commit_id |
| 734 | cnt_mine += 1 | 733 | cnt_mine += 1 |
| @@ -1132,7 +1131,10 @@ class Project(object): | |||
| 1132 | dst = os.path.join(dotgit, name) | 1131 | dst = os.path.join(dotgit, name) |
| 1133 | if relink: | 1132 | if relink: |
| 1134 | os.remove(dst) | 1133 | os.remove(dst) |
| 1135 | os.symlink(relpath(src, dst), dst) | 1134 | if os.path.islink(dst) or not os.path.exists(dst): |
| 1135 | os.symlink(relpath(src, dst), dst) | ||
| 1136 | else: | ||
| 1137 | raise GitError('cannot overwrite a local work tree') | ||
| 1136 | except OSError, e: | 1138 | except OSError, e: |
| 1137 | if e.errno == errno.EPERM: | 1139 | if e.errno == errno.EPERM: |
| 1138 | raise GitError('filesystem must support symlinks') | 1140 | raise GitError('filesystem must support symlinks') |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 5fc834d0..d89c2b8c 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -111,7 +111,6 @@ later is required to fix a server side protocol bug. | |||
| 111 | pm = Progress('Fetching projects', len(projects)) | 111 | pm = Progress('Fetching projects', len(projects)) |
| 112 | for project in projects: | 112 | for project in projects: |
| 113 | pm.update() | 113 | pm.update() |
| 114 | |||
| 115 | if project.Sync_NetworkHalf(): | 114 | if project.Sync_NetworkHalf(): |
| 116 | fetched.add(project.gitdir) | 115 | fetched.add(project.gitdir) |
| 117 | else: | 116 | else: |
| @@ -194,6 +193,15 @@ uncommitted changes are present' % project.relpath | |||
| 194 | if opt.repo_upgraded: | 193 | if opt.repo_upgraded: |
| 195 | _PostRepoUpgrade(self.manifest) | 194 | _PostRepoUpgrade(self.manifest) |
| 196 | 195 | ||
| 196 | if not opt.local_only: | ||
| 197 | mp.Sync_NetworkHalf() | ||
| 198 | |||
| 199 | if mp.HasChanges: | ||
| 200 | syncbuf = SyncBuffer(mp.config) | ||
| 201 | mp.Sync_LocalHalf(syncbuf) | ||
| 202 | if not syncbuf.Finish(): | ||
| 203 | sys.exit(1) | ||
| 204 | self.manifest._Unload() | ||
| 197 | all = self.GetProjects(args, missing_ok=True) | 205 | all = self.GetProjects(args, missing_ok=True) |
| 198 | 206 | ||
| 199 | if not opt.local_only: | 207 | if not opt.local_only: |
| @@ -201,7 +209,6 @@ uncommitted changes are present' % project.relpath | |||
| 201 | now = time.time() | 209 | now = time.time() |
| 202 | if (24 * 60 * 60) <= (now - rp.LastFetch): | 210 | if (24 * 60 * 60) <= (now - rp.LastFetch): |
| 203 | to_fetch.append(rp) | 211 | to_fetch.append(rp) |
| 204 | to_fetch.append(mp) | ||
| 205 | to_fetch.extend(all) | 212 | to_fetch.extend(all) |
| 206 | 213 | ||
| 207 | fetched = self._Fetch(to_fetch) | 214 | fetched = self._Fetch(to_fetch) |
