Patchwork [6,of,6,mergedriver] localrepo.commit: disallow commit when driver-resolved files exist

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 14, 2015, 11:52 p.m.
Message ID <3328de735f306b8057e0.1444866754@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11085/
State Accepted
Commit e1568d5eb0522b3ab20a1cbb15ec06f6d198c9a8
Delegated to: Pierre-Yves David
Headers show

Comments

Siddharth Agarwal - Oct. 14, 2015, 11:52 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1444863883 25200
#      Wed Oct 14 16:04:43 2015 -0700
# Node ID 3328de735f306b8057e0b9ede6b518959cd7dfdc
# Parent  9f41136f7fa1528e16445da843b63945fbe27857
localrepo.commit: disallow commit when driver-resolved files exist

This code will not currently be activated because there's no code to mark
files as driver-resolved in core. This point is also somewhat hard to plug into
from extensions.
Siddharth Agarwal - Oct. 15, 2015, 8:44 a.m.
On 10/14/15 16:52, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1444863883 25200
> #      Wed Oct 14 16:04:43 2015 -0700
> # Node ID 3328de735f306b8057e0b9ede6b518959cd7dfdc
> # Parent  9f41136f7fa1528e16445da843b63945fbe27857
> localrepo.commit: disallow commit when driver-resolved files exist

A slightly fixed version of these patches + a followup set of 14 more 
are available via

hg pull http://42.netv6.net/sid0-wip/hg/ -r 0d4a0d43fcc2

None of these patches change any user-visible behavior -- they're all 
hidden behind experimental config options and flags.

There's also a part of the overall feature that I'm not targeting for 
this release -- the actual implementation of the merge driver itself. 
The idea is to leave stubs in and then implement the merge driver 
functionality as a separate extension for now.

If you're curious, an initial version of the extension lives at 
https://bitbucket.org/facebook/hg-experimental/src/7baef54cd36da00fa17bf9e1346f9105015cfda0/mergedriver.py?at=default

- Siddharth

>
> This code will not currently be activated because there's no code to mark
> files as driver-resolved in core. This point is also somewhat hard to plug into
> from extensions.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1553,11 +1553,21 @@ class localrepository(object):
>               if merge and cctx.deleted():
>                   raise error.Abort(_("cannot commit merge with missing files"))
>   
> +            unresolved, driverresolved = False, False
>               ms = mergemod.mergestate(self)
>               for f in status.modified:
> -                if f in ms and ms[f] == 'u':
> -                    raise error.Abort(_('unresolved merge conflicts '
> -                                       '(see "hg help resolve")'))
> +                if f in ms:
> +                    if ms[f] == 'u':
> +                        unresolved = True
> +                    elif ms[f] == 'd':
> +                        driverresolved = True
> +
> +            if unresolved:
> +                raise error.Abort(_('unresolved merge conflicts '
> +                                    '(see "hg help resolve")'))
> +            if driverresolved:
> +                raise error.Abort(_('driver-resolved merge conflicts'),
> +                                  hint=_('(run "hg resolve --all" to resolve)'))
>   
>               if editor:
>                   cctx._text = editor(self, cctx, subs)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - Oct. 16, 2015, 9:56 p.m.
On Thu, 2015-10-15 at 01:44 -0700, Siddharth Agarwal wrote:
> On 10/14/15 16:52, Siddharth Agarwal wrote:
> > # HG changeset patch
> > # User Siddharth Agarwal <sid0@fb.com>
> > # Date 1444863883 25200
> > #      Wed Oct 14 16:04:43 2015 -0700
> > # Node ID 3328de735f306b8057e0b9ede6b518959cd7dfdc
> > # Parent  9f41136f7fa1528e16445da843b63945fbe27857
> > localrepo.commit: disallow commit when driver-resolved files exist
> 
> A slightly fixed version of these patches + a followup set of 14 more 
> are available via
> 
> hg pull http://42.netv6.net/sid0-wip/hg/ -r 0d4a0d43fcc2

I'd generally prefer a resend. Also, this is what the # url syntax is
for.

I've queued the new version of these six, thanks.
Pierre-Yves David - Oct. 16, 2015, 9:58 p.m.
On 10/16/2015 10:56 PM, Matt Mackall wrote:
> On Thu, 2015-10-15 at 01:44 -0700, Siddharth Agarwal wrote:
>> On 10/14/15 16:52, Siddharth Agarwal wrote:
>>> # HG changeset patch
>>> # User Siddharth Agarwal <sid0@fb.com>
>>> # Date 1444863883 25200
>>> #      Wed Oct 14 16:04:43 2015 -0700
>>> # Node ID 3328de735f306b8057e0b9ede6b518959cd7dfdc
>>> # Parent  9f41136f7fa1528e16445da843b63945fbe27857
>>> localrepo.commit: disallow commit when driver-resolved files exist
>>
>> A slightly fixed version of these patches + a followup set of 14 more
>> are available via
>>
>> hg pull http://42.netv6.net/sid0-wip/hg/ -r 0d4a0d43fcc2
>
> I'd generally prefer a resend. Also, this is what the # url syntax is
> for.

I remember glorious day where I provided you a http://blah.org/wip/#hash 
url that resulted into giving your terminal:

   hg pull http://blah.org/wip/#hash

The # being used for comment, you pulled every single ofr my wip 
changesets and crappy bookmark and spend the next hour cleaning things 
up. That day I decided to never usr the # url syntax again.
Matt Mackall - Oct. 16, 2015, 10:13 p.m.
On Fri, 2015-10-16 at 22:58 +0100, Pierre-Yves David wrote:
> 
> On 10/16/2015 10:56 PM, Matt Mackall wrote:
> > On Thu, 2015-10-15 at 01:44 -0700, Siddharth Agarwal wrote:
> >> On 10/14/15 16:52, Siddharth Agarwal wrote:
> >>> # HG changeset patch
> >>> # User Siddharth Agarwal <sid0@fb.com>
> >>> # Date 1444863883 25200
> >>> #      Wed Oct 14 16:04:43 2015 -0700
> >>> # Node ID 3328de735f306b8057e0b9ede6b518959cd7dfdc
> >>> # Parent  9f41136f7fa1528e16445da843b63945fbe27857
> >>> localrepo.commit: disallow commit when driver-resolved files exist
> >>
> >> A slightly fixed version of these patches + a followup set of 14 more
> >> are available via
> >>
> >> hg pull http://42.netv6.net/sid0-wip/hg/ -r 0d4a0d43fcc2
> >
> > I'd generally prefer a resend. Also, this is what the # url syntax is
> > for.
> 
> I remember glorious day where I provided you a http://blah.org/wip/#hash 
> url that resulted into giving your terminal:
> 
>    hg pull http://blah.org/wip/#hash
> 
> The # being used for comment, you pulled every single ofr my wip 
> changesets and crappy bookmark and spend the next hour cleaning things 
> up. That day I decided to never usr the # url syntax again.

I vaguely remember that. Fair enough.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1553,11 +1553,21 @@  class localrepository(object):
             if merge and cctx.deleted():
                 raise error.Abort(_("cannot commit merge with missing files"))
 
+            unresolved, driverresolved = False, False
             ms = mergemod.mergestate(self)
             for f in status.modified:
-                if f in ms and ms[f] == 'u':
-                    raise error.Abort(_('unresolved merge conflicts '
-                                       '(see "hg help resolve")'))
+                if f in ms:
+                    if ms[f] == 'u':
+                        unresolved = True
+                    elif ms[f] == 'd':
+                        driverresolved = True
+
+            if unresolved:
+                raise error.Abort(_('unresolved merge conflicts '
+                                    '(see "hg help resolve")'))
+            if driverresolved:
+                raise error.Abort(_('driver-resolved merge conflicts'),
+                                  hint=_('(run "hg resolve --all" to resolve)'))
 
             if editor:
                 cctx._text = editor(self, cctx, subs)