threads / discuss / 26694

Cannot fetch whole history from Perforce

Subject: Cannot fetch whole history from Perforce

## tl;dr

4 messages between Mar 8, 2011 and Mar 12, 2011.

replies: 3people: 3as markdown or json

Anatol Pomozov· Mar 8, 2011, 18:09 UTC · lore

Hi, I am using HEAD version of the git and I have an issue with git-p4 tool (p4 to git importer).

git-p4 works fine when I import HEAD version of my project

$ git p4 clone //depot/foo/bar --verbose Importing from //depot/foo/bar into bar Reinitialized existing Git repository in /home/anatol/tmp/bar/.git/ Reading pipe: git config git-p4.useclientspec Doing initial import of //depot/foo/bar/ from revision #head into refs/remotes/p4/master Reading pipe: git config git-p4.user Reading pipe: git config git-p4.password Reading pipe: git config git-p4.port Reading pipe: git config git-p4.host Reading pipe: git config git-p4.client p4 -G files //depot/foo/bar/...#head Opening pipe: p4 -G files //depot/foo/bar/...#head commit into refs/remotes/p4/master p4 -G users Opening pipe: p4 -G users p4 -G -x - print Opening pipe: p4 -G -x - print ...A bunch of files... executing git branch master refs/remotes/p4/master executing git checkout -f

But it fails with a cryptic error when I try to import @all revisions:
$ git p4 clone //depot/foo/bar@all --verbose
Importing from //depot/foo/bar@all into bar
Initialized empty Git repository in /home/anatol/tmp/bar/.git/
Reading pipe: git config git-p4.useclientspec
Traceback (most recent call last):
  File "/home/anatol/bin/git-p4", line 2033, in <module>
    main()
  File "/home/anatol/bin/git-p4", line 2028, in main
    if not cmd.run(args):
  File "/home/anatol/bin/git-p4", line 1904, in run
    if not P4Sync.run(self, depotPaths):
  File "/home/anatol/bin/git-p4", line 1767, in run
    die("No remote p4 branches.  Perhaps you never did \"git p4
clone\" in here.");
  File "/home/anatol/bin/git-p4", line 59, in die
    raise Exception(msg)
Exception: No remote p4 branches.  Perhaps you never did "git p4 clone" in here.

Can it be related to Pete's changes? http://permalink.gmane.org/gmane.comp.version-control.git/167281

Thomas Berg· Mar 8, 2011, 20:36 UTC · re: Anatol Pomozov · lore

Re: Cannot fetch whole history from Perforce

Hi,
On Tue, Mar 8, 2011 at 7:09 PM, Anatol Pomozov <anatol.pomozov@gmail.com> wrote:
Show 7 quoted lines
> Hi, I am using HEAD version of the git and I have an issue with git-p4
> tool (p4 to git importer).
>
> git-p4 works fine when I import HEAD version of my project
>
> $ git p4 clone //depot/foo/bar --verbose
> But it fails with a cryptic error when I try to import @all revisions:
[...]
>
> $ git p4 clone //depot/foo/bar@all --verbose
> Importing from //depot/foo/bar@all into bar
[...]
>
> Can it be related to Pete's changes?
> http://permalink.gmane.org/gmane.comp.version-control.git/167281

Sorry for not testing myself before responding, but in my experience with Perforce a trailing slash may be significant. Did you try this format? $ git p4 clone //depot/foo/bar/@all If that also fails you may be onto something.

- Thomas
Tor Arvid Lund· Mar 8, 2011, 22:33 UTC · re: Thomas Berg · lore

Re: Cannot fetch whole history from Perforce

On Tue, Mar 8, 2011 at 9:36 PM, Thomas Berg <merlin66b@gmail.com> wrote:
Show 18 quoted lines
> Hi,
>
> On Tue, Mar 8, 2011 at 7:09 PM, Anatol Pomozov <anatol.pomozov@gmail.com> wrote:
>> Hi, I am using HEAD version of the git and I have an issue with git-p4
>> tool (p4 to git importer).
>>
>> git-p4 works fine when I import HEAD version of my project
>>
>> $ git p4 clone //depot/foo/bar --verbose
>> But it fails with a cryptic error when I try to import @all revisions:
> [...]
>>
>> $ git p4 clone //depot/foo/bar@all --verbose
>> Importing from //depot/foo/bar@all into bar
> [...]
>>
>> Can it be related to Pete's changes?
>> http://permalink.gmane.org/gmane.comp.version-control.git/167281

Whoops! The P4Clone class is a subclass of P4Sync, which means that this check (The one you mention from e32e00dc) will be done on every clone with @all. We can't have that :)

It works for me if I patch it with this one-liner (but it's not exactly a beautiful looking line of code anymore):

    -- Tor Arvid
---
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2df3bb2..7cb479c 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1763,7 +1763,7 @@ class P4Sync(Command):

                 changes.sort()
             else:
-                if not self.p4BranchesInGit:
+                if not isinstance(self, P4Clone) and not self.p4BranchesInGit:
                     die("No remote p4 branches.  Perhaps you never
did \"git p4 clone\" in here.");
                 if self.verbose:
                     print "Getting p4 changes for %s...%s" % (',
'.join(self.depotPaths),
Anatol Pomozov· Mar 12, 2011, 06:45 UTC · re: Tor Arvid Lund · lore

Re: Cannot fetch whole history from Perforce

Sorry for the slow response.
On Tue, Mar 8, 2011 at 2:33 PM, Tor Arvid Lund <torarvid@gmail.com> wrote:
Show 45 quoted lines
> On Tue, Mar 8, 2011 at 9:36 PM, Thomas Berg <merlin66b@gmail.com> wrote:
>> Hi,
>>
>> On Tue, Mar 8, 2011 at 7:09 PM, Anatol Pomozov <anatol.pomozov@gmail.com> wrote:
>>> Hi, I am using HEAD version of the git and I have an issue with git-p4
>>> tool (p4 to git importer).
>>>
>>> git-p4 works fine when I import HEAD version of my project
>>>
>>> $ git p4 clone //depot/foo/bar --verbose
>>> But it fails with a cryptic error when I try to import @all revisions:
>> [...]
>>>
>>> $ git p4 clone //depot/foo/bar@all --verbose
>>> Importing from //depot/foo/bar@all into bar
>> [...]
>>>
>>> Can it be related to Pete's changes?
>>> http://permalink.gmane.org/gmane.comp.version-control.git/167281
>
> Whoops! The P4Clone class is a subclass of P4Sync, which means that
> this check (The one you mention from e32e00dc) will be done on every
> clone with @all. We can't have that :)
>
> It works for me if I patch it with this one-liner (but it's not
> exactly a beautiful looking line of code anymore):
>
>    -- Tor Arvid
> ---
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 2df3bb2..7cb479c 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -1763,7 +1763,7 @@ class P4Sync(Command):
>
>                 changes.sort()
>             else:
> -                if not self.p4BranchesInGit:
> +                if not isinstance(self, P4Clone) and not self.p4BranchesInGit:
>                     die("No remote p4 branches.  Perhaps you never
> did \"git p4 clone\" in here.");
>                 if self.verbose:
>                     print "Getting p4 changes for %s...%s" % (',
> '.join(self.depotPaths),
Yep it fixes the problem for me. Do you have a plan to propose it for upstream?

← back to recent threads