summaryrefslogtreecommitdiff
path: root/git-p4.py
AgeCommit message (Collapse)Author
2013-02-01Merge branch 'bc/git-p4-for-python-2.4'Junio C Hamano
With small updates to remove dependency on newer features of Python, keep git-p4 usable with older Python. * bc/git-p4-for-python-2.4: INSTALL: git-p4 does not support Python 3 git-p4.py: support Python 2.4 git-p4.py: support Python 2.5
2013-01-27git-p4.py: support Python 2.4Brandon Casey
Python 2.4 lacks the following features: subprocess.check_call struct.pack_into Take a cue from 460d1026 and provide an implementation of the CalledProcessError exception. Then replace the calls to subproccess.check_call with calls to subprocess.call that check the return status and raise a CalledProcessError exception if necessary. The struct.pack_into in t/9802 can be converted into a single struct.pack call which is available in Python 2.4. Signed-off-by: Brandon Casey <bcasey@nvidia.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-27git-p4.py: support Python 2.5Brandon Casey
Python 2.5 and older do not accept None as the first argument to translate() and complain with: TypeError: expected a character buffer object As suggested by Pete Wyckoff, let's just replace the call to translate() with a regex search which should be more clear and more portable. This allows git-p4 to be used with Python 2.5. Signed-off-by: Brandon Casey <bcasey@nvidia.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-22Merge branch 'pw/p4-branch-fixes'Junio C Hamano
Fix "git p4" around branch handling. * pw/p4-branch-fixes: git p4: fix submit when no master branch git p4 test: keep P4CLIENT changes inside subshells git p4: fix sync --branch when no master branch git p4: fail gracefully on sync with no master branch git p4: rearrange self.initialParent use git p4: allow short ref names to --branch git p4 doc: fix branch detection example git p4: clone --branch should checkout master git p4: verify expected refs in clone --bare test git p4: create p4/HEAD on initial clone git p4: inline listExistingP4GitBranches git p4: add comments to p4BranchesInGit git p4: rearrange and simplify hasOrigin handling git p4: test sync/clone --branch behavior
2013-01-15git p4: fix submit when no master branchPete Wyckoff
It finds its upstream and applies the commit properly, but the sync step will fail unless it is told which branch to work on. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: fix sync --branch when no master branchPete Wyckoff
It is legal to sync a branch with a different name than refs/remotes/p4/master, and to do so even when master does not exist. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: fail gracefully on sync with no master branchPete Wyckoff
If --branch was used to build a repository with no refs/remotes/p4/master, future syncs will not know which branch to sync. Notice this situation and print a helpful error message. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: rearrange self.initialParent usePete Wyckoff
This was set in a couple of places, both of which were very far away from its use. Move it a bit closer to importChanges(), and add some comments. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: allow short ref names to --branchPete Wyckoff
For a clone or sync, --branch says where the newly imported branch should go, or which existing branch to sync up. It takes an argument, which is currently either something that starts with "refs/", or if not, "refs/heads/p4" is prepended. Putting it in heads seems like a bad default; these should go in remotes/p4/ in most situations. Make that the new default, and be more liberal in the form of the branch name. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: clone --branch should checkout masterPete Wyckoff
When using the --branch argument to "git p4 clone", one might specify a destination for p4 changes different from the default refs/remotes/p4/master. Both cases should create a master branch and checkout files. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: create p4/HEAD on initial clonePete Wyckoff
There is code to create a symbolic reference from p4/HEAD to p4/master. This allows saying "git show p4" as a shortcut to "git show p4/master", for example. But this reference was only created on the second "git p4 sync" (or first sync after a clone). Make it work on the initial clone or sync. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: inline listExistingP4GitBranchesPete Wyckoff
It is four lines of code used in only one place. Simplify by including it where it is used. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: add comments to p4BranchesInGitPete Wyckoff
Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15git p4: rearrange and simplify hasOrigin handlingPete Wyckoff
Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-28Add checks to Python scripts for version dependencies.Eric S. Raymond
Signed-off-by: Eric S. Raymond <esr@thyrsus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26git p4: remove unneeded cmd initializationPete Wyckoff
It confuses pylint, and is never needed. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26git p4: fix labelDetails typo in exceptionPete Wyckoff
Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26git p4: catch p4 errors when streaming file contentsPete Wyckoff
Error messages that arise during the "p4 print" phase of generating commits were silently ignored. Catch them, abort the fast-import, and exit. Without this fix, the sync/clone appears to work, but files that are inaccessible by the p4d server will still be imported to git, although without the proper contents. Instead the errant files will contain a p4 error message, such as "Librarian checkout //depot/path failed". Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26git p4: handle servers without move supportPete Wyckoff
Support for the "p4 move" command was added in 8e9497c (git p4: add support for 'p4 move' in P4Submit, 2012-07-12), which checks to make sure that the client and server support the command. But older versions of p4d may not handle the "-k" argument, and newer p4d allow disabling "p4 move" with a configuration setting. Check for both these cases by testing a p4 move command on bogus filenames and looking for strings in the error messages. Reported-by: Vitor Antunes <vitor.hda@gmail.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26git p4: catch p4 describe errorsPete Wyckoff
Group the two calls to "p4 describe" into a new helper function, and try to validate the p4 results. The current behavior when p4 describe fails is to die with a python backtrace. The new behavior will print the full response. This does not solve any particular problem, but adds more checking in hopes of narrowing down odd behavior seen on at least two occasions. Based-on-patch-by: Matt Arsenault <arsenm2@gmail.com> Reported-by: Arthur <a.foulon@amesys.fr> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-20Merge branch 'pw/maint-p4-rcs-expansion-newline'Junio C Hamano
I do not have p4 to play with, but looks obviously correct to me. * pw/maint-p4-rcs-expansion-newline: git p4: RCS expansion should not span newlines
2012-11-08git p4: RCS expansion should not span newlinesPete Wyckoff
This bug was introduced in cb585a9 (git-p4: keyword flattening fixes, 2011-10-16). The newline character is indeed special, and $File$ expansions should not try to match across multiple lines. Based-on-patch-by: Chris Goard <cgoard@gmail.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Jeff King <peff@peff.net>
2012-09-18Merge branch 'pw/p4-submit-conflicts'Junio C Hamano
Add '--conflict' option to git-p4 subcommand to specify what action to take when conflicts are found during 'p4 submit'. * pw/p4-submit-conflicts: git-p4: add submit --conflict option and config varaiable git p4: add submit --prepare-p4-only option git p4: add submit --dry-run option git p4: accept -v for --verbose git p4: revert deleted files after submit cancel git p4: rearrange submit template construction git p4: test clean-up after failed submit, fix added files git p4: standardize submit cancel due to unchanged template git p4: move conflict prompt into run, add [q]uit input git p4: remove submit failure options [a]pply and [w]rite git p4: gracefully fail if some commits could not be applied git p4 test: remove bash-ism of combined export/assignment
2012-09-17git-p4: add submit --conflict option and config varaiablePete Wyckoff
This allows specifying what to do when a conflict happens when applying a commit to p4, automating the interactive prompt. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: add submit --prepare-p4-only optionPete Wyckoff
This option can be used to prepare the client workspace for submission, only. It does not invoke the final "p4 submit". A message describes how to proceed, either submitting the changes or reverting. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: add submit --dry-run optionPete Wyckoff
A new option, "git p4 submit --dry-run" can be used to verify what commits and labels would be moved into p4. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: accept -v for --verbosePete Wyckoff
The short form "-v" is common in many git commands as an alias for "--verbose". Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: revert deleted files after submit cancelPete Wyckoff
The user can decide not to continue with a submission, by not saving the p4 submit template, then answering "no" to the "Submit anyway?" prompt. In this case, be sure to return the p4 client to its initial state. Deleted files were not reverted; fix this and test all cases. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: rearrange submit template constructionPete Wyckoff
Put all items in order as they appear, and add comments. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: test clean-up after failed submit, fix added filesPete Wyckoff
Test a variety of cases where a patch failed to apply to p4 and had to be cleaned up. If the patch failed to apply cleanly, do not try to remove to-be-added files, as they have not really been added yet. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: standardize submit cancel due to unchanged templatePete Wyckoff
When editing the submit template, if no change was made to it, git p4 offers a prompt "Submit anyway?". Answering "no" cancels the submit. Previously, a "no" answer behaves like a "[s]kip" answer to the failed-patch prompt, in that it proceeded to try to apply the rest of the commits. Instead, put users back into the new "[s]kip / [c]ontinue" loop so that they can decide. This makes both cases of patch failure behave identically. The return code of git p4 after a "no" answer is now the same as that for a "skip" due to failed patch; update a test to understand this. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: move conflict prompt into run, add [q]uit inputPete Wyckoff
When applying a commit to the p4 workspace fails, a prompt asks what to do next. This belongs up in run() instead of in applyCommit(), where run() can notice, for instance, that the prompt is unnecessary because this is the last commit. Offer two options about how to continue at conflict: [s]kip or [q]uit. Having an explicit "quit" option gives git p4 a chance to clean up, show the applied-commit summary, and do tag export. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: remove submit failure options [a]pply and [w]ritePete Wyckoff
When a patch failed to apply, these interactive options offered to: 1) apply the patch anyway, leaving reject (.rej) files around, or, 2) write the patch to a file (patch.txt) In both cases it suggested to invoke "git p4 submit --continue", an unimplemented option. While manually fixing the rejects and submitting the result might work, there are many steps that must be done to the job properly: * apply patch * invoke p4 add and delete * change executable bits * p4 sync -f renamed/copied files * extract commit message into p4 change description and move Jobs lines out of description section * set changelist owner for --preserve-user Plus the following manual sync/rebase will cause conflicts too, which must be resolved once again. Drop these workflows. Instead users should do a sync/rebase in git, fix the conflicts there, and do a clean "git p4 submit". Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17git p4: gracefully fail if some commits could not be appliedPete Wyckoff
If a commit fails to apply cleanly to the p4 tree, an interactive prompt asks what to do next. In all cases (skip, apply, write), the behavior after the prompt had a few problems. Change it so that it does not claim erroneously that all commits were applied. Instead list the set of the patches under consideration, and mark with an asterisk those that were applied successfully. Like this example: Applying 592f1f9 line5 in file1 will conflict ... Unfortunately applying the change failed! What do you want to do? [s]kip this patch / [a]pply the patch forcibly and with .rej files / [w]rite the patch to a file (patch.txt) s Skipping! Good luck with the next patches... //depot/file1#4 - was edit, reverted Applying b8db1c6 okay_commit_after_skip ... Change 6 submitted. Applied only the commits marked with '*': 592f1f9 line5 in file1 will conflict * b8db1c6 okay_commit_after_skip Do not try to sync and rebase unless all patches were applied. If there was a conflict during the submit, there is sure to be one at the rebase. Let the user to do the sync and rebase manually. This changes how a couple tets in t9810-git-p4-rcs.sh behave: - git p4 now does not leave files open and edited in the client - If a git commit contains a change to a file that was deleted in p4, the test used to check that the sync/rebase loop happened after the failure to apply the change. Since now sync/rebase does not happen after failure, do not test this. Normal rebase machinery, outside of git p4, will let rebase --skip work. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-20git p4: make branch detection work with --use-client-specPete Wyckoff
The bug report in http://stackoverflow.com/questions/11893688 observes that files are mapped into the wrong locations in git when both --use-client-spec and --branch-detection are enabled. Fix this by changing the relative path prefix to match discovered branches when using a client spec. The problem was likely introduced with ecb7cf9 (git-p4: rewrite view handling, 2012-01-02). Signed-off-by: Pete Wyckoff <pw@padd.com> Tested-by: Matthew Korich <matthew@korich.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-12git p4: do wildcard decoding in stripRepoPathPete Wyckoff
Instead of having to remember to do it after each call to stripRepoPath, make it part of that function. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-12git p4: set self.branchPrefixes in initializationPete Wyckoff
This instance variable is needed during commit() to map files from p4 to their relative locations in git. Set it when initializing P4Sync to avoid passing it to every commit() call. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16Merge branch 'pw/git-p4-move'Junio C Hamano
* pw/git-p4-move: git p4: add support for 'p4 move' in P4Submit git p4: refactor diffOpts calculation
2012-07-12git p4: add support for 'p4 move' in P4SubmitGary Gibbons
For -M option (detectRenames) in P4Submit, use 'p4 move' rather than 'p4 integrate'. Check Perforce server for exisitence of 'p4 move' and use it if present, otherwise revert to 'p4 integrate'. [pw: wildcard-encode src/dest, add/update tests, tweak code] Signed-off-by: Gary Gibbons <ggibbons@perforce.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-06git p4: refactor diffOpts calculationGary Gibbons
P4Submit.applyCommit() To avoid recalculating the same diffOpts for each commit, move it out of applyCommit() and into the top-level run(). Also fix a bug in that code which interpreted the value of detectRenames as a string rather than as a boolean. [pw: fix documentation, rearrange code a bit] Signed-off-by: Gary Gibbons <ggibbons@perforce.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-06git p4: notice Jobs lines in git commit messagesPete Wyckoff
P4 has a feature called "jobs" that allows linking changes to a bug tracking system or other tasks. When submitting code, a job name can be specified to mark that this change is associated with a particular job. Teach git-p4 to find an optional "Jobs:" line in git commit messages and use them to make a Jobs section in the p4 change specifitation. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-06git p4: remove unused P4Submit interactive settingPete Wyckoff
The code is unused. Delete. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-17Merge branch 'ld/git-p4-tags-and-labels'Junio C Hamano
By Luke Diamand * ld/git-p4-tags-and-labels: git p4: fix bug when enabling tag import/export via config variables git p4: fix bug when verbose enabled with tag export git p4: add test for tag import/export enabled via config
2012-05-11git p4: fix bug when enabling tag import/export via config variablesLuke Diamand
Use Python's True, not true. Causes failure when enabling tag import or export in "git p4" using a config option rather than the command line. Signed-off-by: Luke Diamand <luke@diamand.org> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-11git p4: fix bug when verbose enabled with tag exportLuke Diamand
Wrong variable name used when verbose enabled, causes failure. Signed-off-by: Luke Diamand <luke@diamand.org> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30git p4: submit files with wildcardsPete Wyckoff
There are four wildcard characters in p4. Files with these characters can be added to p4 repos using the "-f" option. They are stored in %xx notation, and when checked out, p4 converts them back to normal. When adding files with wildcards in git, the submit path must be careful to use the encoded names in some places, and it must use "-f" to add them. All other p4 commands that operate on the client directory expect encoded filenames as arguments. Support for wildcards in the clone/sync path was added in 084f630 (git-p4: decode p4 wildcard characters, 2011-02-19), but that change did not handle the submit path. There was a problem with wildcards in the sync path too. Commit 084f630 (git-p4: decode p4 wildcard characters, 2011-02-19) handled files with p4 wildcards that were added or modified in p4. Do this for deleted files, and also in branch detection checks, too. Reported-by: Luke Diamand <luke@diamand.org> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30git p4: fix writable file after rename or copyPete Wyckoff
The way rename works is with a "p4 integrate", optionally followed by a "p4 edit" if the change is not a 100% rename. Contents are generated by applying a patch, not doing a file system rename. Copy is similar. In this case, p4 does not fix the permissions back to read-only. Make sure this happens by calling "p4 sync -f". Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30git p4: bring back files in deleted client directoryPete Wyckoff
The code to auto-create the client directory, added in 0591cfa (git-p4: ensure submit clientPath exists before chdir, 2011-12-09), works when the client directory never existed. But if the directory is summarily removed without telling p4, the sync operation will not bring back all the files. Always do "sync -f" if the client directory is newly created. Reported-by: Gary Gibbons <ggibbons@perforce.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-24git p4: move verbose to base classLuke Diamand
The verbose flag is common to all classes, or at least should be. Make it a member of the base Command class, rather than reimplementing for each class. Make option parsing mirror this. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-24git p4: Ignore P4EDITOR if it is emptyLuke Diamand
p4 itself treats an empty value for P4EDITOR as the same as having P4EDITOR unset. Do the same for "git p4". Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>