{"thread":{"id":"27291","subject":"[PATCH] git-p4: small improvements to user-preservation","startedAt":"2011-05-07T10:19:42Z","lastAt":"2011-05-09T04:50:29Z","messageCount":3,"participants":["Luke Diamand","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"167315","messageId":"1304763583-17425-1-git-send-email-luke@diamand.org","threadId":"27291","inReplyTo":null,"subject":"[PATCH] git-p4: small improvements to user-preservation","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2011-05-07T10:19:42Z","receivedAt":"2011-05-07T10:19:42Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":". Slightly more paranoid checking of results from 'p4 change'\n. Remove superfluous \"-G\"\n. Don't modify the username if it is unchanged.\n. Add a comment in the change template to show what is\n  going to be done.\n\n\nLuke Diamand (1):\n  git-p4: small improvements to user-preservation\n\n contrib/fast-import/git-p4 |   19 ++++++++++++++-----\n 1 files changed, 14 insertions(+), 5 deletions(-)\n"},{"id":"167316","messageId":"1304763583-17425-2-git-send-email-luke@diamand.org","threadId":"27291","inReplyTo":"1304763583-17425-1-git-send-email-luke@diamand.org","subject":"[PATCH] git-p4: small improvements to user-preservation","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2011-05-07T10:19:43Z","receivedAt":"2011-05-07T10:19:43Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":". Slightly more paranoid checking of results from 'p4 change'\n. Remove superfluous \"-G\"\n. Don't modify the username if it is unchanged.\n. Add a comment in the change template to show what is\n  going to be done.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n contrib/fast-import/git-p4 |   19 ++++++++++++++-----\n 1 files changed, 14 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 36e3d87..e66a7df 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -690,10 +690,15 @@ class P4Submit(Command, P4UserMap):\n     def modifyChangelistUser(self, changelist, newUser):\n         # fixup the user field of a changelist after it has been submitted.\n         changes = p4CmdList(\"change -o %s\" % changelist)\n-        for c in changes:\n-            if c.has_key('User'):\n-                c['User'] = newUser\n-        input = marshal.dumps(changes[0])\n+        if len(changes) != 1:\n+            die(\"Bad output from p4 change modifying %s to user %s\" %\n+                (changelist, newUser))\n+\n+        c = changes[0]\n+        if c['User'] == newUser: return   # nothing to do\n+        c['User'] = newUser\n+        input = marshal.dumps(c)\n+\n         result = p4CmdList(\"change -f -i\", stdin=input)\n         for r in result:\n             if r.has_key('code'):\n@@ -707,7 +712,7 @@ class P4Submit(Command, P4UserMap):\n     def canChangeChangelists(self):\n         # check to see if we have p4 admin or super-user permissions, either of\n         # which are required to modify changelists.\n-        results = p4CmdList(\"-G protects %s\" % self.depotPath)\n+        results = p4CmdList(\"protects %s\" % self.depotPath)\n         for r in results:\n             if r.has_key('perm'):\n                 if r['perm'] == 'admin':\n@@ -865,6 +870,10 @@ class P4Submit(Command, P4UserMap):\n \n         if self.interactive:\n             submitTemplate = self.prepareLogMessage(template, logMessage)\n+\n+            if self.preserveUser:\n+               submitTemplate = submitTemplate + (\"\\n######## Actual user %s, modified after commit\\n\" % p4User)\n+\n             if os.environ.has_key(\"P4DIFF\"):\n                 del(os.environ[\"P4DIFF\"])\n             diff = \"\"\n-- \n1.7.1\n"},{"id":"167460","messageId":"7vk4e0qxyi.fsf@alter.siamese.dyndns.org","threadId":"27291","inReplyTo":"1304763583-17425-2-git-send-email-luke@diamand.org","subject":"Re: [PATCH] git-p4: small improvements to user-preservation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-09T04:50:29Z","receivedAt":"2011-05-09T04:50:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luke Diamand <luke@diamand.org> writes:\n\n> . Slightly more paranoid checking of results from 'p4 change'\n> . Remove superfluous \"-G\"\n> . Don't modify the username if it is unchanged.\n> . Add a comment in the change template to show what is\n>   going to be done.\n>\n> Signed-off-by: Luke Diamand <luke@diamand.org>\n\nThanks.\n\nThe patch text was different from the interdiff between the previous two\npatches that got Ack from Pete, so I didn't realize this was your\nincremental conversion until now. Will queue this one on 'pu' but I'd like\nan Ack from Pete or other git-p4 folks before merging this down to 'next'.\n"}]}