summaryrefslogtreecommitdiff
path: root/git-p4.py
AgeCommit message (Collapse)Author
2015-12-28Merge branch 'sh/p4-multi-depot'Junio C Hamano
"git p4" when interacting with multiple depots at the same time used to incorrectly drop changes. * sh/p4-multi-depot: git-p4: reduce number of server queries for fetches git-p4: support multiple depot paths in p4 submit git-p4: failing test case for skipping changes with multiple depots
2015-12-21git-p4: reduce number of server queries for fetchesSam Hocevar
When fetching changes from a depot using a full client spec, there is no need to perform as many queries as there are top-level paths in the client spec. Instead we query all changes in chronological order, also getting rid of the need to sort the results and remove duplicates. Signed-off-by: Sam Hocevar <sam@hocevar.net> Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-21git-p4: support multiple depot paths in p4 submitSam Hocevar
When submitting from a repository that was cloned using a client spec, use the full list of paths when ruling out files that are outside the view. This fixes a bug where only files pertaining to the first path would be included in the p4 submit. Signed-off-by: Sam Hocevar <sam@hocevar.net> Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-15Merge branch 'ls/p4-keep-empty-commits'Junio C Hamano
"git p4" used to import Perforce CLs that touch only paths outside the client spec as empty commits. It has been corrected to ignore them instead, with a new configuration git-p4.keepEmptyCommits as a backward compatibility knob. * ls/p4-keep-empty-commits: git-p4: add option to keep empty commits
2015-12-10git-p4: add option to keep empty commitsLars Schneider
A changelist that contains only excluded files due to a client spec was imported as an empty commit. Fix that issue by ignoring these commits. Add option "git-p4.keepEmptyCommits" to make the previous behavior available. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Helped-by: Pete Harlan Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-01Merge branch 'maint'Jeff King
* maint: http: treat config options sslCAPath and sslCAInfo as paths Documentation/diff: give --word-diff-regex=. example filter-branch: deal with object name vs. pathname ambiguity in tree-filter check-ignore: correct documentation about output git-p4: clean up after p4 submit failure git-p4: work with a detached head git-p4: add option to system() to return subshell status git-p4: add failing test for submit from detached head remote-http(s): support SOCKS proxies t5813: avoid creating urls that break on cygwin Escape Git's exec path in contrib/rerere-train.sh script allow hooks to ignore their standard input stream rebase-i-exec: Allow space in SHELL_PATH Documentation: make environment variable formatting more consistent
2015-12-01Merge branch 'eg/p4-submit-catch-failure' into maintJeff King
Just like the working tree is cleaned up when the user cancelled submission in P4Submit.applyCommit(), clean up the mess if "p4 submit" fails. * eg/p4-submit-catch-failure: git-p4: clean up after p4 submit failure
2015-12-01Merge branch 'ld/p4-detached-head' into maintJeff King
Make git-p4 work on a detached head. * ld/p4-detached-head: git-p4: work with a detached head git-p4: add option to system() to return subshell status git-p4: add failing test for submit from detached head
2015-11-24git-p4: clean up after p4 submit failureGIRARD Etienne
When "p4 submit" command fails in P4Submit.applyCommit, the workspace is left with the changes. We already have code to revert the changes to the workspace when the user decides to cancel submission by aborting the editor that edits the change description, and we should treat the "p4 submit" failure the same way. Clean the workspace if p4_write_pipe raised SystemExit, so that the user don't have to do it themselves. Signed-off-by: GIRARD Etienne <egirard@murex.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Jeff King <peff@peff.net>
2015-11-24git-p4: work with a detached headLuke Diamand
When submitting, git-p4 finds the current branch in order to know if it is allowed to submit (configuration "git-p4.allowSubmit"). On a detached head, detecting the branch would fail, and git-p4 would report a cryptic error. This change teaches git-p4 to recognise a detached head and submit successfully. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Jeff King <peff@peff.net>
2015-11-24git-p4: add option to system() to return subshell statusLuke Diamand
Add an optional parameter ignore_error to the git-p4 system() function. If used, it will return the subshell exit status rather than throwing an exception. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Jeff King <peff@peff.net>
2015-11-03Merge branch 'ls/p4-translation-failure' into maintJunio C Hamano
Work around "git p4" failing when the P4 depot records the contents in UTF-16 without UTF-16 BOM. * ls/p4-translation-failure: git-p4: handle "Translation of file content failed" git-p4: add test case for "Translation of file content failed" error
2015-11-03Merge branch 'ld/p4-import-labels' into maintJunio C Hamano
Correct "git p4 --detect-labels" so that it does not fail to create a tag that points at a commit that is also being imported. * ld/p4-import-labels: git-p4: fix P4 label import for unprocessed commits git-p4: do not terminate creating tag for unknown commit git-p4: failing test for ignoring invalid p4 labels
2015-10-26Merge branch 'dk/p4-import-ctypes'Junio C Hamano
"git-p4" tried to use from ctypes module without first importing it. * dk/p4-import-ctypes: git-p4: import the ctypes module
2015-10-20git-p4: import the ctypes moduleDennis Kaarsemaker
The ctypes module is used on windows to calculate free disk space, so it must be imported. We won't need it on other platforms, but the module is available in Python 2.5 and newer, so importing it unconditionally is harmless. Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-15Merge branch 'ls/p4-lfs'Junio C Hamano
Teach "git p4" to send large blobs outside the repository by talking to Git LFS. * ls/p4-lfs: git-p4: add Git LFS backend for large file system git-p4: add support for large file systems git-p4: check free space during streaming git-p4: add file streaming progress in verbose mode git-p4: return an empty list if a list config has no values git-p4: add gitConfigInt reader git-p4: add optional type specifier to gitConfig reader
2015-10-15Merge branch 'ls/p4-translation-failure'Junio C Hamano
Work around "git p4" failing when the P4 depot records the contents in UTF-16 without UTF-16 BOM. * ls/p4-translation-failure: git-p4: handle "Translation of file content failed" git-p4: add test case for "Translation of file content failed" error
2015-10-07Merge branch 'ls/p4-path-encoding'Junio C Hamano
"git p4" learned to reencode the pathname it uses to communicate with the p4 depot with a new option. * ls/p4-path-encoding: git-p4: use replacement character for non UTF-8 characters in paths git-p4: improve path encoding verbose output git-p4: add config git-p4.pathEncoding
2015-10-05Merge branch 'ld/p4-import-labels'Junio C Hamano
Correct "git p4 --detect-labels" so that it does not fail to create a tag that points at a commit that is also being imported. * ld/p4-import-labels: git-p4: fix P4 label import for unprocessed commits git-p4: do not terminate creating tag for unknown commit git-p4: failing test for ignoring invalid p4 labels
2015-10-03git-p4: add Git LFS backend for large file systemLars Schneider
Add example implementation including test cases for the large file system using Git LFS. Pushing files to the Git LFS server is not tested. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-03git-p4: add support for large file systemsLars Schneider
Perforce repositories can contain large (binary) files. Migrating these repositories to Git generates very large local clones. External storage systems such as Git LFS [1], Git Fat [2], Git Media [3], git-annex [4] try to address this problem. Add a generic mechanism to detect large files based on extension, uncompressed size, and/or compressed size. [1] https://git-lfs.github.com/ [2] https://github.com/jedbrown/git-fat [3] https://github.com/alebedev/git-media [4] https://git-annex.branchable.com/ Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Conflicts: Documentation/git-p4.txt git-p4.py Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-03git-p4: check free space during streamingLars Schneider
git-p4 will just halt if there is not enough disk space while streaming content from P4 to Git. Add a check to ensure at least 4 times (arbitrarily chosen) the size of a streamed file is available. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-03git-p4: add file streaming progress in verbose modeLars Schneider
If a file is streamed from P4 to Git then the verbose mode prints continuously the progress as percentage like this: //depot/file.bin 20% (10 MB) Upon completion the progress is overwritten with depot source, local file and size like this: //depot/file.bin --> local/file.bin (10 MB) Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-03git-p4: return an empty list if a list config has no valuesLars Schneider
Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-03git-p4: add gitConfigInt readerLars Schneider
Add a git config reader for integer variables. Please note that the git config implementation automatically supports k, m, and g suffixes. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-03git-p4: add optional type specifier to gitConfig readerLars Schneider
The functions "gitConfig" and "gitConfigBool" are almost identical. Make "gitConfig" more generic by adding an optional type specifier. Use the type specifier "--bool" with "gitConfig" to implement "gitConfigBool. This prepares the implementation of other type specifiers such as "--int". Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-09-22git-p4: handle "Translation of file content failed"Lars Schneider
A P4 repository can get into a state where it contains a file with type UTF-16 that does not contain a valid UTF-16 BOM. If git-p4 attempts to retrieve the file then the process crashes with a "Translation of file content failed" error. More info here: http://answers.perforce.com/articles/KB/3117 Fix this by detecting this error and retrieving the file as binary instead. The result in Git is the same. Known issue: This works only if git-p4 is executed in verbose mode. In normal mode no exceptions are thrown and git-p4 just exits. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-09-21git-p4: use replacement character for non UTF-8 characters in pathsLars Schneider
If non UTF-8 characters are detected in paths then replace them with a placeholder instead of throwing a UnicodeDecodeError exception. This restores the original (implicit) implementation that was broken in 00a9403. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Reviewed-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-09-16git-p4: improve path encoding verbose outputLars Schneider
If a path with non-ASCII characters is detected then print the encoding and the encoded string in verbose mode. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-09-03git-p4: add config git-p4.pathEncodingLars Schneider
Perforce keeps the encoding of a path as given by the originating OS. Git expects paths encoded as UTF-8. Add a config to tell git-p4 what encoding Perforce had used for the paths. This encoding is used to transcode the paths to UTF-8. As an example, Perforce on Windows often uses “cp1252” to encode path names. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-28git-p4: fix P4 label import for unprocessed commitsLuke Diamand
With --detect-labels enabled, git-p4 will try to create tags using git fast-import by writing a "tag" clause to the fast-import stream. If the commit that the tag references has not yet actually been processed by fast-import, then the tag can't be created and git-p4 fails to import the P4 label. Teach git-p4 to use fast-import "marks" when creating tags which reference commits created during the current run of the program. Commits created before the current run are still referenced in the old way using a normal git commit. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-28git-p4: do not terminate creating tag for unknown commitLuke Diamand
If p4 reports a tag for a commit that git-p4 does not know about (e.g. because it references a P4 changelist that was imported prior to the point at which the repo was cloned into git), make sure that the error is correctly caught and handled. rather than just crashing. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-28git-p4: honor core.ignorecase when using P4 client specsLars Schneider
Perforce depot may record paths in mixed cases, e.g. "p4 files" may show that there are these two paths: //depot/Path/to/file1 //depot/pATH/to/file2 and with "p4" or "p4v", these end up in the same directory, e.g. //depot/Path/to/file1 //depot/Path/to/file2 which is the desired outcome on case insensitive systems. If git-p4 is used with client spec "//depot/Path/...", however, then all files not matching the case in the client spec are ignored (in the example above "//depot/pATH/to/file2"). Fix this by using the path case that appears first in lexicographical order when core.ignorecase is set to true. This behavior is consistent with "p4" and "p4v". Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-24Merge branch 'ld/p4-changes-block-size'Junio C Hamano
More Perforce row number limit workaround for "git p4". * ld/p4-changes-block-size: git-p4: fixing --changes-block-size handling git-p4: add tests for non-numeric revision range git-p4: test with limited p4 server results git-p4: additional testing of --changes-block-size
2015-06-11Merge branch 'mt/p4-depotFile-at-version'Junio C Hamano
* mt/p4-depotFile-at-version: p4: retrieve the right revision of the file in UTF-16 codepath
2015-06-10git-p4: fixing --changes-block-size handlingLuke Diamand
The --changes-block-size handling was intended to help when a user has a limited "maxscanrows" (see "p4 group"). It used "p4 changes -m $maxchanges" to limit the number of results. Unfortunately, it turns out that the "maxscanrows" and "maxresults" limits are actually applied *before* the "-m maxchanges" parameter is considered (experimentally). Fix the block-size handling so that it gets blocks of changes limited by revision number ($Start..$Start+$N, etc). This limits the number of results early enough that both sets of tests pass. Note that many other Perforce operations can fail for the same reason (p4 print, p4 files, etc) and it's probably not possible to workaround this. In the real world, this is probably not usually a problem. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-05Merge branch 'ld/p4-editor-multi-words'Junio C Hamano
Unlike "$EDITOR" and "$GIT_EDITOR" that can hold the path to the command and initial options (e.g. "/path/to/emacs -nw"), 'git p4' did not let the shell interpolate the contents of the environment variable that name the editor "$P4EDITOR" (and "$EDITOR", too). Make it in line with the rest of Git, as well as with Perforce. * ld/p4-editor-multi-words: git-p4: tests: use test-chmtime in place of touch git-p4: fix handling of multi-word P4EDITOR git-p4: add failing test for P4EDITOR handling
2015-05-27p4: retrieve the right revision of the file in UTF-16 codepathMiguel Torroja
Fixing bug with UTF-16 files when they are retrieved by git-p4. It was always getting the tip version of the file and the history of the file was lost. Signed-off-by: Miguel Torroja <miguel.torroja@gmail.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-24git-p4: fix handling of multi-word P4EDITORLuke Diamand
This teaches git-p4 to pass the P4EDITOR variable to the shell for expansion, so that any command-line arguments are correctly handled. Without this, git-p4 can only launch the editor if P4EDITOR is solely the path to the binary, without any arguments. This also adjusts t9805, which relied on the previous behaviour. Suggested-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-11Merge branch 'va/p4-client-path'Junio C Hamano
git p4 attempts to better handle branches in Perforce. * va/p4-client-path: git-p4: improve client path detection when branches are used t9801: check git-p4's branch detection with client spec enabled
2015-05-11Merge branch 'ls/p4-changes-block-size'Junio C Hamano
"git p4" learned "--changes-block-size <n>" to read the changes in chunks from Perforce, instead of making one call to "p4 changes" that may trigger "too many rows scanned" error from Perforce. * ls/p4-changes-block-size: git-p4: use -m when running p4 changes
2015-04-23git-p4: improve client path detection when branches are usedVitor Antunes
Perforce allows client side file/directory remapping through the use of the client view definition that is part of the user's client spec. To support this functionality while branch detection is enabled it is important to determine the branch location in the workspace such that the correct files are patched before Perforce submission. Perforce provides a command that facilitates this process: p4 where. This patch does two things to fix improve file location detection when git-p4 has branch detection and use of client spec enabled: 1. Enable usage of "p4 where" when Perforce branches exist in the git repository, even when client specification is used. This makes use of the already existing function p4Where. 2. Allow identifying partial matches of the branch's depot path while processing the output of "p4 where". For robustness, paths will only match if ending in "/...". Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-20git-p4: use -m when running p4 changesLex Spoon
Simply running "p4 changes" on a large branch can result in a "too many rows scanned" error from the Perforce server. It is better to use a sequence of smaller calls to "p4 changes", using the "-m" option to limit the size of each call. Signed-off-by: Lex Spoon <lex@lexspoon.org> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-04git-p4: fix filetype detection on files opened exclusivelyBlair Holloway
If a Perforce server is configured to automatically set +l (exclusive lock) on add of certain file types, git p4 submit will fail during getP4OpenedType, as the regex doesn't expect the trailing '*exclusive*' from p4 opened: //depot/file.png#1 - add default change (binary+l) *exclusive* Signed-off-by: Blair Holloway <blair_holloway@playstation.sony.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-02-11Merge branch 'ld/p4-submit-hint'Junio C Hamano
* ld/p4-submit-hint: git-p4: correct --prepare-p4-only instructions
2015-02-11git-p4: support excluding paths on syncLuke Diamand
The clone subcommand has long had support for excluding subdirectories, but sync has not. This is a nuisance, since as soon as you do a sync, any changed files that were initially excluded start showing up. Move the "exclude" command-line option into the parent class; the actual behavior was already present there so it simply had to be exposed. Signed-off-by: Luke Diamand <luke@diamand.org> Reviewed-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-23git-p4: correct --prepare-p4-only instructionsLuke Diamand
If you use git-p4 with the "--prepare-p4-only" option, then it prints the p4 command line to use. However, the command line was incorrect: the changelist specification must be supplied on standard input, not as an argument to p4. Signed-off-by: Luke Diamand <luke@diamand.org> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-13git-p4: fix submit in non --prepare-p4-only modeMaxime Coste
b4073bb3 (git-p4: Do not include diff in spec file when just preparing p4, 2014-05-24) broke git p4 submit, here is a proper fix, including proper handling for windows end of lines. Signed-off-by: Maxime Coste <frrrwww@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-27git-p4: Do not include diff in spec file when just preparing p4Maxime Coste
The diff information render the spec file unusable as is by p4, do not include it when run with --prepare-p4-only so that the given file can be directly passed to p4. With --prepare-p4-only, git-p4 already tells the user it can use p4 submit with the generated spec file. This fails because of the diff being present in the file. Not including the diff fixes that. Without --prepare-p4-only, keeping the diff makes sense for a quick review of the patch before submitting it. And does not cause problems with p4 as we remove it programmatically. Signed-off-by: Maxime Coste <frrrwww@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-07Merge branch 'cl/p4-use-diff-tree'Junio C Hamano
Fixes a regression in 1.9.0 with an obviously correct single-liner. * cl/p4-use-diff-tree: git-p4: format-patch to diff-tree change breaks binary patches