-
-
-
-
-
'is' shouldn't be used for string comparisons. This would be better as: if not self.upstream_branch:
-
-
-
We seem to do this logic twice. I'd prefer an inline utility function like: def get_origin(default_upstream_branch=None, ignore_errors=False): self.upstream_branch = default_upstream_branch or options.tracking or 'origin/master' upstream_remote = ... origin = execute(..., ignore_errors=ignore_errors) Then you can just do: origin = get_origin(self.upstream_branch, True) if origin.startswith("fatal:"): origin = get_origin() Or something like that.
-
-
-
-
Since we do the "%s..%s" % (ancestor, commit) twice, it'd be nice to just do this before the self.type checks and save it as revision_range or something.
-
I'd prefer --tracking-branch. Also, can you update the rbtools docs (reviewboard/docs/manual/users/tools/post-review.txt) with this parameter?
post-review: yet another attempt to improve git support
Review Request #1144 — Created Oct. 4, 2009 and submitted
This is refresh of review 985. I've refactored the change to be more intelligent, and I didn't touch git-svn behavior. The general idea is to try to detect the merge base of your current head, or gracefully fall back to defaults. You can optionally specify a tracking branch if you need to. * Try to detect the tracking branch for the current HEAD, if possible * If a tracking branch doesn't exist, or is not remote, fall back to origin/master * If --tracking-branch is specified, use this branch instead of origin/master * Determine the merge base with the git merge-base command. This makes it okay to specify a tracking branch even when its head no longer points to the original branching point. * No longer mucks with the current git-svn behavior. * Add unit tests for pure git. The tests are limited to pure git GitClient right now and aren't comprehensive, but cover the scenarios I changed. http://github.com/djs/rbtools/tree/review1144-r5
Tested with rbtools repo and local server with following scenarios: * Remote tracking branch available * Local tracking branch available (ignored) * No tracking branch available (default to origin/master) * No tracking branch available, with --tracking specified * No tracking branch available with --parent specified * Revision range specified $ nosetests .......... ---------------------------------------------------------------------- Ran 10 tests in 12.420s
- Change Summary:
-
Update according to review comments and add unit tests.
- Description:
-
This is refresh of review 985. I've refactored the change to be more intelligent, and I didn't touch git-svn behavior.
The general idea is to try to detect the merge base of your current head, or gracefully fall back to defaults. You can optionally specify a tracking branch if you need to.
- Try to detect the tracking branch for the current HEAD, if possible
- If a tracking branch doesn't exist, or is not remote, fall back to origin/master
~ - If --tracking is specified, use this branch instead of origin/master
~ - If --tracking-branch is specified, use this branch instead of origin/master
- Determine the merge base with the git merge-base command. This makes it okay to specify a tracking branch even when its head no longer points to the original branching point.
- No longer mucks with the current git-svn behavior.
+ - Add unit tests for pure git. The tests are limited to pure git GitClient right now and aren't comprehensive, but cover the scenarios I changed.
~ http://github.com/djs/rbtools/tree/review-1144
~ http://github.com/djs/rbtools/tree/review-1144r2
- Testing Done:
-
Tested with rbtools repo and local server with following scenarios:
- Remote tracking branch available
- Local tracking branch available (ignored)
- No tracking branch available (default to origin/master)
- No tracking branch available, with --tracking specified
- No tracking branch available with --parent specified
- Revision range specified
+ + $ nosetests
+ .......... + + + + Ran 10 tests in 12.420s
- Diff:
-
Revision 2 (+440 -11)
-
I love that you're introducing unit tests for rbtools. We've needed this badly for a while :) Some small fixes (coding style) and a handful of docstring stuff.
-
No need for parens around returned tuples. Should do: self.upstream_branch, origin = \ self.get_origin(....)
-
-
Doc blocks in Python should describe what the function does first and foremost. This should then describe what it does with the parameters, and then what's returned.
-
-
-
-
-
-
-
-
-
-
-
Really should have a docstring for the unit tests that says "Testing <some description here>" Same with all other test_* functions.
-
We repeat this so much. Might be nice to just have a utility function that takes the filename, contents, and a commit message, and just does all this.
-
- Change Summary:
-
Update according to comments. I had to upload this diff manually, this server doesn't seem to be responding with post-review (my version or any version)
- Description:
-
This is refresh of review 985. I've refactored the change to be more intelligent, and I didn't touch git-svn behavior.
The general idea is to try to detect the merge base of your current head, or gracefully fall back to defaults. You can optionally specify a tracking branch if you need to.
- Try to detect the tracking branch for the current HEAD, if possible
- If a tracking branch doesn't exist, or is not remote, fall back to origin/master
- If --tracking-branch is specified, use this branch instead of origin/master
- Determine the merge base with the git merge-base command. This makes it okay to specify a tracking branch even when its head no longer points to the original branching point.
- No longer mucks with the current git-svn behavior.
- Add unit tests for pure git. The tests are limited to pure git GitClient right now and aren't comprehensive, but cover the scenarios I changed.
~ http://github.com/djs/rbtools/tree/review-1144r2
~ http://github.com/djs/rbtools/tree/review-1144r3
- Diff:
-
Revision 3 (+422 -11)
-
You likely couldn't post due to the domain name change. I bet it doesn't handle redirects correctly. Try modifying the .reviewboardrc on the server to point to reviews.reviewboard.org. I'll push updates later to fix this.
-
Almost done, a few more things.
-
Out of curiosity, do you know what the minimum version of Git is that supports this? I mostly only care if it's recent, as we'll need to doc/work around it.
-
-
-
-
Still would prefer we not repeat ourselves with this. Can just store it in a variable before the if statements.
-
-
- Change Summary:
-
Update from review comments. I confident we'll get this done in 5-6 more reviews! Certainly no more than 10.
- Description:
-
This is refresh of review 985. I've refactored the change to be more intelligent, and I didn't touch git-svn behavior.
The general idea is to try to detect the merge base of your current head, or gracefully fall back to defaults. You can optionally specify a tracking branch if you need to.
- Try to detect the tracking branch for the current HEAD, if possible
- If a tracking branch doesn't exist, or is not remote, fall back to origin/master
- If --tracking-branch is specified, use this branch instead of origin/master
- Determine the merge base with the git merge-base command. This makes it okay to specify a tracking branch even when its head no longer points to the original branching point.
- No longer mucks with the current git-svn behavior.
- Add unit tests for pure git. The tests are limited to pure git GitClient right now and aren't comprehensive, but cover the scenarios I changed.
~ http://github.com/djs/rbtools/tree/review-1144r3
~ http://github.com/djs/rbtools/tree/review-1144r4
- Diff:
-
Revision 4 (+425 -12)
- Change Summary:
-
Add a fugly hack to avoid using git for-each-ref. Unit tests pass
- Description:
-
This is refresh of review 985. I've refactored the change to be more intelligent, and I didn't touch git-svn behavior.
The general idea is to try to detect the merge base of your current head, or gracefully fall back to defaults. You can optionally specify a tracking branch if you need to.
- Try to detect the tracking branch for the current HEAD, if possible
- If a tracking branch doesn't exist, or is not remote, fall back to origin/master
- If --tracking-branch is specified, use this branch instead of origin/master
- Determine the merge base with the git merge-base command. This makes it okay to specify a tracking branch even when its head no longer points to the original branching point.
- No longer mucks with the current git-svn behavior.
- Add unit tests for pure git. The tests are limited to pure git GitClient right now and aren't comprehensive, but cover the scenarios I changed.
~ http://github.com/djs/rbtools/tree/review-1144r4
~ http://github.com/djs/rbtools/tree/review1144-r5
- Diff:
-
Revision 5 (+434 -12)
-
-
lstrip isn't good here, for example it will change string refs/heads/dev to v insead of "dev" From doc of lstrip "The chars argument is a string specifying the set of characters to be removed" >>> 'www.example.com'.lstrip('cmowz.') 'example.com' replace('refs/heads/','',1) or something similar would work better