[Python-Dev] hg diff

Adrian Buehlmann adrian at cadifra.com
Tue Mar 8 10:53:13 CET 2011

On 2011-03-08 09:38, "Martin v. Löwis" wrote:
>> However, as Michael points out, you can have your tools generate the
>> patch.  For example, it shouldn't be too hard to add a dynamic patch
>> generator to Roundup (although I haven't thought about the UI or the
>> CPU burden).
> For Mercurial, that's more difficult than you might expect. There is "hg 
> incoming -p", but it has the nasty problem that it may produce
> multiple patches for a single file.

I didn't follow/understand closely/completely what your problems is, but
I wouldn't be surprised if mercurial's 'incoming' command has its
limitations (it's most likely intentional, since remote inspection is
limited on purpose and frowned upon by design).

In general, you have to have all the changesets in a local repo to enjoy
the full power of mercurial's history inspection tools.

Maybe the following trick could be interesting for you:

If you don't want to do an outright pull from a (possibly dubious)
remote repo into your precious local repo yet, you can instead
"superimpose" a separate overlay bundle file on your local repo.

Example (initial step):

  $ cd cpython
  $ hg -q incoming --bundle in.hg

Now, you have a mercurial bundle file named "in.hg" which contains all
these incoming changes, but -- of course -- the changes haven't yet been
added to the repo.

The interesting thing is, you can now superimpose this bundle on your
repo, which has the effect that the aggregate is treated as if the
changes had already been pulled.

Continuing my example, let's now specify the bundle "in.hg" as an
*overlay* by using the option -R/--repository [1]:

  $ hg -R in.hg log -r tip
  changeset:   68327:770d45d22a40
  branch:      2.7
  tag:         tip
  parent:      68321:d9cc58f93d72
  user:        Benjamin Peterson <...>
  date:        Mon Mar 07 22:50:37 2011 -0600
  summary:     transform izip_longest #11424

The fun thing with overlay bundles is: you have the full power of all
mercurial history inspection commands as if the changesets had already
been added to your repo.

As an added extra bonus, you can later unbundle the bundle into your
repo without another network round trip -- assuming you are pleased with
what you've seen coming in:

  $ hg unbundle in.hg
  adding changesets
  adding manifests
  adding file changes
  added 6 changesets with 6 changes to 3 files
  (run 'hg update' to get a working copy)

BTW, we regularly use overlay bundles under the hood of TortoiseHg.

'hg help -v' says:
global options:
 -R --repository REPO    repository root directory or name of overlay
                         bundle file

More information about the Python-Dev mailing list