From: Luke Diamand <luke@diamand.org>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>,
"Romain Merland" <merlorom@yahoo.fr>,
"Miguel Torroja" <miguel.torroja@gmail.com>,
"Lars Schneider" <larsxschneider@gmail.com>,
"George Vanburgh" <gvanburgh@bloomberg.net>,
"Luke Diamand" <luke@diamand.org>
Subject: [PATCH 1/1] git-p4: unshelve: use action==add instead of rev==none
Date: Tue, 22 May 2018 09:41:09 +0100 [thread overview]
Message-ID: <20180522084109.29787-2-luke@diamand.org> (raw)
In-Reply-To: <20180522084109.29787-1-luke@diamand.org>
SZEDER Gábor found that the unshelve tests fail with newer
versions of Perforce (2016 vs 2015).
The problem arises because when a file is added in a P4
shelved changelist, the depot revision is shown as "none"
if using the older p4d (which makes sense - the file doesn't
yet exist, so can't have a revision), but as "1" in the newer
versions of p4d.
For example, adding a file called "new" with 2015.1 and then
shelving that change gives this from "p4 describe" :
... //depot/new#none add
Using the 2018.1 server gives this:
... //depot/new#1 add
We can detect that a file has been added simply by using the
file status ("add") instead, rather than the depot revision,
which is what this change does.
This also fixes a few verbose prints used for debugging this
to be more friendly.
Signed-off-by: Luke Diamand <luke@diamand.org>
---
git-p4.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 364d86dbcc..c80d85af89 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2463,7 +2463,7 @@ class P4Sync(Command, P4UserMap):
"""
ret = p4Cmd(["diff2", "{0}#{1}".format(path, filerev), "{0}@{1}".format(path, revision)])
if verbose:
- print("p4 diff2 %s %s %s => %s" % (path, filerev, revision, ret))
+ print("p4 diff2 path %s filerev %s revision %s => %s" % (path, filerev, revision, ret))
return ret["status"] == "identical"
def extractFilesFromCommit(self, commit, shelved=False, shelved_cl = 0, origin_revision = 0):
@@ -2492,7 +2492,12 @@ class P4Sync(Command, P4UserMap):
if shelved:
file["shelved_cl"] = int(shelved_cl)
- if file["rev"] != "none" and \
+ # For shelved changelists, check that the revision of each file that the
+ # shelve was based on matches the revision that we are using for the
+ # starting point for git-fast-import (self.initialParent). Otherwise
+ # the resulting diff will contain deltas from multiple commits.
+
+ if file["action"] != "add" and \
not self.cmp_shelved(path, file["rev"], origin_revision):
sys.exit("change {0} not based on {1} for {2}, cannot unshelve".format(
commit["change"], self.initialParent, path))
@@ -2610,7 +2615,7 @@ class P4Sync(Command, P4UserMap):
def streamOneP4File(self, file, contents):
relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
relPath = self.encodeWithUTF8(relPath)
- if verbose:
+ if verbose and 'fileSize' in self.stream_file:
size = int(self.stream_file['fileSize'])
sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
sys.stdout.flush()
--
2.17.0.392.gdeb1a6e9b7
next prev parent reply other threads:[~2018-05-22 8:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 8:41 [PATCH 0/1] git-p4: unshelving: fix problem with newer P4 Luke Diamand
2018-05-22 8:41 ` Luke Diamand [this message]
2018-05-22 10:15 ` [PATCH 1/1] git-p4: unshelve: use action==add instead of rev==none SZEDER Gábor
2018-05-22 13:02 ` Luke Diamand
2018-05-23 2:05 ` Junio C Hamano
2018-05-23 7:21 ` [PATCHv5 0/1] git-p4: unshelve: fix problem with newer p4d Luke Diamand
2018-05-23 7:21 ` [PATCHv5 1/1] git-p4: add unshelve command Luke Diamand
2018-05-23 16:41 ` [PATCH 1/1] git-p4: unshelve: use action==add instead of rev==none Mazo, Andrey
2018-05-23 19:12 ` Luke Diamand
2018-05-23 19:38 ` Mazo, Andrey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180522084109.29787-2-luke@diamand.org \
--to=luke@diamand.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gvanburgh@bloomberg.net \
--cc=larsxschneider@gmail.com \
--cc=merlorom@yahoo.fr \
--cc=miguel.torroja@gmail.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).