[PATCH] Add a --reverse option to patch

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue Aug 28 13:07:01 CDT 2007


I don't have a strong opinion about the feature (well, --reverse is a
bit unfriendly towards TAB-completion, but that's smaller than minor),
but two comments:

Thus spake Brendan Cully:
> +    if reverse:
> +        node1, ctx1, node2, ctx2 = node2, ctx2, node1, ctx1
> +        execf1, linkf1, execf2, linkf2 = execf2, linkf2, execf1, linkf1
> +        added, removed = removed, added
> +        man1 = ctx1.manifest()
> +        

If I'm reading the code correctly, the call to ctx1.manifest() here will
force another walk of the working dir, making a hg diff --reverse quite
a bit slower than a regular hg diff.

API-wise it might be better to just have the caller reverse node1 and
node2 and interpret "node1 is None and node2 is not None" as "compare
working dir with node2"[1].  But that would probably require some deeper
changes in localrepo.status and would also have the double walk problem
I mentioned above.

Alexis

[1] - right now we end up comparing the first parent of the working dir
with node2, but I'm not sure that's actually used anywhere.  At least it
doesn't sound like a particularly useful shortcut.


More information about the Mercurial-devel mailing list