From: Junio C Hamano Date: Wed, 6 Apr 2016 18:39:05 +0000 (-0700) Subject: Merge branch 'ls/p4-map-user' X-Git-Tag: v2.9.0-rc0~155 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1d851b9d30f5a7d2efdda71623839dcabd27577e?ds=inline;hp=-c Merge branch 'ls/p4-map-user' "git p4" now allows P4 author names to be mapped to Git author names. * ls/p4-map-user: git-p4: map a P4 user to Git author name and email address --- 1d851b9d30f5a7d2efdda71623839dcabd27577e diff --combined Documentation/git-p4.txt index 35e3170918,9f077fd6f4..88ba42b455 --- a/Documentation/git-p4.txt +++ b/Documentation/git-p4.txt @@@ -515,18 -515,20 +515,18 @@@ git-p4.pathEncoding: Git expects paths encoded as UTF-8. Use this 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. + often uses "cp1252" to encode path names. git-p4.largeFileSystem:: Specify the system that is used for large (binary) files. Please note that large file systems do not support the 'git p4 submit' command. - Only Git LFS [1] is implemented right now. Download - and install the Git LFS command line extension to use this option - and configure it like this: + Only Git LFS is implemented right now (see https://git-lfs.github.com/ + for more information). Download and install the Git LFS command line + extension to use this option and configure it like this: + ------------- git config git-p4.largeFileSystem GitLFS ------------- -+ - [1] https://git-lfs.github.com/ git-p4.largeFileExtensions:: All files matching a file extension in the list will be processed @@@ -551,6 -553,17 +551,17 @@@ git-p4.keepEmptyCommits: A changelist that contains only excluded files will be imported as an empty commit if this boolean option is set to true. + git-p4.mapUser:: + Map a P4 user to a name and email address in Git. Use a string + with the following format to create a mapping: + + + ------------- + git config --add git-p4.mapUser "p4user = First Last " + ------------- + + + A mapping will override any user information from P4. Mappings for + multiple P4 user can be defined. + Submit variables ~~~~~~~~~~~~~~~~ git-p4.detectRenames:: diff --combined git-p4.py index 825b9f32d5,bac341d04c..527d44bd20 --- a/git-p4.py +++ b/git-p4.py @@@ -253,8 -253,8 +253,8 @@@ def p4_add(f) def p4_delete(f): p4_system(["delete", wildcard_encode(f)]) -def p4_edit(f): - p4_system(["edit", wildcard_encode(f)]) +def p4_edit(f, *options): + p4_system(["edit"] + list(options) + [wildcard_encode(f)]) def p4_revert(f): p4_system(["revert", wildcard_encode(f)]) @@@ -1160,6 -1160,15 +1160,15 @@@ class P4UserMap self.users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">" self.emails[output["Email"]] = output["User"] + mapUserConfigRegex = re.compile(r"^\s*(\S+)\s*=\s*(.+)\s*<(\S+)>\s*$", re.VERBOSE) + for mapUserConfig in gitConfigList("git-p4.mapUser"): + mapUser = mapUserConfigRegex.findall(mapUserConfig) + if mapUser and len(mapUser[0]) == 3: + user = mapUser[0][0] + fullname = mapUser[0][1] + email = mapUser[0][2] + self.users[user] = fullname + " <" + email + ">" + self.emails[email] = user s = '' for (key, val) in self.users.items(): @@@ -1554,7 -1563,6 +1563,7 @@@ class P4Submit(Command, P4UserMap) diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (self.diffOpts, id, id)) filesToAdd = set() + filesToChangeType = set() filesToDelete = set() editedFiles = set() pureRenameCopy = set() @@@ -1615,8 -1623,6 +1624,8 @@@ os.unlink(dest) filesToDelete.add(src) editedFiles.add(dest) + elif modifier == "T": + filesToChangeType.add(path) else: die("unknown modifier %s for %s" % (modifier, path)) @@@ -1676,8 -1682,6 +1685,8 @@@ # system(applyPatchCmd) + for f in filesToChangeType: + p4_edit(f, "-t", "auto") for f in filesToAdd: p4_add(f) for f in filesToDelete: