Submitter | Drew Gottlieb |
---|---|
Date | May 15, 2015, 10:44 p.m. |
Message ID | <fd530304121bd3c2fcbb.1431729846@waste.org> |
Download | mbox | patch |
Permalink | /patch/9105/ |
State | Accepted |
Commit | d1d69ca78883d05c6bb520c601e631123f002684 |
Headers | show |
Comments
On Fri, May 15, 2015 at 3:44 PM Drew Gottlieb <drgott@google.com> wrote: > # HG changeset patch > # User Drew Gottlieb <drgott@google.com> > # Date 1431729806 25200 > # Fri May 15 15:43:26 2015 -0700 > # Node ID fd530304121bd3c2fcbb23f5ec2052b47e24e0a7 > # Parent 2f34746c27dfd9d4ff51c1f0081526438ded0c04 > match: add match.ispartial() > > match.ispartial() will return the opposite of match.always() in core, but > this > function will be extensible by extensions to produce another result even > if match.always() will be untouched. > > This will be useful for narrowhg, where ispartial() will return False even > if > the match won't always match. This would happen in the case where the only > time the match function is False is when the path is outside of the narrow > spec. > > diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py > --- a/mercurial/localrepo.py > +++ b/mercurial/localrepo.py > @@ -1377,7 +1377,7 @@ > wctx = self[None] > merge = len(wctx.parents()) > 1 > > - if not force and merge and not match.always(): > + if not force and merge and match.ispartial(): > To take one step back, why does the narrow extension need to pass in a non-always matcher? I looked briefly at localrepo.commit() and it wasn't clear to me for which uses of the matcher you need to use a modified matcher (presumably one that matches the narrow clone). raise util.Abort(_('cannot partially commit a merge ' > '(do not specify files or patterns)')) > > diff --git a/mercurial/match.py b/mercurial/match.py > --- a/mercurial/match.py > +++ b/mercurial/match.py > @@ -186,6 +186,14 @@ > - optimization might be possible and necessary.''' > return self._always > > + def ispartial(self): > + '''True if the matcher won't always match. > + > + Although it's just the inverse of _always in this implementation, > + an extenion such as narrowhg might make it return something > + slightly different.''' > + return not self._always > + > def isexact(self): > return self.matchfn == self.exact > > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel >
Abort this patch for now. Martin gave me an idea. On Fri, May 15, 2015 at 3:58 PM Martin von Zweigbergk <martinvonz@google.com> wrote: > On Fri, May 15, 2015 at 3:44 PM Drew Gottlieb <drgott@google.com> wrote: > >> # HG changeset patch >> # User Drew Gottlieb <drgott@google.com> >> # Date 1431729806 25200 >> # Fri May 15 15:43:26 2015 -0700 >> # Node ID fd530304121bd3c2fcbb23f5ec2052b47e24e0a7 >> # Parent 2f34746c27dfd9d4ff51c1f0081526438ded0c04 >> match: add match.ispartial() >> >> match.ispartial() will return the opposite of match.always() in core, but >> this >> function will be extensible by extensions to produce another result even >> if match.always() will be untouched. >> >> This will be useful for narrowhg, where ispartial() will return False >> even if >> the match won't always match. This would happen in the case where the only >> time the match function is False is when the path is outside of the narrow >> spec. >> >> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py >> --- a/mercurial/localrepo.py >> +++ b/mercurial/localrepo.py >> @@ -1377,7 +1377,7 @@ >> wctx = self[None] >> merge = len(wctx.parents()) > 1 >> >> - if not force and merge and not match.always(): >> + if not force and merge and match.ispartial(): >> > > To take one step back, why does the narrow extension need to pass in a > non-always matcher? I looked briefly at localrepo.commit() and it wasn't > clear to me for which uses of the matcher you need to use a modified > matcher (presumably one that matches the narrow clone). > > raise util.Abort(_('cannot partially commit a merge ' >> '(do not specify files or patterns)')) >> >> diff --git a/mercurial/match.py b/mercurial/match.py >> --- a/mercurial/match.py >> +++ b/mercurial/match.py >> @@ -186,6 +186,14 @@ >> - optimization might be possible and necessary.''' >> return self._always >> >> + def ispartial(self): >> + '''True if the matcher won't always match. >> + >> + Although it's just the inverse of _always in this implementation, >> + an extenion such as narrowhg might make it return something >> + slightly different.''' >> + return not self._always >> + >> def isexact(self): >> return self.matchfn == self.exact >> >> _______________________________________________ >> Mercurial-devel mailing list >> Mercurial-devel@selenic.com >> http://selenic.com/mailman/listinfo/mercurial-devel >> >
Patch
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1377,7 +1377,7 @@ wctx = self[None] merge = len(wctx.parents()) > 1 - if not force and merge and not match.always(): + if not force and merge and match.ispartial(): raise util.Abort(_('cannot partially commit a merge ' '(do not specify files or patterns)')) diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -186,6 +186,14 @@ - optimization might be possible and necessary.''' return self._always + def ispartial(self): + '''True if the matcher won't always match. + + Although it's just the inverse of _always in this implementation, + an extenion such as narrowhg might make it return something + slightly different.''' + return not self._always + def isexact(self): return self.matchfn == self.exact