upload: Remove --replace option
It hasn't been necessary for a long time, and its
functionality can be accomplished with 'git push'.
Change-Id: Ic00d3adbe4cee7be3955117489c69d6e90106559
diff --git a/project.py b/project.py
index ce85b86..01dc867 100644
--- a/project.py
+++ b/project.py
@@ -111,7 +111,6 @@
self.project = project
self.branch = branch
self.base = base
- self.replace_changes = None
@property
def name(self):
@@ -151,7 +150,6 @@
def UploadForReview(self, people, auto_topic=False):
self.project.UploadForReview(self.name,
- self.replace_changes,
people,
auto_topic=auto_topic)
@@ -557,7 +555,6 @@
return None
def UploadForReview(self, branch=None,
- replace_changes=None,
people=([],[]),
auto_topic=False):
"""Uploads the named branch for code review.
@@ -600,9 +597,6 @@
cmd.append(branch.remote.SshReviewUrl(self.UserEmail))
cmd.append(ref_spec)
- if replace_changes:
- for change_id,commit_id in replace_changes.iteritems():
- cmd.append('%s:refs/changes/%s/new' % (commit_id, change_id))
if GitCommand(self, cmd, bare = True).Wait() != 0:
raise UploadError('Upload failed')
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 153b3eb..1964bff 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -47,7 +47,7 @@
common = True
helpSummary = "Upload changes for code review"
helpUsage="""
-%prog [--re --cc] {[<project>]... | --replace <project>}
+%prog [--re --cc] [<project>]...
"""
helpDescription = """
The '%prog' command is used to send changes to the Gerrit Code
@@ -67,12 +67,6 @@
new users. Users passed as --reviewers must already be registered
with the code review system, or the upload will fail.
-If the --replace option is passed the user can designate which
-existing change(s) in Gerrit match up to the commits in the branch
-being uploaded. For each matched pair of change,commit the commit
-will be added as a new patch set, completely replacing the set of
-files and description associated with the change in Gerrit.
-
Configuration
-------------
@@ -119,9 +113,6 @@
p.add_option('-t',
dest='auto_topic', action='store_true',
help='Send local branch name to Gerrit Code Review')
- p.add_option('--replace',
- dest='replace', action='store_true',
- help='Upload replacement patchesets from this branch')
p.add_option('--re', '--reviewers',
type='string', action='append', dest='reviewers',
help='Request reviews from these people.')
@@ -262,65 +253,6 @@
except:
return ""
- def _ReplaceBranch(self, opt, project, people):
- branch = project.CurrentBranch
- if not branch:
- print >>sys.stdout, "no branches ready for upload"
- return
- branch = project.GetUploadableBranch(branch)
- if not branch:
- print >>sys.stdout, "no branches ready for upload"
- return
-
- script = []
- script.append('# Replacing from branch %s' % branch.name)
-
- if len(branch.commits) == 1:
- change = self._FindGerritChange(branch)
- script.append('[%-6s] %s' % (change, branch.commits[0]))
- else:
- for commit in branch.commits:
- script.append('[ ] %s' % commit)
-
- script.append('')
- script.append('# Insert change numbers in the brackets to add a new patch set.')
- script.append('# To create a new change record, leave the brackets empty.')
-
- script = Editor.EditString("\n".join(script)).split("\n")
-
- change_re = re.compile(r'^\[\s*(\d{1,})\s*\]\s*([0-9a-f]{1,}) .*$')
- to_replace = dict()
- full_hashes = branch.unabbrev_commits
-
- for line in script:
- m = change_re.match(line)
- if m:
- c = m.group(1)
- f = m.group(2)
- try:
- f = full_hashes[f]
- except KeyError:
- print 'fh = %s' % full_hashes
- print >>sys.stderr, "error: commit %s not found" % f
- sys.exit(1)
- if c in to_replace:
- print >>sys.stderr,\
- "error: change %s cannot accept multiple commits" % c
- sys.exit(1)
- to_replace[c] = f
-
- if not to_replace:
- print >>sys.stderr, "error: no replacements specified"
- print >>sys.stderr, " use 'repo upload' without --replace"
- sys.exit(1)
-
- if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD:
- if not _ConfirmManyUploads(multiple_branches=True):
- _die("upload aborted by user")
-
- branch.replace_changes = to_replace
- self._UploadAndReport(opt, [branch], people)
-
def _UploadAndReport(self, opt, todo, original_people):
have_errors = False
for branch in todo:
@@ -383,14 +315,6 @@
cc = _SplitEmails(opt.cc)
people = (reviewers,cc)
- if opt.replace:
- if len(project_list) != 1:
- print >>sys.stderr, \
- 'error: --replace requires exactly one project'
- sys.exit(1)
- self._ReplaceBranch(opt, project_list[0], people)
- return
-
for project in project_list:
avail = project.GetUploadableBranches()
if avail: