From patchwork Fri Nov 15 14:42:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11246497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95C326C1 for ; Fri, 15 Nov 2019 14:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 761792073A for ; Fri, 15 Nov 2019 14:43:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nNvduCKA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727655AbfKOOnC (ORCPT ); Fri, 15 Nov 2019 09:43:02 -0500 Received: from mail-wm1-f46.google.com ([209.85.128.46]:55074 "EHLO mail-wm1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727585AbfKOOnC (ORCPT ); Fri, 15 Nov 2019 09:43:02 -0500 Received: by mail-wm1-f46.google.com with SMTP id z26so9882224wmi.4 for ; Fri, 15 Nov 2019 06:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ulXd4IThug2U96xg6JWSWBuRUK5z8mgnfvbgtowERFM=; b=nNvduCKAd8DdXXEWfgqRcWX5MxcDaAdEDwlyFYl8Vo2weonfc13PxtaWOzyyd8Kp4b jWOOotv/8rypVspfRWmX3dQH8N1X0V2cJIcxh2PnbXwV67GbqUpgxzsUZWla1xCNS/XD i/DV2dgIo+9QJnSukDNTNPAgAyVTXggeuFy5C9FcT4IAfyLnoRs2TMH+hA+AHdC/YZ+B WKC2k5abjPSv4mA0K48d9MvVbP1kjntEry+XkP14I4J/JWqwE7vnd2+Hxs7Fpw4Th/M/ yjwLxcbHoMOti7x5YUj1IQq4iIBHRMVbo6aP3gixVA8uIcYIdBTG3KfhlOsZ3TDInCm4 7kuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ulXd4IThug2U96xg6JWSWBuRUK5z8mgnfvbgtowERFM=; b=S8vmpWpcwM8RklnTqDWS5Wf8r6Kc4iX6r7ExktOolHzsQJ+C9017zABsQXNOiUpBFn ndgO26/23xiu5fql3W6xsmMR+6s1QOpJUINTek/fAY4r535tFo9BYzzdh5JKnQIsmMMp DsL5eutYl+sHP3HKnpjPSUBVUN/kBJhdytZDT5vhHMxHMAoE+Z/+EHAopefGaCXio4I9 9fRY+doC/X5ddZJQ2g085nuXZR0nFcH7NvYU0RqfUd/wHyMsacDHZwWFR78RQR35EDmf v4VdBiqsCX/cTua8GGicU5hY4/DQWUazUcKB2Lf2DWKPKOpe5IYgGxksePwmA64gW12q uT+Q== X-Gm-Message-State: APjAAAXlb9+2XxVHdYmBmVW4Fus75R+BRQr8VPtjZmV694U9ouaSeOnb 0lD4leE0baeiSEFTF495JIwm+feQ X-Google-Smtp-Source: APXvYqwW44/9HJr8Xm3T00m2mrtZKfU0HxrWRDTTRtJ6eCSrTtl5J/0+drGDAHq7hYmkX2JJl+ZdyQ== X-Received: by 2002:a1c:6146:: with SMTP id v67mr15279387wmb.102.1573828980048; Fri, 15 Nov 2019 06:43:00 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j66sm9055086wma.19.2019.11.15.06.42.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2019 06:42:59 -0800 (PST) Message-Id: <0bca930ff82623bbef172b4cb6c36ef8e5c46098.1573828978.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 15 Nov 2019 14:42:56 +0000 Subject: [PATCH v2 1/3] Cast byte strings to unicode strings in python3 Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene Signed-off-by: Ben Keene --- git-p4.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/git-p4.py b/git-p4.py index 60c73b6a37..6e8b3a26cd 100755 --- a/git-p4.py +++ b/git-p4.py @@ -36,12 +36,22 @@ unicode = str bytes = bytes basestring = (str,bytes) + isunicode = True + def ustring(text): + """Returns the byte string as a unicode string""" + if text == '' or text == b'': + return '' + return unicode(text, "utf-8") else: # 'unicode' exists, must be Python 2 str = str unicode = unicode bytes = str basestring = basestring + isunicode = False + def ustring(text): + """Returns the byte string unchanged""" + return text try: from subprocess import CalledProcessError @@ -196,6 +206,8 @@ def read_pipe_full(c): expand = isinstance(c,basestring) p = subprocess.Popen(c, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=expand) (out, err) = p.communicate() + out = ustring(out) + err = ustring(err) return (p.returncode, out, err) def read_pipe(c, ignore_error=False): @@ -263,6 +275,7 @@ def p4_has_move_command(): cmd = p4_build_cmd(["move", "-k", "@from", "@to"]) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() + err = ustring(err) # return code will be 1 in either case if err.find("Invalid option") >= 0: return False @@ -646,10 +659,18 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False, if skip_info: if 'code' in entry and entry['code'] == 'info': continue + if b'code' in entry and entry[b'code'] == b'info': + continue if cb is not None: cb(entry) else: - result.append(entry) + if isunicode: + out = {} + for key, value in entry.items(): + out[ustring(key)] = ustring(value) + result.append(out) + else: + result.append(entry) except EOFError: pass exitCode = p4.wait() @@ -792,7 +813,7 @@ def gitConfig(key, typeSpecifier=None): cmd += [ key ] s = read_pipe(cmd, ignore_error=True) _gitConfig[key] = s.strip() - return _gitConfig[key] + return ustring(_gitConfig[key]) def gitConfigBool(key): """Return a bool, using git config --bool. It is True only if the @@ -860,6 +881,7 @@ def branch_exists(branch): cmd = [ "git", "rev-parse", "--symbolic", "--verify", branch ] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate() + out = ustring(out) if p.returncode: return False # expect exactly one line of output: the branch name From patchwork Fri Nov 15 14:42:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11246501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6299F17E8 for ; Fri, 15 Nov 2019 14:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 435862073B for ; Fri, 15 Nov 2019 14:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FZAXUDKs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727690AbfKOOnE (ORCPT ); Fri, 15 Nov 2019 09:43:04 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36741 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727619AbfKOOnE (ORCPT ); Fri, 15 Nov 2019 09:43:04 -0500 Received: by mail-wm1-f68.google.com with SMTP id c22so10680825wmd.1 for ; Fri, 15 Nov 2019 06:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=uBGnmh6C8b3U8srmNO7oGNYBad2Ysh1xnMTiZq5goYM=; b=FZAXUDKsXoPxzQ6FPDxCWEyxBZ18boMet4wCC8CL/inWOBgTi9qD3IpR7xoVQYPjjb 4g32h4DzGvLKGtNlPVqMK/H12KMxYdiZ1T7YuKMSM9UunrvWRi7JEjX9p6uRWFXQCM/N QuRfNQFgm3ng3ivbrHRXsHixDaf4DZoNFpa9lqPvk3O5aq2NV0eKSNP+LzpKqefoYqD7 ZYqwdjpuz2pLTgTiLlooZAK2TCDr38sjI00hUQ6XI/Y4yoOGlY1G1h8R1usT8+wDwpFn cO4F2PV6jaQFiM8jDqONf65+/L8qOP5WsagEIXje0Qf5g7KVv5eAsydC0iBd4vyKZkn6 Lg1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=uBGnmh6C8b3U8srmNO7oGNYBad2Ysh1xnMTiZq5goYM=; b=CsvyTW4FwNIdBtiXy7zS2IBbIDCxnb306emhu67GnkH9gP6r+/YtQpakci51ni9hXl +FDlqPvkAi/BmrgWmtbn5nMQKolzHs3kxvgdc68nJC3X+lNkLrUalnDYwxaEVV3IetG7 LLtbq25WW7AaUcWcINP3EvKK55hXdAO29Y/e7uMJiBEaCG5tAXWvwynnI4wD6dcgh/ht y+0OCTX5Z6dVKXzZaYQOOBVmWHL1V6poRNyIfotZGdzSPlZNIoH6Sgkgysv7ywWIVxFF L6PXm+7kFqkTjo+fHWPLwF4nsSYpCuMhOF9szGISYdrseSTUTBn67PgTW+aOumsAVtO9 eMjA== X-Gm-Message-State: APjAAAWfIAoI85YqdDNEZE6axR+g6tqPDoRti/T3BAa5FPs9cakQOyY4 N45i2/5Xl3JWOaXeWRtWp2zKkEBD X-Google-Smtp-Source: APXvYqynhKnJnM3xSfq8+4th650ZKsl3ChfCa+uyXN9ChtO8OZVSy2zMLxRdG1prbOM2sIO3B1rIEA== X-Received: by 2002:a7b:c743:: with SMTP id w3mr15588962wmk.165.1573828980695; Fri, 15 Nov 2019 06:43:00 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j11sm11362657wrq.26.2019.11.15.06.43.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2019 06:43:00 -0800 (PST) Message-Id: <98bae92fda9ca01d01b2e9fb70b04b00470e7bec.1573828978.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 15 Nov 2019 14:42:57 +0000 Subject: [PATCH v2 2/3] Added general variable git-p4.binary and added a default for windows of 'P4.EXE' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene Signed-off-by: Ben Keene --- Documentation/git-p4.txt | 5 +++++ git-p4.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt index 3494a1db3e..e206e69250 100644 --- a/Documentation/git-p4.txt +++ b/Documentation/git-p4.txt @@ -547,6 +547,11 @@ git-p4.retries:: Set the value to 0 to disable retries or if your p4 version does not support retries (pre 2012.2). +git-p4.binary:: + Specifies the p4 executable used by git-p4 to process commands. + The default value for Windows is `p4.exe` and for all other + systems the default is `p4`. + Clone and sync variables ~~~~~~~~~~~~~~~~~~~~~~~~ git-p4.syncFromOrigin:: diff --git a/git-p4.py b/git-p4.py index 6e8b3a26cd..160d966ee1 100755 --- a/git-p4.py +++ b/git-p4.py @@ -26,6 +26,8 @@ import zlib import ctypes import errno +import os.path +from os import path # support basestring in python3 try: @@ -85,7 +87,17 @@ def p4_build_cmd(cmd): location. It means that hooking into the environment, or other configuration can be done more easily. """ - real_cmd = ["p4"] + # Look for the P4 binary + p4bin = gitConfig("git-p4.binary") + real_cmd = [] + if p4bin != "": + if path.exists(p4bin): + real_cmd = [p4bin] + if real_cmd == []: + if (platform.system() == "Windows"): + real_cmd = ["p4.exe"] + else: + real_cmd = ["p4"] user = gitConfig("git-p4.user") if len(user) > 0: From patchwork Fri Nov 15 14:42:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11246499 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF8D713BD for ; Fri, 15 Nov 2019 14:43:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E1E02073A for ; Fri, 15 Nov 2019 14:43:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p43VQI92" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727685AbfKOOnD (ORCPT ); Fri, 15 Nov 2019 09:43:03 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51771 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727427AbfKOOnD (ORCPT ); Fri, 15 Nov 2019 09:43:03 -0500 Received: by mail-wm1-f67.google.com with SMTP id q70so9900136wme.1 for ; Fri, 15 Nov 2019 06:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=gSvCaLW+fSQ3phRjmePgBbG0fT+fHfGnjuZKAYco1ZQ=; b=p43VQI92PYzN5ykZEKjKAHU3OHsQjfpwUkzcqxGbeA5vy8zclwYGVSf0H48y+bqbuR Fe69YqOTYpY3oqhG2N9QZ55PaY+A8bj43BcfFtTv0pN9XmWmjY8ShbsS0hVj6Y6BdfuC aEjZ34ZW+/c2R+X6IY7cKIl94gAp+/3c92E+ng3pAVLV8Hn6Flq+Hu2CIIJkX6EcAw+3 ErVsY2Co1smwQ9LgMKlsLqWyHMJmI3NrDW3Zed7lZA0tpvo3vHo2oa9R6mGlwJNt7fPL 5iQAahQ3n0gbkmN1ezYusE4xzSTY7YM79o+3rcQsa/TTHN/57XxCf5p3sBN9OPgCSvjx DrGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=gSvCaLW+fSQ3phRjmePgBbG0fT+fHfGnjuZKAYco1ZQ=; b=cl5SVUsofjGALnu+AZ56YBu782qY1dm3eRNQGnDPTyplvV6IgdffytRziubhASNUIM VgbH6QPNEgA2XTbyAP/fhJtemDLXh6W1ZXhFGMnEFfXF2U0cSGv+jeSBz+k72lBMYFP3 ph0yGUZ7mXOVE/abN17yqLxEJuH+p2FMJ2JbiUqHmW433xzlqbXFDOjHbmlPgGA0X0yv bdle1DykHcLssqZKU4Z4cVRrNBOHH49bsQPA0DyTfeGlh8OaZVv5BUuv697upWOCPuqq piEXNdPBjE0+1Gzzu6PR2eAUByqvzoVTvucnKV1YYhlYRlHTJS+9ZQD6Llanlw2z0Zii 6phA== X-Gm-Message-State: APjAAAXCT7m+VSWoAE/f+3yHoh4eRUYYxTkdVr+06IX9c09Xue2+2dfE xyePFARLrJGg9CWYmT85I87Fipbu X-Google-Smtp-Source: APXvYqwLvd7xyxIx2ZvK1qQR/Y+rAjv8rssGiNBRsHYoWSyfo9BUkMy0GjQIYXrxGoDWd4CbzvcOiw== X-Received: by 2002:a1c:810d:: with SMTP id c13mr16197695wmd.154.1573828981463; Fri, 15 Nov 2019 06:43:01 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y78sm10547682wmd.32.2019.11.15.06.43.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2019 06:43:01 -0800 (PST) Message-Id: In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 15 Nov 2019 14:42:58 +0000 Subject: [PATCH v2 3/3] Changed the name of the parameter from git-p4.binary to git-p4.p4program Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene Signed-off-by: Ben Keene --- Documentation/git-p4.txt | 2 +- git-p4.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt index e206e69250..21ef100c28 100644 --- a/Documentation/git-p4.txt +++ b/Documentation/git-p4.txt @@ -547,7 +547,7 @@ git-p4.retries:: Set the value to 0 to disable retries or if your p4 version does not support retries (pre 2012.2). -git-p4.binary:: +git-p4.p4program:: Specifies the p4 executable used by git-p4 to process commands. The default value for Windows is `p4.exe` and for all other systems the default is `p4`. diff --git a/git-p4.py b/git-p4.py index 160d966ee1..4fbb7344f1 100755 --- a/git-p4.py +++ b/git-p4.py @@ -88,7 +88,7 @@ def p4_build_cmd(cmd): can be done more easily. """ # Look for the P4 binary - p4bin = gitConfig("git-p4.binary") + p4bin = gitConfig("git-p4.p4program") real_cmd = [] if p4bin != "": if path.exists(p4bin):