Patchwork graft: allow to not preserve original source in subsequent grafts

login
register
mail settings
Submitter Alexander Drozdov
Date April 1, 2014, 3:24 a.m.
Message ID <e7b0eaf7bbbd35d5cc0b.1396322678@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/4178/
State Deferred
Headers show

Comments

Alexander Drozdov - April 1, 2014, 3:24 a.m.
# HG changeset patch
# User Alexander Drozdov <al.drozdov@gmail.com>
# Date 1393909791 -14400
#      Tue Mar 04 09:09:51 2014 +0400
# Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
# Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
graft: allow to not preserve original source in subsequent grafts

From dc9fb7015d7f, graft preserves original source when grafting
changeset that was grafted from another branch.

That may be undesirable in some situations. For example, the first
graft may be from user's private branch, so the source changeset may
not be present in a public repository.

This changeset adds -S (--currentsource) option to always refer to
grafted changeset as a source revision.
Augie Fackler - April 12, 2014, 4:06 p.m.
On Tue, Apr 01, 2014 at 07:24:38AM +0400, Alexander Drozdov wrote:
> # HG changeset patch
> # User Alexander Drozdov <al.drozdov@gmail.com>
> # Date 1393909791 -14400
> #      Tue Mar 04 09:09:51 2014 +0400
> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
> graft: allow to not preserve original source in subsequent grafts

Feature seems mostly reasonable to me, but the flag name is completely
baffling. Maybe it could be something like

--no-record-source?

Other people will probably have better naming proposals than I will.

>
> From dc9fb7015d7f, graft preserves original source when grafting
> changeset that was grafted from another branch.
>
> That may be undesirable in some situations. For example, the first
> graft may be from user's private branch, so the source changeset may
> not be present in a public repository.
>
> This changeset adds -S (--currentsource) option to always refer to
> grafted changeset as a source revision.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3036,6 +3036,8 @@
>       ('', 'log', None, _('append graft info to log message')),
>       ('D', 'currentdate', False,
>        _('record the current date as commit date')),
> +     ('S', 'currentsource', False,
> +      _('do not refer to original source for subsequent graft')),
>       ('U', 'currentuser', False,
>        _('record the current user as committer'), _('DATE'))]
>      + commitopts2 + mergetoolopts  + dryrunopts,
> @@ -3181,7 +3183,9 @@
>              if opts.get('dry_run'):
>                  continue
>
> -            source = ctx.extra().get('source')
> +            source = None
> +            if not opts.get('currentsource'):
> +                source = ctx.extra().get('source')
>              if not source:
>                  source = ctx.hex()
>              extra = {'source': source}
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Alexander Drozdov - April 13, 2014, 1:19 p.m.
On 13.04.2014 17:13:38, Augie Fackler <raf@durin42.com> wrote:
> On Tue, Apr 01, 2014 at 07:24:38AM +0400, Alexander Drozdov wrote:
>> # HG changeset patch
>> # User Alexander Drozdov <al.drozdov@gmail.com>
>> # Date 1393909791 -14400
>> #      Tue Mar 04 09:09:51 2014 +0400
>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>> graft: allow to not preserve original source in subsequent grafts
> Feature seems mostly reasonable to me, but the flag name is completely
> baffling. Maybe it could be something like
>
> --no-record-source?
>
> Other people will probably have better naming proposals than I will.
Maybe --no-follow-source ? The patch don't disable source recording.

>
>>  From dc9fb7015d7f, graft preserves original source when grafting
>> changeset that was grafted from another branch.
>>
>> That may be undesirable in some situations. For example, the first
>> graft may be from user's private branch, so the source changeset may
>> not be present in a public repository.
>>
>> This changeset adds -S (--currentsource) option to always refer to
>> grafted changeset as a source revision.
>>
>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>> --- a/mercurial/commands.py
>> +++ b/mercurial/commands.py
>> @@ -3036,6 +3036,8 @@
>>        ('', 'log', None, _('append graft info to log message')),
>>        ('D', 'currentdate', False,
>>         _('record the current date as commit date')),
>> +     ('S', 'currentsource', False,
>> +      _('do not refer to original source for subsequent graft')),
>>        ('U', 'currentuser', False,
>>         _('record the current user as committer'), _('DATE'))]
>>       + commitopts2 + mergetoolopts  + dryrunopts,
>> @@ -3181,7 +3183,9 @@
>>               if opts.get('dry_run'):
>>                   continue
>>
>> -            source = ctx.extra().get('source')
>> +            source = None
>> +            if not opts.get('currentsource'):
>> +                source = ctx.extra().get('source')
>>               if not source:
>>                   source = ctx.hex()
>>               extra = {'source': source}
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - April 15, 2014, 12:44 a.m.
On Apr 13, 2014, at 9:19 AM, Alexander Drozdov <al.drozdov@gmail.com> wrote:

> On 13.04.2014 17:13:38, Augie Fackler <raf@durin42.com> wrote:
>> On Tue, Apr 01, 2014 at 07:24:38AM +0400, Alexander Drozdov wrote:
>>> # HG changeset patch
>>> # User Alexander Drozdov <al.drozdov@gmail.com>
>>> # Date 1393909791 -14400
>>> #      Tue Mar 04 09:09:51 2014 +0400
>>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>>> graft: allow to not preserve original source in subsequent grafts
>> Feature seems mostly reasonable to me, but the flag name is completely
>> baffling. Maybe it could be something like
>> 
>> --no-record-source?
>> 
>> Other people will probably have better naming proposals than I will.
> Maybe --no-follow-source ? The patch don't disable source recording.

Heh, I'm going to take that as a sign that this behavior was under-described. So what this does then, is record the revision specified on the command line and records that as the graft source, rather than any of the earlier graft_source entries that might be present?
Siddharth Agarwal - April 15, 2014, 12:46 a.m.
On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
> # HG changeset patch
> # User Alexander Drozdov <al.drozdov@gmail.com>
> # Date 1393909791 -14400
> #      Tue Mar 04 09:09:51 2014 +0400
> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
> graft: allow to not preserve original source in subsequent grafts
>
>  From dc9fb7015d7f, graft preserves original source when grafting
> changeset that was grafted from another branch.
>
> That may be undesirable in some situations. For example, the first
> graft may be from user's private branch, so the source changeset may
> not be present in a public repository.

Why is this an actual issue?
Siddharth Agarwal - April 15, 2014, 12:51 a.m.
On 04/14/2014 05:46 PM, Siddharth Agarwal wrote:
> On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
>> # HG changeset patch
>> # User Alexander Drozdov <al.drozdov@gmail.com>
>> # Date 1393909791 -14400
>> #      Tue Mar 04 09:09:51 2014 +0400
>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>> graft: allow to not preserve original source in subsequent grafts
>>
>>  From dc9fb7015d7f, graft preserves original source when grafting
>> changeset that was grafted from another branch.
>>
>> That may be undesirable in some situations. For example, the first
>> graft may be from user's private branch, so the source changeset may
>> not be present in a public repository.
>
> Why is this an actual issue?

Ah, I misread the patch. This isn't coming from some sort of privacy 
perspective.

Honestly, I'm not really a fan of adding command-line options 
willy-nilly, Git style. How about: check whether the source exists in 
the repository (and if it is public, perhaps?), and use it if it does, 
or drop it if it doesn't.
Alexander Drozdov - April 15, 2014, 5:17 a.m.
15.04.2014 04:44, Augie Fackler wrote:
> On Apr 13, 2014, at 9:19 AM, Alexander Drozdov <al.drozdov@gmail.com> wrote:
>
>> On 13.04.2014 17:13:38, Augie Fackler <raf@durin42.com> wrote:
>>> On Tue, Apr 01, 2014 at 07:24:38AM +0400, Alexander Drozdov wrote:
>>>> # HG changeset patch
>>>> # User Alexander Drozdov <al.drozdov@gmail.com>
>>>> # Date 1393909791 -14400
>>>> #      Tue Mar 04 09:09:51 2014 +0400
>>>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>>>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>>>> graft: allow to not preserve original source in subsequent grafts
>>> Feature seems mostly reasonable to me, but the flag name is completely
>>> baffling. Maybe it could be something like
>>>
>>> --no-record-source?
>>>
>>> Other people will probably have better naming proposals than I will.
>> Maybe --no-follow-source ? The patch don't disable source recording.
> Heh, I'm going to take that as a sign that this behavior was under-described. So what this does then, is record the revision specified on the command line and records that as the graft source, rather than any of the earlier graft_source entries that might be present?
Yes. But note that graft records exactly one 'source' extra, so a changeset may not have multiple graft source references now.

Also, note that what I want to get from graft command is what transplant command does.
Transplant always write command-line revision as transplant_source.
Alexander Drozdov - April 15, 2014, 5:56 a.m.
15.04.2014 04:51, Siddharth Agarwal wrote:
> On 04/14/2014 05:46 PM, Siddharth Agarwal wrote:
>> On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
>>> # HG changeset patch
>>> # User Alexander Drozdov <al.drozdov@gmail.com>
>>> # Date 1393909791 -14400
>>> #      Tue Mar 04 09:09:51 2014 +0400
>>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>>> graft: allow to not preserve original source in subsequent grafts
>>>
>>>  From dc9fb7015d7f, graft preserves original source when grafting
>>> changeset that was grafted from another branch.
>>>
>>> That may be undesirable in some situations. For example, the first
>>> graft may be from user's private branch, so the source changeset may
>>> not be present in a public repository.
>>
>> Why is this an actual issue?
>
> Ah, I misread the patch. This isn't coming from some sort of privacy perspective.
>
> Honestly, I'm not really a fan of adding command-line options willy-nilly, Git style. How about: check whether the source exists in the repository (and if it is public, perhaps?), and use it if it does, or drop it if it doesn't.
In project I'm working on, we have multiple public repositories: one is 'official', others is for temporary/experimental features. From my local repository I can push or pull to or from any of the repositories. So, the source is always present in my local repository and is often public.

BTW, I don't understand why it was needed to make dc9fb7015d7f change at all. Without the change, it was possible to check 'graft history'
by just walking through 'source' chain. In my project, there are many long-lived 'supported' branches, and graft often lead to merge conflicts.
So the earliest source changeset is often differs from graft ones, and may be changed up to two or three times times while grafting. I would like to see the most recent source in the changeset.

Maybe just add an option to hgrc? Actualy, I want this option to be always enabled for me.
Sean Farley - April 15, 2014, 3:33 p.m.
Alexander Drozdov <al.drozdov@gmail.com> writes:

> 15.04.2014 04:51, Siddharth Agarwal wrote:
>> On 04/14/2014 05:46 PM, Siddharth Agarwal wrote:
>>> On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
>>>> # HG changeset patch
>>>> # User Alexander Drozdov <al.drozdov@gmail.com>
>>>> # Date 1393909791 -14400
>>>> #      Tue Mar 04 09:09:51 2014 +0400
>>>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>>>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>>>> graft: allow to not preserve original source in subsequent grafts
>>>>
>>>>  From dc9fb7015d7f, graft preserves original source when grafting
>>>> changeset that was grafted from another branch.
>>>>
>>>> That may be undesirable in some situations. For example, the first
>>>> graft may be from user's private branch, so the source changeset may
>>>> not be present in a public repository.
>>>
>>> Why is this an actual issue?
>>
>> Ah, I misread the patch. This isn't coming from some sort of privacy perspective.
>>
>> Honestly, I'm not really a fan of adding command-line options willy-nilly, Git style. How about: check whether the source exists in the repository (and if it is public, perhaps?), and use it if it does, or drop it if it doesn't.
> In project I'm working on, we have multiple public repositories: one is 'official', others is for temporary/experimental features. From my local repository I can push or pull to or from any of the repositories. So, the source is always present in my local repository and is often public.
>
> BTW, I don't understand why it was needed to make dc9fb7015d7f change at all. Without the change, it was possible to check 'graft history'
> by just walking through 'source' chain. In my project, there are many long-lived 'supported' branches, and graft often lead to merge conflicts.
> So the earliest source changeset is often differs from graft ones, and may be changed up to two or three times times while grafting. I would like to see the most recent source in the changeset.
>
> Maybe just add an option to hgrc? Actualy, I want this option to be always enabled for me.

This sounds more along the lines of using Changeset Evolution but
perhaps I'm off base. Pierre-Yves could comment more on that.
Pierre-Yves David - April 15, 2014, 3:34 p.m.
On 04/15/2014 11:33 AM, Sean Farley wrote:
>
> Alexander Drozdov <al.drozdov@gmail.com> writes:
>
>> 15.04.2014 04:51, Siddharth Agarwal wrote:
>>> On 04/14/2014 05:46 PM, Siddharth Agarwal wrote:
>>>> On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
>>>>> # HG changeset patch
>>>>> # User Alexander Drozdov <al.drozdov@gmail.com>
>>>>> # Date 1393909791 -14400
>>>>> #      Tue Mar 04 09:09:51 2014 +0400
>>>>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>>>>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>>>>> graft: allow to not preserve original source in subsequent grafts
>>>>>
>>>>>   From dc9fb7015d7f, graft preserves original source when grafting
>>>>> changeset that was grafted from another branch.
>>>>>
>>>>> That may be undesirable in some situations. For example, the first
>>>>> graft may be from user's private branch, so the source changeset may
>>>>> not be present in a public repository.
>>>>
>>>> Why is this an actual issue?
>>>
>>> Ah, I misread the patch. This isn't coming from some sort of privacy perspective.
>>>
>>> Honestly, I'm not really a fan of adding command-line options willy-nilly, Git style. How about: check whether the source exists in the repository (and if it is public, perhaps?), and use it if it does, or drop it if it doesn't.
>> In project I'm working on, we have multiple public repositories: one is 'official', others is for temporary/experimental features. From my local repository I can push or pull to or from any of the repositories. So, the source is always present in my local repository and is often public.
>>
>> BTW, I don't understand why it was needed to make dc9fb7015d7f change at all. Without the change, it was possible to check 'graft history'
>> by just walking through 'source' chain. In my project, there are many long-lived 'supported' branches, and graft often lead to merge conflicts.
>> So the earliest source changeset is often differs from graft ones, and may be changed up to two or three times times while grafting. I would like to see the most recent source in the changeset.
>>
>> Maybe just add an option to hgrc? Actualy, I want this option to be always enabled for me.
>
> This sounds more along the lines of using Changeset Evolution but
> perhaps I'm off base. Pierre-Yves could comment more on that.

Seeing this discussion from afar it appear that the experimental repo 
should be non-publishing and the changeset should be amended/rebased 
around instead.
Matt Mackall - April 15, 2014, 4 p.m.
On Tue, 2014-04-15 at 09:56 +0400, Alexander Drozdov wrote:
> 15.04.2014 04:51, Siddharth Agarwal wrote:
> > On 04/14/2014 05:46 PM, Siddharth Agarwal wrote:
> >> On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
> >>> # HG changeset patch
> >>> # User Alexander Drozdov <al.drozdov@gmail.com>
> >>> # Date 1393909791 -14400
> >>> #      Tue Mar 04 09:09:51 2014 +0400
> >>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
> >>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
> >>> graft: allow to not preserve original source in subsequent grafts
> >>>
> >>>  From dc9fb7015d7f, graft preserves original source when grafting
> >>> changeset that was grafted from another branch.
> >>>
> >>> That may be undesirable in some situations. For example, the first
> >>> graft may be from user's private branch, so the source changeset may
> >>> not be present in a public repository.
> >>
> >> Why is this an actual issue?
> >
> > Ah, I misread the patch. This isn't coming from some sort of privacy perspective.
> >
> > Honestly, I'm not really a fan of adding command-line options willy-nilly, Git style. How about: check whether the source exists in the repository (and if it is public, perhaps?), and use it if it does, or drop it if it doesn't.
> In project I'm working on, we have multiple public repositories: one is 'official', others is for temporary/experimental features. From my local repository I can push or pull to or from any of the repositories. So, the source is always present in my local repository and is often public.
> 
> BTW, I don't understand why it was needed to make dc9fb7015d7f change at all. Without the change, it was possible to check 'graft history'
> by just walking through 'source' chain. In my project, there are many long-lived 'supported' branches, and graft often lead to merge conflicts.
> So the earliest source changeset is often differs from graft ones, and may be changed up to two or three times times while grafting. I would like to see the most recent source in the changeset.
> 
> Maybe just add an option to hgrc? Actualy, I want this option to be always enabled for me.

Here is the original discussion of this feature:

http://mercurial.markmail.org/thread/alax3vpc55n4e5te

Right now this behavior is tied up with the origin and destination
revsets, so this discussion primarily needs to be about how those are
affected. I'd prefer not to have an option here and instead focus on
whether the current behavior is sensible and whether anything can be
done to fix it.
Alexander Drozdov - April 17, 2014, 4:28 a.m.
15.04.2014 20:00, Matt Mackall wrote:
> On Tue, 2014-04-15 at 09:56 +0400, Alexander Drozdov wrote:
>> 15.04.2014 04:51, Siddharth Agarwal wrote:
>>> On 04/14/2014 05:46 PM, Siddharth Agarwal wrote:
>>>> On 03/31/2014 08:24 PM, Alexander Drozdov wrote:
>>>>> # HG changeset patch
>>>>> # User Alexander Drozdov <al.drozdov@gmail.com>
>>>>> # Date 1393909791 -14400
>>>>> #      Tue Mar 04 09:09:51 2014 +0400
>>>>> # Node ID e7b0eaf7bbbd35d5cc0b1415014749d4b8e533d0
>>>>> # Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
>>>>> graft: allow to not preserve original source in subsequent grafts
>>>>>
>>>>>   From dc9fb7015d7f, graft preserves original source when grafting
>>>>> changeset that was grafted from another branch.
>>>>>
>>>>> That may be undesirable in some situations. For example, the first
>>>>> graft may be from user's private branch, so the source changeset may
>>>>> not be present in a public repository.
>>>> Why is this an actual issue?
>>> Ah, I misread the patch. This isn't coming from some sort of privacy perspective.
>>>
>>> Honestly, I'm not really a fan of adding command-line options willy-nilly, Git style. How about: check whether the source exists in the repository (and if it is public, perhaps?), and use it if it does, or drop it if it doesn't.
>> In project I'm working on, we have multiple public repositories: one is 'official', others is for temporary/experimental features. From my local repository I can push or pull to or from any of the repositories. So, the source is always present in my local repository and is often public.
>>
>> BTW, I don't understand why it was needed to make dc9fb7015d7f change at all. Without the change, it was possible to check 'graft history'
>> by just walking through 'source' chain. In my project, there are many long-lived 'supported' branches, and graft often lead to merge conflicts.
>> So the earliest source changeset is often differs from graft ones, and may be changed up to two or three times times while grafting. I would like to see the most recent source in the changeset.
>>
>> Maybe just add an option to hgrc? Actualy, I want this option to be always enabled for me.
> Here is the original discussion of this feature:
>
> http://mercurial.markmail.org/thread/alax3vpc55n4e5te
>
> Right now this behavior is tied up with the origin and destination
> revsets, so this discussion primarily needs to be about how those are
> affected. I'd prefer not to have an option here and instead focus on
> whether the current behavior is sensible and whether anything can be
> done to fix it.
origin revset now works fine for transplanted and grafted changesets.
destination revset works for transplanted changesets but doesn't work for grafted changesets:
the behavior is documented in tests/test-graft.t (see "grafts of grafts unfortunately can't").
But it is still possible to see all the copies of the changeset: 'origin(cset) or destination(origin(cset))'
To make destination revset to work with grafted changesets, I think dc9fb7015d7f code should be
backed out and some tests should be fixed.

BTW, destination(anyrev) is rather slow (~2 sec on my not so old machine, on mercurial repository).

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3036,6 +3036,8 @@ 
      ('', 'log', None, _('append graft info to log message')),
      ('D', 'currentdate', False,
       _('record the current date as commit date')),
+     ('S', 'currentsource', False,
+      _('do not refer to original source for subsequent graft')),
      ('U', 'currentuser', False,
       _('record the current user as committer'), _('DATE'))]
     + commitopts2 + mergetoolopts  + dryrunopts,
@@ -3181,7 +3183,9 @@ 
             if opts.get('dry_run'):
                 continue
 
-            source = ctx.extra().get('source')
+            source = None
+            if not opts.get('currentsource'):
+                source = ctx.extra().get('source')
             if not source:
                 source = ctx.hex()
             extra = {'source': source}