Mercurial > hg
annotate contrib/memory.py @ 23381:cc0ff93d0c0c stable
changegroup: fix file linkrevs during reorders (issue4462)
Previously, if reorder was true during the creation of a changegroup bundle,
it was possible that the manifest and filelogs would be reordered such that the
resulting bundle filelog had a linkrev that pointed to a commit that was not
the earliest instance of the filelog revision. For example:
With commits:
0<-1<---3<-4
\ /
--2<---
if 2 and 3 added the same version of a file, if the manifests of 2 and 3 have
their order reversed, but the changelog did not, it could produce a filelog with
linkrevs 0<-3 instead of 0<-2, which meant if commit 3 was stripped, it would
delete that file data from the repository and commit 2 would be corrupt (as
would any future pulls that tried to build upon that version of the file).
The fix is to make the linkrev fixup smarter. Previously it considered the first
manifest that added a file to be the first commit that added that file, which is
not true. Now, for every file revision we add to the bundle we make sure we
attach it to the earliest applicable linkrev.
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 20 Nov 2014 16:30:57 -0800 |
parents | 08a0f04b56bd |
children | 3e0d27d298b7 |
rev | line source |
---|---|
10017
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
1 # memory.py - track memory usage |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
2 # |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
3 # Copyright 2009 Matt Mackall <mpm@selenic.com> and others |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
4 # |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10264 | 6 # GNU General Public License version 2 or any later version. |
10017
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
7 |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
8 '''helper extension to measure memory usage |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
9 |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
10 Reads current and peak memory usage from ``/proc/self/status`` and |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
11 prints it to ``stderr`` on exit. |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
12 ''' |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
13 |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
14 import atexit |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
15 |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
16 def memusage(ui): |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
17 """Report memory usage of the current process.""" |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
18 status = None |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
19 result = {'peak': 0, 'rss': 0} |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
20 try: |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
21 # This will only work on systems with a /proc file system |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
22 # (like Linux). |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
23 status = open('/proc/self/status', 'r') |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
24 for line in status: |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
25 parts = line.split() |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
26 key = parts[0][2:-1].lower() |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
27 if key in result: |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
28 result[key] = int(parts[1]) |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
29 finally: |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
30 if status is not None: |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
31 status.close() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
32 ui.write_err(", ".join(["%s: %.1f MiB" % (key, value / 1024.0) |
10017
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
33 for key, value in result.iteritems()]) + "\n") |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
34 |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
35 def extsetup(ui): |
253d0da256b2
contrib: helper extension to track memory usage
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
36 atexit.register(memusage, ui) |