# Git p4 sync changelist interval

8 messages from 2017-06-04 to 2017-06-06. Participants: Андрей Ефанов, Luke Diamand.
Thread: https://gitlist.dev/t/46112

## Андрей Ефанов, 2017-06-04 09:56

Subject: Git p4 sync changelist interval
Message-ID: <CAPRL90JeQ3i1m7ydYzTCFgtZ4cC+gYEXFeAKvCuAVwPLXpsgXg@mail.gmail.com>
URL: https://gitlist.dev/e/CAPRL90JeQ3i1m7ydYzTCFgtZ4cC%2BgYEXFeAKvCuAVwPLXpsgXg%40mail.gmail.com

```
Hello,

My goal is to sync the repository from p4 using an interval of
changelists so that the first changelist version of the repository
would be considered as an initial commit.
So I used the following command:

 git p4 clone //depot@cl1,cl2

And when it finished, the files, that were created before the cl1 were
not in the HEAD.

The problem, as I see it, is that before syncing changes in the given
range, p4 task does not sync to cl1 version of the repo, and applies
commits to the empty repository.
Is it a bug or my misunderstanding of how git p4 should work?

Regards,
Andrew Yefanov

```

## Luke Diamand, 2017-06-04 11:09

Subject: Re: Git p4 sync changelist interval
Message-ID: <CAE5ih7-Nmy2J6zO9mx7g=L7Ey9PnVUcD3wnXBN4_0znwOHaUeQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih7-Nmy2J6zO9mx7g%3DL7Ey9PnVUcD3wnXBN4_0znwOHaUeQ%40mail.gmail.com
In-Reply-To: <CAPRL90JeQ3i1m7ydYzTCFgtZ4cC+gYEXFeAKvCuAVwPLXpsgXg@mail.gmail.com>

```
On 4 June 2017 at 10:56, Андрей Ефанов <1134togo@gmail.com> wrote:
> Hello,
>
> My goal is to sync the repository from p4 using an interval of
> changelists so that the first changelist version of the repository
> would be considered as an initial commit.
> So I used the following command:
>
>  git p4 clone //depot@cl1,cl2
>
> And when it finished, the files, that were created before the cl1 were
> not in the HEAD.

Do you mean that if foo.c was created at cl1+1, that after doing the
clone, it wasn't there?

If so, that doesn't sound right to me.

I have just tried doing what I think you mean:

1. Create p4 depot
2. Add foo.c (at CL 2)
3. Add bar.c (at CL 3)
4. git-p4 clone //depot@2,3

I end up with both files.

>
> The problem, as I see it, is that before syncing changes in the given
> range, p4 task does not sync to cl1 version of the repo, and applies
> commits to the empty repository.
> Is it a bug or my misunderstanding of how git p4 should work?

Possibly I'm misunderstanding what you're doing! Can you give a
sequence of steps to show the problem?

Thanks!
Luke

```

## Андрей Ефанов, 2017-06-05 18:50

Subject: Fwd: Git p4 sync changelist interval
Message-ID: <CAKOu8-0DG_wQf4ch_MH=rjAncg1iP=uA1U7XHgXe7JNrEJSkGg@mail.gmail.com>
URL: https://gitlist.dev/e/CAKOu8-0DG_wQf4ch_MH%3DrjAncg1iP%3DuA1U7XHgXe7JNrEJSkGg%40mail.gmail.com
In-Reply-To: <CAKOu8-2iBV=sAP0WeRMQFT+0y5cJ1g6A3bQ5x=D=8q9ocxnBVg@mail.gmail.com>

```
2017-06-04 14:09 GMT+03:00 Luke Diamand <luke@diamand.org>:
>
> On 4 June 2017 at 10:56, Андрей Ефанов <1134togo@gmail.com> wrote:
> > Hello,
> >
> > My goal is to sync the repository from p4 using an interval of
> > changelists so that the first changelist version of the repository
> > would be considered as an initial commit.
> > So I used the following command:
> >
> >  git p4 clone //depot@cl1,cl2
> >
> > And when it finished, the files, that were created before the cl1 were
> > not in the HEAD.
>
> Do you mean that if foo.c was created at cl1+1, that after doing the
> clone, it wasn't there?
>
> If so, that doesn't sound right to me.
>
> I have just tried doing what I think you mean:
>
> 1. Create p4 depot
> 2. Add foo.c (at CL 2)
> 3. Add bar.c (at CL 3)
> 4. git-p4 clone //depot@2,3
>
> I end up with both files.
>
> >
> > The problem, as I see it, is that before syncing changes in the given
> > range, p4 task does not sync to cl1 version of the repo, and applies
> > commits to the empty repository.
> > Is it a bug or my misunderstanding of how git p4 should work?
>
> Possibly I'm misunderstanding what you're doing! Can you give a
> sequence of steps to show the problem?

What I meant is:

1. Create p4 depot
2. Add first.file (CL 2)
3. Add second.file (at CL 3)
4. Add third.file (at CL 4)
5. Modify first.file (at CL 5)
4. git-p4 clone //depot@3,5

In this case first.file, will not be represented in the repository.

Regards,
Andrew

```

## Luke Diamand, 2017-06-05 23:29

Subject: Re: Git p4 sync changelist interval
Message-ID: <CAE5ih79VCpmMmaq0AEW=5HeOmVdpjpSmh=1CheUZbqvbNfBFbA@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih79VCpmMmaq0AEW%3D5HeOmVdpjpSmh%3D1CheUZbqvbNfBFbA%40mail.gmail.com
In-Reply-To: <CAKOu8-0DG_wQf4ch_MH=rjAncg1iP=uA1U7XHgXe7JNrEJSkGg@mail.gmail.com>

```
On 5 June 2017 at 19:50, Андрей Ефанов <1134togo@gmail.com> wrote:
> 2017-06-04 14:09 GMT+03:00 Luke Diamand <luke@diamand.org>:
>>
>> On 4 June 2017 at 10:56, Андрей Ефанов <1134togo@gmail.com> wrote:
>> > Hello,
>> >
>> > My goal is to sync the repository from p4 using an interval of
>> > changelists so that the first changelist version of the repository
>> > would be considered as an initial commit.
>> > So I used the following command:
>> >
>> >  git p4 clone //depot@cl1,cl2
>> >
>> > And when it finished, the files, that were created before the cl1 were
>> > not in the HEAD.
>>
>> Do you mean that if foo.c was created at cl1+1, that after doing the
>> clone, it wasn't there?
>>
>> If so, that doesn't sound right to me.
>>
>> I have just tried doing what I think you mean:
>>
>> 1. Create p4 depot
>> 2. Add foo.c (at CL 2)
>> 3. Add bar.c (at CL 3)
>> 4. git-p4 clone //depot@2,3
>>
>> I end up with both files.
>>
>> >
>> > The problem, as I see it, is that before syncing changes in the given
>> > range, p4 task does not sync to cl1 version of the repo, and applies
>> > commits to the empty repository.
>> > Is it a bug or my misunderstanding of how git p4 should work?
>>
>> Possibly I'm misunderstanding what you're doing! Can you give a
>> sequence of steps to show the problem?
>
> What I meant is:
>
> 1. Create p4 depot
> 2. Add first.file (CL 2)
> 3. Add second.file (at CL 3)
> 4. Add third.file (at CL 4)
> 5. Modify first.file (at CL 5)
> 4. git-p4 clone //depot@3,5
>
> In this case first.file, will not be represented in the repository.

Hmmm, it's not working right for me. Although in my case I seem to be
missing the second file.

It's fine if I don't use the revision range "3,5".

Luke

```

## Luke Diamand, 2017-06-06 07:00

Subject: Re: Git p4 sync changelist interval
Message-ID: <CAE5ih7_yt4zjju3F34gUTKLPip9T98ow=shZY7EPe3yE8gk32Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih7_yt4zjju3F34gUTKLPip9T98ow%3DshZY7EPe3yE8gk32Q%40mail.gmail.com
In-Reply-To: <CAE5ih79VCpmMmaq0AEW=5HeOmVdpjpSmh=1CheUZbqvbNfBFbA@mail.gmail.com>

```
On 6 June 2017 at 00:29, Luke Diamand <luke@diamand.org> wrote:
> On 5 June 2017 at 19:50, Андрей Ефанов <1134togo@gmail.com> wrote:
>> 2017-06-04 14:09 GMT+03:00 Luke Diamand <luke@diamand.org>:
>>>
>>>
>>> >
>>> > The problem, as I see it, is that before syncing changes in the given
>>> > range, p4 task does not sync to cl1 version of the repo, and applies
>>> > commits to the empty repository.
>>> > Is it a bug or my misunderstanding of how git p4 should work?
>>>
>>> Possibly I'm misunderstanding what you're doing! Can you give a
>>> sequence of steps to show the problem?
>>
>> What I meant is:
>>
>> 1. Create p4 depot
>> 2. Add first.file (CL 2)
>> 3. Add second.file (at CL 3)
>> 4. Add third.file (at CL 4)
>> 5. Modify first.file (at CL 5)
>> 4. git-p4 clone //depot@3,5
>>
>> In this case first.file, will not be represented in the repository.
>
> Hmmm, it's not working right for me. Although in my case I seem to be
> missing the second file.
>
> It's fine if I don't use the revision range "3,5".

It's also fine if I do:

git p4 sync //depot@3
cd depot
git p4 rebase

```

## Luke Diamand, 2017-06-06 07:49

Subject: Re: Git p4 sync changelist interval
Message-ID: <CAE5ih7-+EzUhjXCCOu_oELof_2X_qf5snoqUZyuRNqEu+p=ewg@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih7-%2BEzUhjXCCOu_oELof_2X_qf5snoqUZyuRNqEu%2Bp%3Dewg%40mail.gmail.com
In-Reply-To: <CAE5ih7_yt4zjju3F34gUTKLPip9T98ow=shZY7EPe3yE8gk32Q@mail.gmail.com>

```
On 6 June 2017 at 08:00, Luke Diamand <luke@diamand.org> wrote:
> On 6 June 2017 at 00:29, Luke Diamand <luke@diamand.org> wrote:
>> On 5 June 2017 at 19:50, Андрей Ефанов <1134togo@gmail.com> wrote:
>>> 2017-06-04 14:09 GMT+03:00 Luke Diamand <luke@diamand.org>:
>>>>
>>>>
>>>> >
>>>> > The problem, as I see it, is that before syncing changes in the given
>>>> > range, p4 task does not sync to cl1 version of the repo, and applies
>>>> > commits to the empty repository.
>>>> > Is it a bug or my misunderstanding of how git p4 should work?
>>>>
>>>> Possibly I'm misunderstanding what you're doing! Can you give a
>>>> sequence of steps to show the problem?
>>>
>>> What I meant is:
>>>
>>> 1. Create p4 depot
>>> 2. Add first.file (CL 2)
>>> 3. Add second.file (at CL 3)
>>> 4. Add third.file (at CL 4)
>>> 5. Modify first.file (at CL 5)
>>> 4. git-p4 clone //depot@3,5
>>>
>>> In this case first.file, will not be represented in the repository.
>>
>> Hmmm, it's not working right for me. Although in my case I seem to be
>> missing the second file.
>>
>> It's fine if I don't use the revision range "3,5".
>
> It's also fine if I do:
>
> git p4 sync //depot@3
> cd depot
> git p4 rebase

It seems to be something to do with the code around line 3395 that says:

    if self.changeRange == "@all":
        self.changeRange = ""
    elif ',' not in self.changeRange:

It's finding a lower revision number with which to later call
importHeadRevision(), but that only seems to be called if the revision
range does *not* have a "," in it. As a result, we never actually call
importHeadRevision() and so files end up missing.

The obvious fix of fishing out the "@3" from the "@3,5" revision range
works in this instance, but breaks some of the regression tests.

Luke

```

## Андрей Ефанов, 2017-06-06 07:56

Subject: Re: Git p4 sync changelist interval
Message-ID: <CAKOu8-2mB=fcFUd86vdK+z==0bX3rUvY-VuNjQ-C6t++uik8YQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAKOu8-2mB%3DfcFUd86vdK%2Bz%3D%3D0bX3rUvY-VuNjQ-C6t%2B%2Buik8YQ%40mail.gmail.com
In-Reply-To: <CAE5ih7-+EzUhjXCCOu_oELof_2X_qf5snoqUZyuRNqEu+p=ewg@mail.gmail.com>

```
2017-06-06 10:49 GMT+03:00 Luke Diamand <luke@diamand.org>:
> On 6 June 2017 at 08:00, Luke Diamand <luke@diamand.org> wrote:
>> On 6 June 2017 at 00:29, Luke Diamand <luke@diamand.org> wrote:
>>> On 5 June 2017 at 19:50, Андрей Ефанов <1134togo@gmail.com> wrote:
>>>> 2017-06-04 14:09 GMT+03:00 Luke Diamand <luke@diamand.org>:
>>>>>
>>>>>
>>>>> >
>>>>> > The problem, as I see it, is that before syncing changes in the given
>>>>> > range, p4 task does not sync to cl1 version of the repo, and applies
>>>>> > commits to the empty repository.
>>>>> > Is it a bug or my misunderstanding of how git p4 should work?
>>>>>
>>>>> Possibly I'm misunderstanding what you're doing! Can you give a
>>>>> sequence of steps to show the problem?
>>>>
>>>> What I meant is:
>>>>
>>>> 1. Create p4 depot
>>>> 2. Add first.file (CL 2)
>>>> 3. Add second.file (at CL 3)
>>>> 4. Add third.file (at CL 4)
>>>> 5. Modify first.file (at CL 5)
>>>> 4. git-p4 clone //depot@3,5
>>>>
>>>> In this case first.file, will not be represented in the repository.
>>>
>>> Hmmm, it's not working right for me. Although in my case I seem to be
>>> missing the second file.
>>>
>>> It's fine if I don't use the revision range "3,5".
>>
>> It's also fine if I do:
>>
>> git p4 sync //depot@3
>> cd depot
>> git p4 rebase
>
> It seems to be something to do with the code around line 3395 that says:
>
>     if self.changeRange == "@all":
>         self.changeRange = ""
>     elif ',' not in self.changeRange:
>
> It's finding a lower revision number with which to later call
> importHeadRevision(), but that only seems to be called if the revision
> range does *not* have a "," in it. As a result, we never actually call
> importHeadRevision() and so files end up missing.
>
> The obvious fix of fishing out the "@3" from the "@3,5" revision range
> works in this instance, but breaks some of the regression tests.
>
> Luke

I did the same change before and it worked for me. I'd like to find
out if it is a bug (I think it is), a normal behavior or am I doing
something wrong.

So according to what you say, it is a bug.

Andrew

```

## Luke Diamand, 2017-06-06 10:54

Subject: Re: Git p4 sync changelist interval
Message-ID: <CAE5ih79_0XhT6Nb5WMki0kCZ_FaWSCYc5H=fZmp3esQSN-tF1w@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih79_0XhT6Nb5WMki0kCZ_FaWSCYc5H%3DfZmp3esQSN-tF1w%40mail.gmail.com
In-Reply-To: <CAKOu8-2mB=fcFUd86vdK+z==0bX3rUvY-VuNjQ-C6t++uik8YQ@mail.gmail.com>

```
On 6 June 2017 at 08:56, Андрей Ефанов <1134togo@gmail.com> wrote:
>>
>> It seems to be something to do with the code around line 3395 that says:
>>
>>     if self.changeRange == "@all":
>>         self.changeRange = ""
>>     elif ',' not in self.changeRange:
>>
>> It's finding a lower revision number with which to later call
>> importHeadRevision(), but that only seems to be called if the revision
>> range does *not* have a "," in it. As a result, we never actually call
>> importHeadRevision() and so files end up missing.
>>
>> The obvious fix of fishing out the "@3" from the "@3,5" revision range
>> works in this instance, but breaks some of the regression tests.
>>
>> Luke
>
> I did the same change before and it worked for me. I'd like to find
> out if it is a bug (I think it is), a normal behavior or am I doing
> something wrong.
>
> So according to what you say, it is a bug.

It's a bug!

I think you can workaround it by doing:

$ git p4 clone //depot@3
$ git p4 sync

I'll see if I can workout why my obvious fix caused the tests to fail.

```
