summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/codereview/codereview.py140
1 files changed, 13 insertions, 127 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py
index 36d7df199..bfa69fcc0 100644
--- a/lib/codereview/codereview.py
+++ b/lib/codereview/codereview.py
@@ -112,7 +112,6 @@ defaultcc = None
contributors = {}
missing_codereview = None
real_rollback = None
-releaseBranch = None
#######################################################################
# RE: UNICODE STRING HANDLING
@@ -1050,7 +1049,7 @@ def change(ui, repo, *pats, **opts):
if missing_codereview:
return missing_codereview
-
+
dirty = {}
if len(pats) > 0 and GoodCLName(pats[0]):
name = pats[0]
@@ -1063,8 +1062,6 @@ def change(ui, repo, *pats, **opts):
if not cl.local and (opts["stdin"] or not opts["stdout"]):
return "cannot change non-local CL " + name
else:
- if repo[None].branch() != "default":
- return "cannot run hg change outside default branch"
name = "new"
cl = CL("new")
dirty[cl] = True
@@ -1157,9 +1154,7 @@ def clpatch(ui, repo, clname, **opts):
Submitting an imported patch will keep the original author's
name as the Author: line but add your own name to a Committer: line.
"""
- if repo[None].branch() != "default":
- return "cannot run hg clpatch outside default branch"
- return clpatch_or_undo(ui, repo, clname, opts, mode="clpatch")
+ return clpatch_or_undo(ui, repo, clname, opts)
def undo(ui, repo, clname, **opts):
"""undo the effect of a CL
@@ -1168,66 +1163,7 @@ def undo(ui, repo, clname, **opts):
After creating the CL, opens the CL text for editing so that
you can add the reason for the undo to the description.
"""
- if repo[None].branch() != "default":
- return "cannot run hg undo outside default branch"
- return clpatch_or_undo(ui, repo, clname, opts, mode="undo")
-
-def release_apply(ui, repo, clname, **opts):
- """apply a CL to the release branch
-
- Creates a new CL copying a previously committed change
- from the main branch to the release branch.
- The current client must either be clean or already be in
- the release branch.
-
- The release branch must be created by starting with a
- clean client, disabling the code review plugin, and running:
-
- hg update weekly.YYYY-MM-DD
- hg branch release-branch.rNN
- hg commit -m 'create release-branch.rNN'
- hg push --new-branch
-
- Then re-enable the code review plugin.
-
- People can test the release branch by running
-
- hg update release-branch.rNN
-
- in a clean client. To return to the normal tree,
-
- hg update default
-
- Move changes since the weekly into the release branch
- using hg release-apply followed by the usual code review
- process and hg submit.
-
- When it comes time to tag the release, record the
- final long-form tag of the release-branch.rNN
- in the *default* branch's .hgtags file. That is, run
-
- hg update default
-
- and then edit .hgtags as you would for a weekly.
-
- """
- c = repo[None]
- if not releaseBranch:
- return "no active release branches"
- if c.branch() != releaseBranch:
- if c.modified() or c.added() or c.removed():
- raise util.Abort("uncommitted local changes - cannot switch branches")
- err = hg.clean(repo, releaseBranch)
- if err:
- return err
- try:
- err = clpatch_or_undo(ui, repo, clname, opts, mode="backport")
- if err:
- raise util.Abort(err)
- except Exception, e:
- hg.clean(repo, "default")
- raise e
- return None
+ return clpatch_or_undo(ui, repo, clname, opts, undo=True)
def rev2clname(rev):
# Extract CL name from revision description.
@@ -1249,24 +1185,15 @@ undoFooter = """
»»»
"""
-backportHeader = """[%s] %s
-
-««« CL %s / %s
-"""
-
-backportFooter = """
-»»»
-"""
-
# Implementation of clpatch/undo.
-def clpatch_or_undo(ui, repo, clname, opts, mode):
+def clpatch_or_undo(ui, repo, clname, opts, undo=False):
if missing_codereview:
return missing_codereview
- if mode == "undo" or mode == "backport":
+ if undo:
if hgversion < '1.4':
# Don't have cmdutil.match (see implementation of sync command).
- return "hg is too old to run hg %s - update to 1.4 or newer" % mode
+ return "hg is too old to run hg undo - update to 1.4 or newer"
# Find revision in Mercurial repository.
# Assume CL number is 7+ decimal digits.
@@ -1300,19 +1227,8 @@ def clpatch_or_undo(ui, repo, clname, opts, mode):
# Create fresh CL and start with patch that would reverse the change.
vers = short(rev.node())
cl = CL("new")
- desc = rev.description()
- if mode == "undo":
- cl.desc = (undoHeader % (clname, vers)) + desc + undoFooter
- else:
- cl.desc = (backportHeader % (releaseBranch, line1(desc), clname, vers)) + desc + undoFooter
- v1 = vers
- v0 = short(rev.parents()[0].node())
- if mode == "undo":
- arg = v1 + ":" + v0
- else:
- vers = v0
- arg = v0 + ":" + v1
- patch = RunShell(["hg", "diff", "--git", "-r", arg])
+ cl.desc = (undoHeader % (clname, vers)) + rev.description() + undoFooter
+ patch = RunShell(["hg", "diff", "--git", "-r", vers + ":" + short(rev.parents()[0].node())])
else: # clpatch
cl, vers, patch, err = DownloadCL(ui, repo, clname)
@@ -1333,10 +1249,10 @@ def clpatch_or_undo(ui, repo, clname, opts, mode):
if id != vers:
patch, err = portPatch(repo, patch, vers, id)
if err != "":
- return "codereview issue %s is out of date: %s (%s->%s)" % (clname, err, vers, id)
+ return "codereview issue %s is out of date: %s" % (clname, err)
argv = ["hgpatch"]
- if opts["no_incoming"] or mode == "backport":
+ if opts["no_incoming"]:
argv += ["--checksync=false"]
try:
cmd = subprocess.Popen(argv, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, close_fds=sys.platform != "win32")
@@ -1355,7 +1271,7 @@ def clpatch_or_undo(ui, repo, clname, opts, mode):
if extra:
ui.warn("warning: these files were listed in the patch but not changed:\n\t" + "\n\t".join(extra) + "\n")
cl.Flush(ui, repo)
- if mode == "undo":
+ if undo:
err = EditCL(ui, repo, cl)
if err != "":
return "CL created, but error editing: " + err
@@ -1590,7 +1506,7 @@ def reposetup(ui, repo):
def CheckContributor(ui, repo, user=None):
set_status("checking CONTRIBUTORS file")
- user, userline = FindContributor(ui, repo, user, warn=False)
+ _, userline = FindContributor(ui, repo, user, warn=False)
if not userline:
raise util.Abort("cannot find %s in CONTRIBUTORS" % (user,))
return userline
@@ -1608,7 +1524,7 @@ def FindContributor(ui, repo, user=None, warn=True):
if user not in contributors:
if warn:
ui.warn("warning: cannot find %s in CONTRIBUTORS\n" % (user,))
- return user, None
+ return None, None
user, email = contributors[user]
return email, "%s <%s>" % (user, email)
@@ -1734,14 +1650,6 @@ def submit(ui, repo, *pats, **opts):
if not cl.copied_from:
EditDesc(cl.name, closed=True, private=cl.private)
cl.Delete(ui, repo)
-
- c = repo[None]
- if c.branch() == releaseBranch and not c.modified() and not c.added() and not c.removed():
- ui.write("switching from %s to default branch.\n" % releaseBranch)
- err = hg.clean(repo, "default")
- if err:
- return err
- return None
def sync(ui, repo, **opts):
"""synchronize with remote repository
@@ -1914,15 +1822,6 @@ cmdtable = {
] + commands.walkopts,
"[-r reviewer] [--cc cc] [change# | file ...]"
),
- "^release-apply": (
- release_apply,
- [
- ('', 'ignore_hgpatch_failure', None, 'create CL metadata even if hgpatch fails'),
- ('', 'no_incoming', None, 'disable check for incoming changes'),
- ],
- "change#"
- ),
- # TODO: release-start, release-tag, weekly-tag
"^submit": (
submit,
review_opts + [
@@ -2364,19 +2263,6 @@ def RietveldSetup(ui, repo):
upload_options.email = "test@example.com"
rpc = None
-
- global releaseBranch
- tags = repo.branchtags().keys()
- if 'release-branch.r100' in tags:
- # NOTE(rsc): This tags.sort is going to get the wrong
- # answer when comparing release-branch.r99 with
- # release-branch.r100. If we do ten releases a year
- # that gives us 4 years before we have to worry about this.
- raise util.Abort('tags.sort needs to be fixed for release-branch.r100')
- tags.sort()
- for t in tags:
- if t.startswith('release-branch.'):
- releaseBranch = t
#######################################################################
# http://codereview.appspot.com/static/upload.py, heavily edited.