annotate contrib/python-hook-examples.py @ 26593:c60dfcc0abf2

cvsps: fix computation of parent revisions when log caching is on cvsps computes the parent revisions of log entries by walking the cvs log sorted by (rcs, revision) and by iteratively maintaining a 'versions' dictionary which maps a (rcs, branch) pair onto the last revision seen for that pair. When log caching is on and a log cache exists, cvsps fails to set the parent revisions of new log entries because it does not iterate over the log cache in the parents computation. A complication is that a file rcs can change (move to/from the attic), with respect to its value in the log cache, if the file is removed/added back. This patch adds an iteration over the log cache to update the rcs of cached log entries, if changed, and to properly populate the 'versions' dictionary.
author Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
date Wed, 07 Oct 2015 11:33:52 +0300
parents a8d13ee0ce68
children 2b585677220e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7917
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
1 '''
7918
62f11ef0df5b Change wording in example hook
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7917
diff changeset
2 Examples of useful python hooks for Mercurial.
7917
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
3 '''
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
4 from mercurial import patch, util
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
5
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
6 def diffstat(ui, repo, **kwargs):
7918
62f11ef0df5b Change wording in example hook
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7917
diff changeset
7 '''Example usage:
7917
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
8
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
9 [hooks]
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
10 commit.diffstat = python:/path/to/this/file.py:diffstat
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
11 changegroup.diffstat = python:/path/to/this/file.py:diffstat
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
12 '''
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
13 if kwargs.get('parent2'):
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
14 return
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
15 node = kwargs['node']
13878
a8d13ee0ce68 misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents: 7918
diff changeset
16 first = repo[node].p1().node()
7917
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
17 if 'url' in kwargs:
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
18 last = repo['tip'].node()
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
19 else:
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
20 last = node
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
21 diff = patch.diff(repo, first, last)
5a5396f49420 diffstat hook example
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
22 ui.write(patch.diffstat(util.iterlines(diff)))