[PATCH] Add a --reverse option to patch

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue Aug 28 23:09:54 UTC 2007


Thus spake Brendan Cully:
> > 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.
> 
> I've avoided using ctx1.manifest() in this patch, but it turned out to
> be messier than I was expecting for renames and for diffs of working
> directory merges. Ideas would be welcome.

I don't have any suggestions for the diff during merges issue, but for
the rename thing it might be easier to just do the "man1 = ctx1.manifest()"
in the opts.git case.

We would have a performance penalty with "hg diff --git --reverse", but:

- it wouldn't affect other cases much more common cases

- our copy detection won't work in this case anyway (we should try to
  use the code from merge.py...), so I'm guessing it won't get used much
  (then again I don't really know why you want diff --reverse...)

- I've just noticed that we're already doing an extra walk for hg diff
  --git (because of the c.files() in renamed - shouldn't be hard to
  fix), so it shouldn't be slower than what we have now.

Some test would be good, too - I'm seeing a "hg diff --git --reverse"
enter an infinite loop if I have added files (probably because of
ctx1.rev() returning None in the beginning of renamed()).

Alexis



More information about the Mercurial-devel mailing list