diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/download.py | 6 | ||||
| -rw-r--r-- | subcmds/grep.py | 14 | ||||
| -rw-r--r-- | subcmds/help.py | 2 | ||||
| -rw-r--r-- | subcmds/info.py | 195 | ||||
| -rw-r--r-- | subcmds/init.py | 4 | ||||
| -rw-r--r-- | subcmds/overview.py | 3 | ||||
| -rw-r--r-- | subcmds/sync.py | 180 | ||||
| -rw-r--r-- | subcmds/upload.py | 42 |
8 files changed, 322 insertions, 124 deletions
diff --git a/subcmds/download.py b/subcmds/download.py index 6aa54afa..471e88b5 100644 --- a/subcmds/download.py +++ b/subcmds/download.py | |||
| @@ -33,13 +33,13 @@ makes it available in your project's local working directory. | |||
| 33 | """ | 33 | """ |
| 34 | 34 | ||
| 35 | def _Options(self, p): | 35 | def _Options(self, p): |
| 36 | p.add_option('-c','--cherry-pick', | 36 | p.add_option('-c', '--cherry-pick', |
| 37 | dest='cherrypick', action='store_true', | 37 | dest='cherrypick', action='store_true', |
| 38 | help="cherry-pick instead of checkout") | 38 | help="cherry-pick instead of checkout") |
| 39 | p.add_option('-r','--revert', | 39 | p.add_option('-r', '--revert', |
| 40 | dest='revert', action='store_true', | 40 | dest='revert', action='store_true', |
| 41 | help="revert instead of checkout") | 41 | help="revert instead of checkout") |
| 42 | p.add_option('-f','--ff-only', | 42 | p.add_option('-f', '--ff-only', |
| 43 | dest='ffonly', action='store_true', | 43 | dest='ffonly', action='store_true', |
| 44 | help="force fast-forward merge") | 44 | help="force fast-forward merge") |
| 45 | 45 | ||
diff --git a/subcmds/grep.py b/subcmds/grep.py index fa5f8765..dd391cfa 100644 --- a/subcmds/grep.py +++ b/subcmds/grep.py | |||
| @@ -85,7 +85,7 @@ contain a line that matches both expressions: | |||
| 85 | g.add_option('--cached', | 85 | g.add_option('--cached', |
| 86 | action='callback', callback=carry, | 86 | action='callback', callback=carry, |
| 87 | help='Search the index, instead of the work tree') | 87 | help='Search the index, instead of the work tree') |
| 88 | g.add_option('-r','--revision', | 88 | g.add_option('-r', '--revision', |
| 89 | dest='revision', action='append', metavar='TREEish', | 89 | dest='revision', action='append', metavar='TREEish', |
| 90 | help='Search TREEish, instead of the work tree') | 90 | help='Search TREEish, instead of the work tree') |
| 91 | 91 | ||
| @@ -97,7 +97,7 @@ contain a line that matches both expressions: | |||
| 97 | g.add_option('-i', '--ignore-case', | 97 | g.add_option('-i', '--ignore-case', |
| 98 | action='callback', callback=carry, | 98 | action='callback', callback=carry, |
| 99 | help='Ignore case differences') | 99 | help='Ignore case differences') |
| 100 | g.add_option('-a','--text', | 100 | g.add_option('-a', '--text', |
| 101 | action='callback', callback=carry, | 101 | action='callback', callback=carry, |
| 102 | help="Process binary files as if they were text") | 102 | help="Process binary files as if they were text") |
| 103 | g.add_option('-I', | 103 | g.add_option('-I', |
| @@ -126,7 +126,7 @@ contain a line that matches both expressions: | |||
| 126 | g.add_option('--and', '--or', '--not', | 126 | g.add_option('--and', '--or', '--not', |
| 127 | action='callback', callback=carry, | 127 | action='callback', callback=carry, |
| 128 | help='Boolean operators to combine patterns') | 128 | help='Boolean operators to combine patterns') |
| 129 | g.add_option('-(','-)', | 129 | g.add_option('-(', '-)', |
| 130 | action='callback', callback=carry, | 130 | action='callback', callback=carry, |
| 131 | help='Boolean operator grouping') | 131 | help='Boolean operator grouping') |
| 132 | 132 | ||
| @@ -146,10 +146,10 @@ contain a line that matches both expressions: | |||
| 146 | action='callback', callback=carry, | 146 | action='callback', callback=carry, |
| 147 | metavar='CONTEXT', type='str', | 147 | metavar='CONTEXT', type='str', |
| 148 | help='Show CONTEXT lines after match') | 148 | help='Show CONTEXT lines after match') |
| 149 | g.add_option('-l','--name-only','--files-with-matches', | 149 | g.add_option('-l', '--name-only', '--files-with-matches', |
| 150 | action='callback', callback=carry, | 150 | action='callback', callback=carry, |
| 151 | help='Show only file names containing matching lines') | 151 | help='Show only file names containing matching lines') |
| 152 | g.add_option('-L','--files-without-match', | 152 | g.add_option('-L', '--files-without-match', |
| 153 | action='callback', callback=carry, | 153 | action='callback', callback=carry, |
| 154 | help='Show only file names not containing matching lines') | 154 | help='Show only file names not containing matching lines') |
| 155 | 155 | ||
| @@ -158,9 +158,9 @@ contain a line that matches both expressions: | |||
| 158 | out = GrepColoring(self.manifest.manifestProject.config) | 158 | out = GrepColoring(self.manifest.manifestProject.config) |
| 159 | 159 | ||
| 160 | cmd_argv = ['grep'] | 160 | cmd_argv = ['grep'] |
| 161 | if out.is_on and git_require((1,6,3)): | 161 | if out.is_on and git_require((1, 6, 3)): |
| 162 | cmd_argv.append('--color') | 162 | cmd_argv.append('--color') |
| 163 | cmd_argv.extend(getattr(opt,'cmd_argv',[])) | 163 | cmd_argv.extend(getattr(opt, 'cmd_argv', [])) |
| 164 | 164 | ||
| 165 | if '-e' not in cmd_argv: | 165 | if '-e' not in cmd_argv: |
| 166 | if not args: | 166 | if not args: |
diff --git a/subcmds/help.py b/subcmds/help.py index 57fb3cc2..15aab7f9 100644 --- a/subcmds/help.py +++ b/subcmds/help.py | |||
| @@ -126,7 +126,7 @@ Displays detailed usage information about a command. | |||
| 126 | 126 | ||
| 127 | p('%s', title) | 127 | p('%s', title) |
| 128 | self.nl() | 128 | self.nl() |
| 129 | p('%s', ''.ljust(len(title),section_type[0])) | 129 | p('%s', ''.ljust(len(title), section_type[0])) |
| 130 | self.nl() | 130 | self.nl() |
| 131 | continue | 131 | continue |
| 132 | 132 | ||
diff --git a/subcmds/info.py b/subcmds/info.py new file mode 100644 index 00000000..3a25e3b5 --- /dev/null +++ b/subcmds/info.py | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | # | ||
| 2 | # Copyright (C) 2012 The Android Open Source Project | ||
| 3 | # | ||
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | # you may not use this file except in compliance with the License. | ||
| 6 | # You may obtain a copy of the License at | ||
| 7 | # | ||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | # | ||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | # See the License for the specific language governing permissions and | ||
| 14 | # limitations under the License. | ||
| 15 | |||
| 16 | from command import PagedCommand | ||
| 17 | from color import Coloring | ||
| 18 | from error import NoSuchProjectError | ||
| 19 | from git_refs import R_M | ||
| 20 | |||
| 21 | class _Coloring(Coloring): | ||
| 22 | def __init__(self, config): | ||
| 23 | Coloring.__init__(self, config, "status") | ||
| 24 | |||
| 25 | class Info(PagedCommand): | ||
| 26 | common = True | ||
| 27 | helpSummary = "Get info on the manifest branch, current branch or unmerged branches" | ||
| 28 | helpUsage = "%prog [-dl] [-o [-b]] [<project>...]" | ||
| 29 | |||
| 30 | def _Options(self, p, show_smart=True): | ||
| 31 | p.add_option('-d', '--diff', | ||
| 32 | dest='all', action='store_true', | ||
| 33 | help="show full info and commit diff including remote branches") | ||
| 34 | p.add_option('-o', '--overview', | ||
| 35 | dest='overview', action='store_true', | ||
| 36 | help='show overview of all local commits') | ||
| 37 | p.add_option('-b', '--current-branch', | ||
| 38 | dest="current_branch", action="store_true", | ||
| 39 | help="consider only checked out branches") | ||
| 40 | p.add_option('-l', '--local-only', | ||
| 41 | dest="local", action="store_true", | ||
| 42 | help="Disable all remote operations") | ||
| 43 | |||
| 44 | |||
| 45 | def Execute(self, opt, args): | ||
| 46 | self.out = _Coloring(self.manifest.globalConfig) | ||
| 47 | self.heading = self.out.printer('heading', attr = 'bold') | ||
| 48 | self.headtext = self.out.printer('headtext', fg = 'yellow') | ||
| 49 | self.redtext = self.out.printer('redtext', fg = 'red') | ||
| 50 | self.sha = self.out.printer("sha", fg = 'yellow') | ||
| 51 | self.text = self.out.printer('text') | ||
| 52 | self.dimtext = self.out.printer('dimtext', attr = 'dim') | ||
| 53 | |||
| 54 | self.opt = opt | ||
| 55 | |||
| 56 | mergeBranch = self.manifest.manifestProject.config.GetBranch("default").merge | ||
| 57 | |||
| 58 | self.heading("Manifest branch: ") | ||
| 59 | self.headtext(self.manifest.default.revisionExpr) | ||
| 60 | self.out.nl() | ||
| 61 | self.heading("Manifest merge branch: ") | ||
| 62 | self.headtext(mergeBranch) | ||
| 63 | self.out.nl() | ||
| 64 | |||
| 65 | self.printSeparator() | ||
| 66 | |||
| 67 | if not opt.overview: | ||
| 68 | self.printDiffInfo(args) | ||
| 69 | else: | ||
| 70 | self.printCommitOverview(args) | ||
| 71 | |||
| 72 | def printSeparator(self): | ||
| 73 | self.text("----------------------------") | ||
| 74 | self.out.nl() | ||
| 75 | |||
| 76 | def printDiffInfo(self, args): | ||
| 77 | try: | ||
| 78 | projs = self.GetProjects(args) | ||
| 79 | except NoSuchProjectError: | ||
| 80 | return | ||
| 81 | |||
| 82 | for p in projs: | ||
| 83 | self.heading("Project: ") | ||
| 84 | self.headtext(p.name) | ||
| 85 | self.out.nl() | ||
| 86 | |||
| 87 | self.heading("Mount path: ") | ||
| 88 | self.headtext(p.worktree) | ||
| 89 | self.out.nl() | ||
| 90 | |||
| 91 | self.heading("Current revision: ") | ||
| 92 | self.headtext(p.revisionExpr) | ||
| 93 | self.out.nl() | ||
| 94 | |||
| 95 | localBranches = p.GetBranches().keys() | ||
| 96 | self.heading("Local Branches: ") | ||
| 97 | self.redtext(str(len(localBranches))) | ||
| 98 | if len(localBranches) > 0: | ||
| 99 | self.text(" [") | ||
| 100 | self.text(", ".join(localBranches)) | ||
| 101 | self.text("]") | ||
| 102 | self.out.nl() | ||
| 103 | |||
| 104 | if self.opt.all: | ||
| 105 | self.findRemoteLocalDiff(p) | ||
| 106 | |||
| 107 | self.printSeparator() | ||
| 108 | |||
| 109 | def findRemoteLocalDiff(self, project): | ||
| 110 | #Fetch all the latest commits | ||
| 111 | if not self.opt.local: | ||
| 112 | project.Sync_NetworkHalf(quiet=True, current_branch_only=True) | ||
| 113 | |||
| 114 | logTarget = R_M + self.manifest.default.revisionExpr | ||
| 115 | |||
| 116 | bareTmp = project.bare_git._bare | ||
| 117 | project.bare_git._bare = False | ||
| 118 | localCommits = project.bare_git.rev_list( | ||
| 119 | '--abbrev=8', | ||
| 120 | '--abbrev-commit', | ||
| 121 | '--pretty=oneline', | ||
| 122 | logTarget + "..", | ||
| 123 | '--') | ||
| 124 | |||
| 125 | originCommits = project.bare_git.rev_list( | ||
| 126 | '--abbrev=8', | ||
| 127 | '--abbrev-commit', | ||
| 128 | '--pretty=oneline', | ||
| 129 | ".." + logTarget, | ||
| 130 | '--') | ||
| 131 | project.bare_git._bare = bareTmp | ||
| 132 | |||
| 133 | self.heading("Local Commits: ") | ||
| 134 | self.redtext(str(len(localCommits))) | ||
| 135 | self.dimtext(" (on current branch)") | ||
| 136 | self.out.nl() | ||
| 137 | |||
| 138 | for c in localCommits: | ||
| 139 | split = c.split() | ||
| 140 | self.sha(split[0] + " ") | ||
| 141 | self.text("".join(split[1:])) | ||
| 142 | self.out.nl() | ||
| 143 | |||
| 144 | self.printSeparator() | ||
| 145 | |||
| 146 | self.heading("Remote Commits: ") | ||
| 147 | self.redtext(str(len(originCommits))) | ||
| 148 | self.out.nl() | ||
| 149 | |||
| 150 | for c in originCommits: | ||
| 151 | split = c.split() | ||
| 152 | self.sha(split[0] + " ") | ||
| 153 | self.text("".join(split[1:])) | ||
| 154 | self.out.nl() | ||
| 155 | |||
| 156 | def printCommitOverview(self, args): | ||
| 157 | all_branches = [] | ||
| 158 | for project in self.GetProjects(args): | ||
| 159 | br = [project.GetUploadableBranch(x) | ||
| 160 | for x in project.GetBranches().keys()] | ||
| 161 | br = [x for x in br if x] | ||
| 162 | if self.opt.current_branch: | ||
| 163 | br = [x for x in br if x.name == project.CurrentBranch] | ||
| 164 | all_branches.extend(br) | ||
| 165 | |||
| 166 | if not all_branches: | ||
| 167 | return | ||
| 168 | |||
| 169 | self.out.nl() | ||
| 170 | self.heading('Projects Overview') | ||
| 171 | project = None | ||
| 172 | |||
| 173 | for branch in all_branches: | ||
| 174 | if project != branch.project: | ||
| 175 | project = branch.project | ||
| 176 | self.out.nl() | ||
| 177 | self.headtext(project.relpath) | ||
| 178 | self.out.nl() | ||
| 179 | |||
| 180 | commits = branch.commits | ||
| 181 | date = branch.date | ||
| 182 | self.text('%s %-33s (%2d commit%s, %s)' % ( | ||
| 183 | branch.name == project.CurrentBranch and '*' or ' ', | ||
| 184 | branch.name, | ||
| 185 | len(commits), | ||
| 186 | len(commits) != 1 and 's' or '', | ||
| 187 | date)) | ||
| 188 | self.out.nl() | ||
| 189 | |||
| 190 | for commit in commits: | ||
| 191 | split = commit.split() | ||
| 192 | self.text('{0:38}{1} '.format('','-')) | ||
| 193 | self.sha(split[0] + " ") | ||
| 194 | self.text("".join(split[1:])) | ||
| 195 | self.out.nl() | ||
diff --git a/subcmds/init.py b/subcmds/init.py index 7aaa7f17..eeadc70d 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -279,14 +279,14 @@ to update the working directory files. | |||
| 279 | print() | 279 | print() |
| 280 | print("Testing colorized output (for 'repo diff', 'repo status'):") | 280 | print("Testing colorized output (for 'repo diff', 'repo status'):") |
| 281 | 281 | ||
| 282 | for c in ['black','red','green','yellow','blue','magenta','cyan']: | 282 | for c in ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan']: |
| 283 | out.write(' ') | 283 | out.write(' ') |
| 284 | out.printer(fg=c)(' %-6s ', c) | 284 | out.printer(fg=c)(' %-6s ', c) |
| 285 | out.write(' ') | 285 | out.write(' ') |
| 286 | out.printer(fg='white', bg='black')(' %s ' % 'white') | 286 | out.printer(fg='white', bg='black')(' %s ' % 'white') |
| 287 | out.nl() | 287 | out.nl() |
| 288 | 288 | ||
| 289 | for c in ['bold','dim','ul','reverse']: | 289 | for c in ['bold', 'dim', 'ul', 'reverse']: |
| 290 | out.write(' ') | 290 | out.write(' ') |
| 291 | out.printer(fg='black', attr=c)(' %-6s ', c) | 291 | out.printer(fg='black', attr=c)(' %-6s ', c) |
| 292 | out.nl() | 292 | out.nl() |
diff --git a/subcmds/overview.py b/subcmds/overview.py index 9e6100b4..418459ae 100644 --- a/subcmds/overview.py +++ b/subcmds/overview.py | |||
| @@ -55,8 +55,11 @@ are displayed. | |||
| 55 | def __init__(self, config): | 55 | def __init__(self, config): |
| 56 | Coloring.__init__(self, config, 'status') | 56 | Coloring.__init__(self, config, 'status') |
| 57 | self.project = self.printer('header', attr='bold') | 57 | self.project = self.printer('header', attr='bold') |
| 58 | self.text = self.printer('text') | ||
| 58 | 59 | ||
| 59 | out = Report(all_branches[0].project.config) | 60 | out = Report(all_branches[0].project.config) |
| 61 | out.text("Deprecated. See repo info -o.") | ||
| 62 | out.nl() | ||
| 60 | out.project('Projects Overview') | 63 | out.project('Projects Overview') |
| 61 | out.nl() | 64 | out.nl() |
| 62 | 65 | ||
diff --git a/subcmds/sync.py b/subcmds/sync.py index a64f2c45..5b3dca78 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -150,22 +150,22 @@ later is required to fix a server side protocol bug. | |||
| 150 | p.add_option('-f', '--force-broken', | 150 | p.add_option('-f', '--force-broken', |
| 151 | dest='force_broken', action='store_true', | 151 | dest='force_broken', action='store_true', |
| 152 | help="continue sync even if a project fails to sync") | 152 | help="continue sync even if a project fails to sync") |
| 153 | p.add_option('-l','--local-only', | 153 | p.add_option('-l', '--local-only', |
| 154 | dest='local_only', action='store_true', | 154 | dest='local_only', action='store_true', |
| 155 | help="only update working tree, don't fetch") | 155 | help="only update working tree, don't fetch") |
| 156 | p.add_option('-n','--network-only', | 156 | p.add_option('-n', '--network-only', |
| 157 | dest='network_only', action='store_true', | 157 | dest='network_only', action='store_true', |
| 158 | help="fetch only, don't update working tree") | 158 | help="fetch only, don't update working tree") |
| 159 | p.add_option('-d','--detach', | 159 | p.add_option('-d', '--detach', |
| 160 | dest='detach_head', action='store_true', | 160 | dest='detach_head', action='store_true', |
| 161 | help='detach projects back to manifest revision') | 161 | help='detach projects back to manifest revision') |
| 162 | p.add_option('-c','--current-branch', | 162 | p.add_option('-c', '--current-branch', |
| 163 | dest='current_branch_only', action='store_true', | 163 | dest='current_branch_only', action='store_true', |
| 164 | help='fetch only current branch from server') | 164 | help='fetch only current branch from server') |
| 165 | p.add_option('-q','--quiet', | 165 | p.add_option('-q', '--quiet', |
| 166 | dest='quiet', action='store_true', | 166 | dest='quiet', action='store_true', |
| 167 | help='be more quiet') | 167 | help='be more quiet') |
| 168 | p.add_option('-j','--jobs', | 168 | p.add_option('-j', '--jobs', |
| 169 | dest='jobs', action='store', type='int', | 169 | dest='jobs', action='store', type='int', |
| 170 | help="projects to fetch simultaneously (default %d)" % self.jobs) | 170 | help="projects to fetch simultaneously (default %d)" % self.jobs) |
| 171 | p.add_option('-m', '--manifest-name', | 171 | p.add_option('-m', '--manifest-name', |
| @@ -197,62 +197,62 @@ later is required to fix a server side protocol bug. | |||
| 197 | help=SUPPRESS_HELP) | 197 | help=SUPPRESS_HELP) |
| 198 | 198 | ||
| 199 | def _FetchHelper(self, opt, project, lock, fetched, pm, sem, err_event): | 199 | def _FetchHelper(self, opt, project, lock, fetched, pm, sem, err_event): |
| 200 | """Main function of the fetch threads when jobs are > 1. | 200 | """Main function of the fetch threads when jobs are > 1. |
| 201 | 201 | ||
| 202 | Args: | 202 | Args: |
| 203 | opt: Program options returned from optparse. See _Options(). | 203 | opt: Program options returned from optparse. See _Options(). |
| 204 | project: Project object for the project to fetch. | 204 | project: Project object for the project to fetch. |
| 205 | lock: Lock for accessing objects that are shared amongst multiple | 205 | lock: Lock for accessing objects that are shared amongst multiple |
| 206 | _FetchHelper() threads. | 206 | _FetchHelper() threads. |
| 207 | fetched: set object that we will add project.gitdir to when we're done | 207 | fetched: set object that we will add project.gitdir to when we're done |
| 208 | (with our lock held). | 208 | (with our lock held). |
| 209 | pm: Instance of a Project object. We will call pm.update() (with our | 209 | pm: Instance of a Project object. We will call pm.update() (with our |
| 210 | lock held). | 210 | lock held). |
| 211 | sem: We'll release() this semaphore when we exit so that another thread | 211 | sem: We'll release() this semaphore when we exit so that another thread |
| 212 | can be started up. | 212 | can be started up. |
| 213 | err_event: We'll set this event in the case of an error (after printing | 213 | err_event: We'll set this event in the case of an error (after printing |
| 214 | out info about the error). | 214 | out info about the error). |
| 215 | """ | 215 | """ |
| 216 | # We'll set to true once we've locked the lock. | 216 | # We'll set to true once we've locked the lock. |
| 217 | did_lock = False | 217 | did_lock = False |
| 218 | 218 | ||
| 219 | # Encapsulate everything in a try/except/finally so that: | 219 | # Encapsulate everything in a try/except/finally so that: |
| 220 | # - We always set err_event in the case of an exception. | 220 | # - We always set err_event in the case of an exception. |
| 221 | # - We always make sure we call sem.release(). | 221 | # - We always make sure we call sem.release(). |
| 222 | # - We always make sure we unlock the lock if we locked it. | 222 | # - We always make sure we unlock the lock if we locked it. |
| 223 | try: | ||
| 223 | try: | 224 | try: |
| 224 | try: | 225 | start = time.time() |
| 225 | start = time.time() | 226 | success = project.Sync_NetworkHalf( |
| 226 | success = project.Sync_NetworkHalf( | 227 | quiet=opt.quiet, |
| 227 | quiet=opt.quiet, | 228 | current_branch_only=opt.current_branch_only, |
| 228 | current_branch_only=opt.current_branch_only, | 229 | clone_bundle=not opt.no_clone_bundle) |
| 229 | clone_bundle=not opt.no_clone_bundle) | 230 | self._fetch_times.Set(project, time.time() - start) |
| 230 | self._fetch_times.Set(project, time.time() - start) | 231 | |
| 231 | 232 | # Lock around all the rest of the code, since printing, updating a set | |
| 232 | # Lock around all the rest of the code, since printing, updating a set | 233 | # and Progress.update() are not thread safe. |
| 233 | # and Progress.update() are not thread safe. | 234 | lock.acquire() |
| 234 | lock.acquire() | 235 | did_lock = True |
| 235 | did_lock = True | 236 | |
| 236 | 237 | if not success: | |
| 237 | if not success: | 238 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) |
| 238 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) | 239 | if opt.force_broken: |
| 239 | if opt.force_broken: | 240 | print('warn: --force-broken, continuing to sync', |
| 240 | print('warn: --force-broken, continuing to sync', | 241 | file=sys.stderr) |
| 241 | file=sys.stderr) | 242 | else: |
| 242 | else: | 243 | raise _FetchError() |
| 243 | raise _FetchError() | ||
| 244 | 244 | ||
| 245 | fetched.add(project.gitdir) | 245 | fetched.add(project.gitdir) |
| 246 | pm.update() | 246 | pm.update() |
| 247 | except _FetchError: | 247 | except _FetchError: |
| 248 | err_event.set() | 248 | err_event.set() |
| 249 | except: | 249 | except: |
| 250 | err_event.set() | 250 | err_event.set() |
| 251 | raise | 251 | raise |
| 252 | finally: | 252 | finally: |
| 253 | if did_lock: | 253 | if did_lock: |
| 254 | lock.release() | 254 | lock.release() |
| 255 | sem.release() | 255 | sem.release() |
| 256 | 256 | ||
| 257 | def _Fetch(self, projects, opt): | 257 | def _Fetch(self, projects, opt): |
| 258 | fetched = set() | 258 | fetched = set() |
| @@ -379,36 +379,36 @@ later is required to fix a server side protocol bug. | |||
| 379 | if path not in new_project_paths: | 379 | if path not in new_project_paths: |
| 380 | # If the path has already been deleted, we don't need to do it | 380 | # If the path has already been deleted, we don't need to do it |
| 381 | if os.path.exists(self.manifest.topdir + '/' + path): | 381 | if os.path.exists(self.manifest.topdir + '/' + path): |
| 382 | project = Project( | 382 | project = Project( |
| 383 | manifest = self.manifest, | 383 | manifest = self.manifest, |
| 384 | name = path, | 384 | name = path, |
| 385 | remote = RemoteSpec('origin'), | 385 | remote = RemoteSpec('origin'), |
| 386 | gitdir = os.path.join(self.manifest.topdir, | 386 | gitdir = os.path.join(self.manifest.topdir, |
| 387 | path, '.git'), | 387 | path, '.git'), |
| 388 | worktree = os.path.join(self.manifest.topdir, path), | 388 | worktree = os.path.join(self.manifest.topdir, path), |
| 389 | relpath = path, | 389 | relpath = path, |
| 390 | revisionExpr = 'HEAD', | 390 | revisionExpr = 'HEAD', |
| 391 | revisionId = None, | 391 | revisionId = None, |
| 392 | groups = None) | 392 | groups = None) |
| 393 | 393 | ||
| 394 | if project.IsDirty(): | 394 | if project.IsDirty(): |
| 395 | print('error: Cannot remove project "%s": uncommitted changes' | 395 | print('error: Cannot remove project "%s": uncommitted changes' |
| 396 | 'are present' % project.relpath, file=sys.stderr) | 396 | 'are present' % project.relpath, file=sys.stderr) |
| 397 | print(' commit changes, then run sync again', | 397 | print(' commit changes, then run sync again', |
| 398 | file=sys.stderr) | 398 | file=sys.stderr) |
| 399 | return -1 | 399 | return -1 |
| 400 | else: | 400 | else: |
| 401 | print('Deleting obsolete path %s' % project.worktree, | 401 | print('Deleting obsolete path %s' % project.worktree, |
| 402 | file=sys.stderr) | 402 | file=sys.stderr) |
| 403 | shutil.rmtree(project.worktree) | 403 | shutil.rmtree(project.worktree) |
| 404 | # Try deleting parent subdirs if they are empty | 404 | # Try deleting parent subdirs if they are empty |
| 405 | project_dir = os.path.dirname(project.worktree) | 405 | project_dir = os.path.dirname(project.worktree) |
| 406 | while project_dir != self.manifest.topdir: | 406 | while project_dir != self.manifest.topdir: |
| 407 | try: | 407 | try: |
| 408 | os.rmdir(project_dir) | 408 | os.rmdir(project_dir) |
| 409 | except OSError: | 409 | except OSError: |
| 410 | break | 410 | break |
| 411 | project_dir = os.path.dirname(project_dir) | 411 | project_dir = os.path.dirname(project_dir) |
| 412 | 412 | ||
| 413 | new_project_paths.sort() | 413 | new_project_paths.sort() |
| 414 | fd = open(file_path, 'w') | 414 | fd = open(file_path, 'w') |
diff --git a/subcmds/upload.py b/subcmds/upload.py index a6ada337..e314032a 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -50,7 +50,7 @@ def _SplitEmails(values): | |||
| 50 | class Upload(InteractiveCommand): | 50 | class Upload(InteractiveCommand): |
| 51 | common = True | 51 | common = True |
| 52 | helpSummary = "Upload changes for code review" | 52 | helpSummary = "Upload changes for code review" |
| 53 | helpUsage=""" | 53 | helpUsage = """ |
| 54 | %prog [--re --cc] [<project>]... | 54 | %prog [--re --cc] [<project>]... |
| 55 | """ | 55 | """ |
| 56 | helpDescription = """ | 56 | helpDescription = """ |
| @@ -312,23 +312,23 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 312 | 312 | ||
| 313 | # Check if there are local changes that may have been forgotten | 313 | # Check if there are local changes that may have been forgotten |
| 314 | if branch.project.HasChanges(): | 314 | if branch.project.HasChanges(): |
| 315 | key = 'review.%s.autoupload' % branch.project.remote.review | 315 | key = 'review.%s.autoupload' % branch.project.remote.review |
| 316 | answer = branch.project.config.GetBoolean(key) | 316 | answer = branch.project.config.GetBoolean(key) |
| 317 | 317 | ||
| 318 | # if they want to auto upload, let's not ask because it could be automated | 318 | # if they want to auto upload, let's not ask because it could be automated |
| 319 | if answer is None: | 319 | if answer is None: |
| 320 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') | 320 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') |
| 321 | a = sys.stdin.readline().strip().lower() | 321 | a = sys.stdin.readline().strip().lower() |
| 322 | if a not in ('y', 'yes', 't', 'true', 'on'): | 322 | if a not in ('y', 'yes', 't', 'true', 'on'): |
| 323 | print("skipping upload", file=sys.stderr) | 323 | print("skipping upload", file=sys.stderr) |
| 324 | branch.uploaded = False | 324 | branch.uploaded = False |
| 325 | branch.error = 'User aborted' | 325 | branch.error = 'User aborted' |
| 326 | continue | 326 | continue |
| 327 | 327 | ||
| 328 | # Check if topic branches should be sent to the server during upload | 328 | # Check if topic branches should be sent to the server during upload |
| 329 | if opt.auto_topic is not True: | 329 | if opt.auto_topic is not True: |
| 330 | key = 'review.%s.uploadtopic' % branch.project.remote.review | 330 | key = 'review.%s.uploadtopic' % branch.project.remote.review |
| 331 | opt.auto_topic = branch.project.config.GetBoolean(key) | 331 | opt.auto_topic = branch.project.config.GetBoolean(key) |
| 332 | 332 | ||
| 333 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) | 333 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) |
| 334 | branch.uploaded = True | 334 | branch.uploaded = True |
| @@ -355,11 +355,11 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 355 | print() | 355 | print() |
| 356 | 356 | ||
| 357 | for branch in todo: | 357 | for branch in todo: |
| 358 | if branch.uploaded: | 358 | if branch.uploaded: |
| 359 | print('[OK ] %-15s %s' % ( | 359 | print('[OK ] %-15s %s' % ( |
| 360 | branch.project.relpath + '/', | 360 | branch.project.relpath + '/', |
| 361 | branch.name), | 361 | branch.name), |
| 362 | file=sys.stderr) | 362 | file=sys.stderr) |
| 363 | 363 | ||
| 364 | if have_errors: | 364 | if have_errors: |
| 365 | sys.exit(1) | 365 | sys.exit(1) |
| @@ -397,7 +397,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 397 | reviewers = _SplitEmails(opt.reviewers) | 397 | reviewers = _SplitEmails(opt.reviewers) |
| 398 | if opt.cc: | 398 | if opt.cc: |
| 399 | cc = _SplitEmails(opt.cc) | 399 | cc = _SplitEmails(opt.cc) |
| 400 | people = (reviewers,cc) | 400 | people = (reviewers, cc) |
| 401 | 401 | ||
| 402 | if not pending: | 402 | if not pending: |
| 403 | print("no branches ready for upload", file=sys.stderr) | 403 | print("no branches ready for upload", file=sys.stderr) |
