[PATCH 5 of 5 relative-diff] patch.diff: add support for diffs relative to a subdirectory

Martin von Zweigbergk martinvonz at google.com
Wed Mar 18 08:29:26 CDT 2015


On Tue, Mar 17, 2015 at 9:10 PM Siddharth Agarwal <sid at less-broken.com>
wrote:

> On 03/17/2015 08:46 PM, Martin von Zweigbergk wrote:
> >
> >     +    if relroot is not None:
> >     +        # XXX this would ideally be done in the matcher rather
> >     than here
> >
> >
> > So why isn't it?
>
> A patch I haven't sent out yet has more details, but supporting this in
> the matcher in general is non-trivial. The matcher is generally designed
> to support 'or'ing patterns, not 'and'ing them.
>

Yep, I'll try to clean up some old patches that add support for that. They
only mutate an existing matcher. Is that good enough for your needs?

The first three patches look good to me. Can we wait with the rest until I
get those patches cleaned up? I think I should be able to do that today.


>
> In a later patch I'll add an optimization for the match.always() case,
> creating a new matcher where the only pattern is the relative root.
>

Actually, wouldn't that work with any pattern that doesn't already have an
"include"? I.e., can you just set "include=['$relroot']" if no includes
were passed on the command line?


>
> > I guess I'm missing an explanation for when relroot would be used in
> > the first place.
>
> relroot will be used to produce patches relative to a directory. e.g.
>
> hg diff --relative mercurial
>
> will produce a diff where the filenames are e.g. a/patch.py and b/patch.py.
>

And if there are paths outside "mercurial/", they are ignored? I found that
a little surprising. I see that git made the same decision. I would
probably have expected it to fail. What do people want this feature for?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150318/5fbe3c3b/attachment.html>


More information about the Mercurial-devel mailing list