From: Gustavo Niemeyer Date: Wed, 23 Feb 2011 16:48:40 +0000 (-0500) Subject: codereview: fix clpatch with empty diffs X-Git-Tag: weekly.2011-02-24~26 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=73aacbda205127dd5a51eae4ab02869a98f92404;p=gostls13.git 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 --- diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py index 96efc855b6..fa703c711f 100644 --- a/lib/codereview/codereview.py +++ b/lib/codereview/codereview.py @@ -1136,11 +1136,14 @@ def clpatch(ui, repo, clname, **opts): return missing_codereview cl, patch, err = DownloadCL(ui, repo, clname) + if err != "": + return err + if patch == emptydiff: + return "codereview issue %s has no diff" % clname + argv = ["hgpatch"] if opts["no_incoming"]: argv += ["--checksync=false"] - if err != "": - return err try: cmd = subprocess.Popen(argv, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, close_fds=sys.platform != "win32") except: @@ -1151,6 +1154,8 @@ def clpatch(ui, repo, clname, **opts): return "hgpatch failed" cl.local = True cl.files = out.strip().split() + if not cl.files: + return "codereview issue %s has no diff" % clname files = ChangedFiles(ui, repo, [], opts) extra = Sub(cl.files, files) if extra: