Supporting relative paths for hg diff and patch

Kevin Bullock kbullock at
Sat Mar 7 12:58:08 CST 2015

> On Mar 3, 2015, at 10:12 AM, Augie Fackler <raf at> wrote:
> On Mon, Mar 02, 2015 at 11:29:29PM -0800, Siddharth Agarwal wrote:
>> As we're merging repos, something that would be incredibly useful for
>> both automated tools and humans at Facebook would be the ability to
>> produce and apply patches relative to a subdirectory.
>> So (tentative UI):
>> hg diff --relative prefix/
>> would produce diffs only from files within prefix/, where all the paths
>> are relative to prefix/. (Moves into and out of prefix/ would be
>> presented as adds and deletes respectively.)
>> Similarly,
>> hg import --relative prefix/
>> would apply a patch assuming paths in it are relative to prefix.
>> While we could do this at a higher level by munging paths in the patch
>> data, it's really much easier to do within Mercurial. (Moves make things
>> particularly tricky.)
>> Does that sound like a reasonable feature request? I'd be happy to
>> implement it.
> Looks reasonable to me.

Agreed, I say go for it.

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock

More information about the Mercurial-devel mailing list