This CL is based on the work and discussion in CL 24969 and CL 32392.
It simplifies the code further and makes trybots pass on Windows.
Also update the documentation and implementation of the subpackages
function slightly to make it more clear what it's doing.
Background
CL 24943 has made progress on fixing rename.Move behavior on Windows,
but hadn't re-enabled TestMoves at the time. CL 24969 attempted to do
so, but the tests weren't passing and it didn't get merged at the time.
Since that time, CL 65672 has fixed a bug in the subpackages function.
As a result, it's possible to simplify code in Move now.
The subpackages function returns a set of packages in the given srcDir
whose import path equals to root or has "root/" as the prefix.
After CL 65672, it correctly filters out ones that are not true
sub-packages of root. That's why it's not necessary to try to append
a trailing separator when doing the string replacement in Move now.
Given subpackages reports their import paths (always '/'-separated),
not filesystem paths, it's not necessary to use filepath.ToSlash either.
Updates golang/go#16384
Change-Id: Ia808fbaaeffe44ea1e51d7cc3ed9499bc2b438cf
Reviewed-on: https://go-review.googlesource.com/c/161777
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
When determining children of a parent directory, look for the expected /
to avoid processing directories that look similar but are not direct
descendants.
Fixesgolang/go#21991
Change-Id: I5c7d18076540e5588a856845f04645231856196f
Reviewed-on: https://go-review.googlesource.com/65672
Reviewed-by: Michael Matloob <matloob@golang.org>
In the package, the added import declarations used backslashes.
In the test, filenames in warning messages used backslashes.
Now both use forward slash.
Fixesgolang/go#16384
Change-Id: I43116aab0b3209305f23ed9def7c4adf3259941e
Reviewed-on: https://go-review.googlesource.com/24943
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The user may specify the diff tool using the -diffcmd flag.
+ test.
Also:
- eliminate redundant DryRun flag
- simplify Verbose messages using log.SetPrefix
Fixes issue #13355
Change-Id: I917edc73e31ddf0f5d5b9b30c43f826465529da1
Reviewed-on: https://go-review.googlesource.com/18208
Reviewed-by: Michael Matloob <matloob@golang.org>
Rename the package name of the external test package, e.g. <from>_test to <to>_test.
Rewrite the import statements of external test packages which import the renamed package.
Fixes#10507
Change-Id: Iad702189469c54776e55ed4a821610bd9977618c
Reviewed-on: https://go-review.googlesource.com/12637
Reviewed-by: Alan Donovan <adonovan@google.com>
And in gomvpkg, don't stop just because some packages had errors.
This is inevitable in a large GOPATH tree.
Fixes issue golang/go#10907
Change-Id: I9a60b070228d06d44880202eeef54394e914f5d5
Reviewed-on: https://go-review.googlesource.com/10715
Reviewed-by: Sameer Ajmani <sameer@golang.org>
This was not a visible bug since the only caller discards the relevant
result, so I also deleted the result.
Fixes#9999
Change-Id: I276d6523b2891d3cb9c8137448e1aed32a5fd197
Reviewed-on: https://go-review.googlesource.com/5921
Reviewed-by: Michael Matloob <michaelmatloob@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
The callbacks are intentionally concurrent, making this function very
easy to misuse (most clients so far have got it wrong, even my own).
Using a channel in the API makes the concurrency obvious, the
correct usage easy, and the client control flow simpler.
Change-Id: Ied38c3ed5c98b40eb1b322a984ed9dc092ac0918
Reviewed-on: https://go-review.googlesource.com/3250
Reviewed-by: Sameer Ajmani <sameer@golang.org>
The top-level moved package was skipped when doing import rewrites.
Don't skip that package.
Fixes#9811
Change-Id: I1c524ed44606586b5231e5adb6168079aa0e0228
Reviewed-on: https://go-review.googlesource.com/4470
Reviewed-by: Alan Donovan <adonovan@google.com>
This change adds a command mvpkg that will move a given package and
update all its imports. It uses similar logic to gorename to update
the imports.
Change-Id: Iebbd0b4c93c2302b0a71c3b99c68f6778106012a
Reviewed-on: https://go-review.googlesource.com/1973
Reviewed-by: Alan Donovan <adonovan@google.com>