Skip to content

Commit 998e760

Browse files
author
Dan Brakeley
committed
add reminder text to cleanup workspace & local files
plus some misc cleanup, mostly to the readme
1 parent 16fb85c commit 998e760

4 files changed

Lines changed: 25 additions & 15 deletions

File tree

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Overview
44

5-
`p4harmonize` is a tool for getting the head revision of a stream on one perforce server to mirror the head revision from some other perforce server. It can reconcile files, fix differences in file name/path capitalization, fix the file type, and fix improperly checked in AppleDouble files created by the "apple" file type.
5+
`p4harmonize` is a tool for mirroring a stream's head revision from one perforce server to another. This includes reconciling files, fixing differences in file name/path capitalization, fixing the file type, and fixing improperly checked in %AppleDouble files.
66

7-
`p4harmonize` was built with Unreal Engine releases in mind, where the Epic licensee perforce server is used as the source, and a dedicated stream on a project's perforce server is used as the destination. It is intended to be used with a setup similar to [the one recommended by Epic](https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/ProgrammingWithCPP/DownloadingSourceCode/UpdatingSourceCode/#integrating,merging,andbranching). At Proletariat, we have different names, but the purposes are the same:
7+
`p4harmonize` was built with Unreal Engine source in mind, where the Epic licensee perforce server is used as the source, and a dedicated stream on a project's perforce server is used as the destination. It is intended to be used with a setup similar to [the one recommended by Epic](https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/ProgrammingWithCPP/DownloadingSourceCode/UpdatingSourceCode/#integrating,merging,andbranching). At Proletariat, we have different names, but the purposes are the same:
88

99
name | description
1010
--- | ---
@@ -40,11 +40,11 @@ new_client_root = "d:/p4/local/harmonize" # this will be created by p4harmonize
4040
new_client_stream = "//test/engine_epic" # this needs to already exist
4141
```
4242

43-
`p4harmonize` connects to each server, requests file lists from each, and determines what work needs to be done. If everything is already in sync, then it reports that back to the user and ends. If there is work to be done, then it creates a changelist and begins adding its fixes to it.
43+
`p4harmonize` connects to each server, requests file lists from each, and determines what work needs to be done. If everything is already in sync, then it quickly reports the status and stops. If there is work to be done, then it creates a changelist and begins adding its fixes to it.
4444

4545
While it runs, it outputs status updates and every individual `p4` command it is running so you can follow along.
4646

47-
When it is done, there will be a changelist that must be submitted by hand. This gives you an opportunity to sanity check the changes before they are committed.
47+
When it is done, there will be a changelist that must be submitted by hand, giving you a chance to sanity check the work.
4848

4949
## Runtime requirements
5050

@@ -67,7 +67,7 @@ When it is done, there will be a changelist that must be submitted by hand. This
6767
```text
6868
git clone https://github.com/proletariatgames/p4harmonize.git
6969
```
70-
- Open a bash prompt in the created `p4harmonize` folder and run `scripts/setup.sh`
70+
- Open a bash prompt in the `p4harmonize` folder that git created in the previous step and run `scripts/setup.sh`
7171
- This ensures Go is installed and ready
7272
- This builds [Mage](https://magefile.org) into your $GOPATH/bin folder
7373

@@ -88,28 +88,29 @@ Targets:
8888

8989
### Mage usage notes
9090

91-
- If your shell can't find `mage`, then you can try
92-
- re-run `scripts/setup.sh` (or `scripts/reinstall-mage.sh`), which creates a `mage` executable in your `$GOPATH/bin`
93-
- ensure you have a `$GOPATH/bin` folder, and that it has been added to your `$PATH` environment variable
91+
- If your shell can't find `mage`
92+
- make sure your `$GOPATH/bin` folder is in your `$PATH`
93+
- make sure there's a `mage` executable in your `$GOPATH/bin` folder
94+
- if `mage` is missing, then re-run `scripts/setup.sh`
9495
- Mage targets are not case sensitive, so `mage longTest` and `mage longtest` will run the same target.
95-
- If you see `No .go files marked with the mage build tag in this directory`, make sure you there is a `magefile.go` in the current folder (Mage does not look to parent folders for magefiles).
9696

9797
## Contributing
9898

99-
Before opening a pull request, please run `mage longtest`, which will run all tests, including functional tests that spin up two Perforce servers in Docker, populate each with some test files, then runs p4harmonize against them, and validates the results.
99+
Before opening a pull request, please run `mage longtest`, which spins up two Perforce servers via Docker, places test files in them, then runs p4harmonize and validates the results.
100100

101-
Once you have a passing longtest, feel free to open a PR. Please include a quick description of the problem your PR solves in the PR description.
101+
Once `longtest` is passing, feel free to open a PR. Please include a quick description of the problem your PR solves in the PR description. If your PR includes performance improvements, please include benchmark numbers and an explanation of how to reproduce those numbers.
102102

103103
### Debugging longtest
104104

105-
Unfortunately the specifics of `longtest` are a bit gross at the moment, and while I hope to one day have time to go in and clean things up, for now it is an all or nothing pass/fail, and so debugging often requires going in and temporarily altering it to focus on the specific behavior that is failing. See the `func LongTest()` in `magefile.go`.
105+
Unfortunately `longtest` is a bit gross at the moment, and while I hope to one day have time to go in and break it out into individual test cases, for now it is an all or nothing pass/fail. Debugging failures often requires temporarily altering the bash scripts and/or connecting perforce clients directly to the docker servers to find and fix the specific behavior that is failing. A good starting point is to read through `func LongTest()` in `magefile.go`.
106106

107107
## Special Thanks!
108108

109-
Thanks to [Bohdon Sayre](https://github.com/bohdon) and [Jørgen P. Tjernø](https://github.com/jorgenpt) for contributing time and code to help me fix my bugs and improve performance!
109+
Thanks to [Bohdon Sayre](https://github.com/bohdon) and [Jørgen P. Tjernø](https://github.com/jorgenpt) for contributing time and code to help me fix my bugs and dramatically improve performance!
110110

111111
## TODO:
112112

113113
- clean up output to be more readable
114114
- make longtest less gross to work with/debug
115-
- test on other platforms (only tested on Windows so far)
115+
- run longtest via github actions
116+
- test on a Mac (maybe with github actions?)

cmd/p4harmonize/logger.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Logger interface {
1414
Info(format string, args ...interface{})
1515
Verbose(format string, args ...interface{})
1616
Warning(format string, args ...interface{})
17+
Error(format string, args ...interface{})
1718
}
1819

1920
type FrogLog struct {

cmd/p4harmonize/update.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,19 @@ func Harmonize(log Logger, cfg Config) error {
188188
}
189189
}
190190

191+
// TODO: Is this revert necessary anymore? Is there an edge case where this might help?
192+
// I'm leaving it in for now, but if there are ever any perf concerns, it can probably be removed.
191193
if err := p4dst.RevertUnchanged(filepath.Join(dstClientRoot, "..."), p4.Changelist(cl)); err != nil {
192194
return fmt.Errorf("Unable to revert unchanged files in the destination: %w", err)
193195
}
194196

197+
root, err := filepath.Abs(cfg.Dst.ClientRoot)
198+
if err != nil {
199+
root = cfg.Dst.ClientRoot
200+
}
195201
log.Warning("Success! All changes are waiting in CL #%d. Please review and submit when ready.", cl)
202+
log.Info("Remember to delete workspace \"%s\"", cfg.Dst.ClientName)
203+
log.Info("and local folder \"%s\"", root)
196204

197205
return nil
198206
}

internal/p4/p4.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (x DepotFileCaseInsensitive) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
157157
// and headAction.
158158
// The results are then sorted by Path (case-insensitive) and returned.
159159
func (p *P4) runAndParseDepotFiles(cmd string) ([]DepotFile, error) {
160-
if !strings.Contains(cmd, "-ztag") && !strings.Contains(cmd, "-z tag") && !strings.Contains(cmd, "fstat") {
160+
if !strings.Contains(cmd, "-ztag") && !strings.Contains(cmd, "-z tag") && !strings.Contains(cmd, "fstat") {
161161
return nil, fmt.Errorf("missing '-z tag' in non-fstat cmd: %s", cmd)
162162
}
163163

0 commit comments

Comments
 (0)