Commit dde666da authored by Russ Cox's avatar Russ Cox

code review: avoid subject changes, fix http_proxy submit bug

R=r
http://go/go-review/1016021
parent f4e3947f
...@@ -136,13 +136,19 @@ class CL(object): ...@@ -136,13 +136,19 @@ class CL(object):
f.close() f.close()
os.rename(path+'!', path) os.rename(path+'!', path)
if self.web: if self.web:
EditDesc(self.name, subject=line1(self.desc), desc=self.desc, EditDesc(self.name, desc=self.desc,
reviewers=JoinComma(self.reviewer), cc=JoinComma(self.cc)) reviewers=JoinComma(self.reviewer), cc=JoinComma(self.cc))
def Delete(self, ui, repo): def Delete(self, ui, repo):
dir = CodeReviewDir(ui, repo) dir = CodeReviewDir(ui, repo)
os.unlink(dir + "/cl." + self.name) os.unlink(dir + "/cl." + self.name)
def Subject(self):
s = line1(self.desc)
if self.name != "new":
s = "codereview %s: %s" % (self.name, s)
return s
def Upload(self, ui, repo, send_mail=False): def Upload(self, ui, repo, send_mail=False):
os.chdir(repo.root) os.chdir(repo.root)
form_fields = [ form_fields = [
...@@ -151,7 +157,9 @@ class CL(object): ...@@ -151,7 +157,9 @@ class CL(object):
("cc", JoinComma(self.cc)), ("cc", JoinComma(self.cc)),
("description", self.desc), ("description", self.desc),
("base_hashes", ""), ("base_hashes", ""),
("subject", line1(self.desc)), # Would prefer not to change the subject
# on reupload, but /upload requires it.
("subject", self.Subject()),
] ]
# NOTE(rsc): This duplicates too much of RealMain, # NOTE(rsc): This duplicates too much of RealMain,
...@@ -297,6 +305,7 @@ class LoadCLThread(threading.Thread): ...@@ -297,6 +305,7 @@ class LoadCLThread(threading.Thread):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.ui = ui self.ui = ui
self.repo = repo self.repo = repo
self.dir = dir
self.f = f self.f = f
self.web = web self.web = web
self.cl = None self.cl = None
...@@ -441,10 +450,18 @@ def Add(l1, l2): ...@@ -441,10 +450,18 @@ def Add(l1, l2):
def Intersect(l1, l2): def Intersect(l1, l2):
return [l for l in l1 if l in l2] return [l for l in l1 if l in l2]
def Incoming(ui, repo, opts, op): def getremote(ui, repo, opts):
# save $http_proxy; creating the HTTP repo object will
# delete it in an attempt to "help"
proxy = os.environ.get('http_proxy')
source, _, _ = hg.parseurl(ui.expandpath("default"), None) source, _, _ = hg.parseurl(ui.expandpath("default"), None)
other = hg.repository(cmdutil.remoteui(repo, opts), source) other = hg.repository(cmdutil.remoteui(repo, opts), source)
_, incoming, _ = repo.findcommonincoming(other) if proxy is not None:
os.environ['http_proxy'] = proxy
return other
def Incoming(ui, repo, opts):
_, incoming, _ = repo.findcommonincoming(getremote(ui, repo, opts))
return incoming return incoming
def EditCL(ui, repo, cl): def EditCL(ui, repo, cl):
...@@ -692,8 +709,7 @@ def mail(ui, repo, *pats, **opts): ...@@ -692,8 +709,7 @@ def mail(ui, repo, *pats, **opts):
pmsg = "Hello " + JoinComma(cl.reviewer) + ",\n" pmsg = "Hello " + JoinComma(cl.reviewer) + ",\n"
pmsg += "\n" pmsg += "\n"
pmsg += "I'd like you to review the following change.\n" pmsg += "I'd like you to review the following change.\n"
subject = "code review %s: %s" % (cl.name, line1(cl.desc)) PostMessage(cl.name, pmsg, send_mail="checked", subject=cl.Subject())
PostMessage(cl.name, pmsg, send_mail="checked", subject=subject)
def nocommit(ui, repo, *pats, **opts): def nocommit(ui, repo, *pats, **opts):
return "The codereview extension is enabled; do not use commit." return "The codereview extension is enabled; do not use commit."
...@@ -726,7 +742,7 @@ def submit(ui, repo, *pats, **opts): ...@@ -726,7 +742,7 @@ def submit(ui, repo, *pats, **opts):
Bails out if the local repository is not in sync with the remote one. Bails out if the local repository is not in sync with the remote one.
""" """
repo.ui.quiet = True repo.ui.quiet = True
if not opts["no_incoming"] and Incoming(ui, repo, opts, "submit"): if not opts["no_incoming"] and Incoming(ui, repo, opts):
return "local repository out of date; must sync before submit" return "local repository out of date; must sync before submit"
cl, err = CommandLineCL(ui, repo, pats, opts) cl, err = CommandLineCL(ui, repo, pats, opts)
...@@ -776,8 +792,7 @@ def submit(ui, repo, *pats, **opts): ...@@ -776,8 +792,7 @@ def submit(ui, repo, *pats, **opts):
# push changes to remote. # push changes to remote.
# if it works, we're committed. # if it works, we're committed.
# if not, roll back # if not, roll back
dest, _, _ = hg.parseurl(ui.expandpath("default"), None) other = getremote(ui, repo, opts)
other = hg.repository(cmdutil.remoteui(repo, opts), dest)
r = repo.push(other, False, None) r = repo.push(other, False, None)
if r == 0: if r == 0:
repo.rollback() repo.rollback()
...@@ -804,8 +819,7 @@ def sync(ui, repo, **opts): ...@@ -804,8 +819,7 @@ def sync(ui, repo, **opts):
""" """
ui.status = sync_note ui.status = sync_note
ui.note = sync_note ui.note = sync_note
source, _, _ = hg.parseurl(ui.expandpath("default"), None) other = getremote(ui, repo, opts)
other = hg.repository(cmdutil.remoteui(repo, opts), source)
modheads = repo.pull(other) modheads = repo.pull(other)
err = commands.postincoming(ui, repo, modheads, True, "tip") err = commands.postincoming(ui, repo, modheads, True, "tip")
if err: if err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment