Commit 73aacbda authored by Gustavo Niemeyer's avatar Gustavo Niemeyer Committed by Russ Cox

codereview: fix clpatch with empty diffs

Avoid passing the placeholder diff to hgpatch, so that
clpatch-ing an empty diff grabs the metadata and warns
about it being empty, rather than failing with a
hard-to-debug problem ("mkdir: no such file or dir",
no metadata, etc).

R=rsc
CC=golang-dev
https://golang.org/cl/4172060
parent 83da7d15
...@@ -1136,11 +1136,14 @@ def clpatch(ui, repo, clname, **opts): ...@@ -1136,11 +1136,14 @@ def clpatch(ui, repo, clname, **opts):
return missing_codereview return missing_codereview
cl, patch, err = DownloadCL(ui, repo, clname) cl, patch, err = DownloadCL(ui, repo, clname)
if err != "":
return err
if patch == emptydiff:
return "codereview issue %s has no diff" % clname
argv = ["hgpatch"] argv = ["hgpatch"]
if opts["no_incoming"]: if opts["no_incoming"]:
argv += ["--checksync=false"] argv += ["--checksync=false"]
if err != "":
return err
try: try:
cmd = subprocess.Popen(argv, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, close_fds=sys.platform != "win32") cmd = subprocess.Popen(argv, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, close_fds=sys.platform != "win32")
except: except:
...@@ -1151,6 +1154,8 @@ def clpatch(ui, repo, clname, **opts): ...@@ -1151,6 +1154,8 @@ def clpatch(ui, repo, clname, **opts):
return "hgpatch failed" return "hgpatch failed"
cl.local = True cl.local = True
cl.files = out.strip().split() cl.files = out.strip().split()
if not cl.files:
return "codereview issue %s has no diff" % clname
files = ChangedFiles(ui, repo, [], opts) files = ChangedFiles(ui, repo, [], opts)
extra = Sub(cl.files, files) extra = Sub(cl.files, files)
if extra: if extra:
......
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