]> Cypherpunks repositories - gostls13.git/commitdiff
add -l flag to hg gofmt.
authorRuss Cox <rsc@golang.org>
Thu, 5 Nov 2009 16:11:44 +0000 (08:11 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 5 Nov 2009 16:11:44 +0000 (08:11 -0800)
don't apply gofmt to non-go files during upload check.

R=r
http://go/go-review/1016048

lib/codereview/codereview.py

index 457b183516ec88cc5cdddb40f3aa73fe9d16b3fb..0e71a699e54107eed7427a053c467627838a5fa8 100644 (file)
@@ -562,8 +562,8 @@ def RelativePath(path, cwd):
 
 # Check that gofmt run on the list of files does not change them
 def CheckGofmt(ui, repo, files):
-       f = [f for f in files if f.endswith('.go')]
-       if not f:
+       files = [f for f in files if f.endswith('.go')]
+       if not files:
                return
        cwd = os.getcwd()
        files = [RelativePath(repo.root + '/' + f, cwd) for f in files]
@@ -761,7 +761,10 @@ def gofmt(ui, repo, *pats, **opts):
        cwd = os.getcwd()
        files = [RelativePath(repo.root + '/' + f, cwd) for f in files]
        try:
-               if os.spawnvp(os.P_WAIT, "gofmt", ["gofmt", "-l", "-w"] + files) != 0:
+               cmd = ["gofmt", "-l"]
+               if not opts["list"]:
+                       cmd += ["-w"]
+               if os.spawnvp(os.P_WAIT, "gofmt", cmd + files) != 0:
                        raise util.Abort("gofmt did not exit cleanly")
        except error.Abort, e:
                raise
@@ -1026,7 +1029,9 @@ cmdtable = {
        ),
        "^gofmt": (
                gofmt,
-               [],
+               [
+                       ('l', 'list', None, 'list files that would change, but do not edit them'),
+               ],
                "FILE ..."
        ),
        "^pending|p": (