[PATCH] Add a --reverse option to patch

Brendan Cully brendan at kublai.com
Tue Aug 28 13:21:15 CDT 2007


On Tuesday, 28 August 2007 at 15:07, Alexis S. L. Carvalho wrote:
> 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.

that's right. I think man1 is just used to see if the file exists in
node1 during diff generation, and we can probably replace 'if f in
man1' with 'if f in modified or removed', since we aren't interested
in files in node1 that aren't generating diffs.

> 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.

Hmm, that might be prettier.


More information about the Mercurial-devel mailing list