Mercurial > hg
annotate mercurial/changegroup.py @ 33495:d78b7d734b63
patch: use devel.all-warnings to replace devel.all
It appears to be a misspell in patch.py.
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 12 Jul 2017 15:24:47 -0700 |
parents | bb72031f0ea8 |
children | 38fc45721334 91f0677dc920 |
rev | line source |
---|---|
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
1 # changegroup.py - Mercurial changegroup manipulation functions |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
2 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
3 # Copyright 2006 Matt Mackall <mpm@selenic.com> |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
4 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
3877
abaee83ce0a6
Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents:
3859
diff
changeset
|
7 |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
8 from __future__ import absolute_import |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
9 |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
10 import os |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
11 import struct |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
12 import tempfile |
20933
d3775db748a0
localrepo: move the addchangegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20932
diff
changeset
|
13 import weakref |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
14 |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
15 from .i18n import _ |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
16 from .node import ( |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
17 hex, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
18 nullrev, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
19 short, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
20 ) |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
21 |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
22 from . import ( |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
23 dagutil, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
24 discovery, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
25 error, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
26 mdiff, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
27 phases, |
30925
82f1ef8b4477
py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30743
diff
changeset
|
28 pycompat, |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
29 util, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
30 ) |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
31 |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
32 _CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s" |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
33 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s" |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
34 _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH" |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
35 |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
36 def readexactly(stream, n): |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
37 '''read n bytes from stream.read and abort if less was available''' |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
38 s = stream.read(n) |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
39 if len(s) < n: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
40 raise error.Abort(_("stream ended unexpectedly" |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
41 " (got %d bytes, expected %d)") |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
42 % (len(s), n)) |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
43 return s |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
44 |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
45 def getchunk(stream): |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
46 """return the next chunk from stream as a string""" |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
47 d = readexactly(stream, 4) |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
48 l = struct.unpack(">l", d)[0] |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
49 if l <= 4: |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
50 if l: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
51 raise error.Abort(_("invalid chunk length %d") % l) |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
52 return "" |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
53 return readexactly(stream, l - 4) |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
54 |
5368
61462e7d62ed
changegroup: avoid large copies
Matt Mackall <mpm@selenic.com>
parents:
3932
diff
changeset
|
55 def chunkheader(length): |
9437
1c4e4004f3a6
Improve some docstrings relating to changegroups and prepush().
Greg Ward <greg-hg@gerg.ca>
parents:
9087
diff
changeset
|
56 """return a changegroup chunk header (string)""" |
5368
61462e7d62ed
changegroup: avoid large copies
Matt Mackall <mpm@selenic.com>
parents:
3932
diff
changeset
|
57 return struct.pack(">l", length + 4) |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
58 |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
59 def closechunk(): |
9437
1c4e4004f3a6
Improve some docstrings relating to changegroups and prepush().
Greg Ward <greg-hg@gerg.ca>
parents:
9087
diff
changeset
|
60 """return a changegroup chunk header (string) for a zero-length chunk""" |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
61 return struct.pack(">l", 0) |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
62 |
26540
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
63 def writechunks(ui, chunks, filename, vfs=None): |
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
64 """Write chunks to a file and return its filename. |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
65 |
26540
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
66 The stream is assumed to be a bundle file. |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
67 Existing files will not be overwritten. |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
68 If no filename is specified, a temporary file is created. |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
69 """ |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
70 fh = None |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
71 cleanup = None |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
72 try: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
73 if filename: |
20976
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
74 if vfs: |
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
75 fh = vfs.open(filename, "wb") |
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
76 else: |
30212
260af19891f2
changegroup: increase write buffer size to 128k
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30211
diff
changeset
|
77 # Increase default buffer size because default is usually |
260af19891f2
changegroup: increase write buffer size to 128k
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30211
diff
changeset
|
78 # small (4k is common on Linux). |
260af19891f2
changegroup: increase write buffer size to 128k
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30211
diff
changeset
|
79 fh = open(filename, "wb", 131072) |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
80 else: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
81 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") |
30925
82f1ef8b4477
py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30743
diff
changeset
|
82 fh = os.fdopen(fd, pycompat.sysstr("wb")) |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
83 cleanup = filename |
26540
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
84 for c in chunks: |
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
85 fh.write(c) |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
86 cleanup = None |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
87 return filename |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
88 finally: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
89 if fh is not None: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
90 fh.close() |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
91 if cleanup is not None: |
20976
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
92 if filename and vfs: |
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
93 vfs.unlink(cleanup) |
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
94 else: |
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
95 os.unlink(cleanup) |
3660
8500a13ec44b
create a readbundle function
Matt Mackall <mpm@selenic.com>
parents:
3659
diff
changeset
|
96 |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
97 class cg1unpacker(object): |
26708
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
98 """Unpacker for cg1 changegroup streams. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
99 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
100 A changegroup unpacker handles the framing of the revision data in |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
101 the wire format. Most consumers will want to use the apply() |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
102 method to add the changes from the changegroup to a repository. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
103 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
104 If you're forwarding a changegroup unmodified to another consumer, |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
105 use getchunks(), which returns an iterator of changegroup |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
106 chunks. This is mostly useful for cases where you need to know the |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
107 data stream has ended by observing the end of the changegroup. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
108 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
109 deltachunk() is useful only if you're applying delta data. Most |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
110 consumers should prefer apply() instead. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
111 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
112 A few other public methods exist. Those are used only for |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
113 bundlerepo and some debug commands - their use is discouraged. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
114 """ |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
115 deltaheader = _CHANGEGROUPV1_DELTA_HEADER |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
116 deltaheadersize = struct.calcsize(deltaheader) |
23896
becfecaf9087
changegroup.writebundle: HG2Y support
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
117 version = '01' |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
118 _grouplistcount = 1 # One list of files after the manifests |
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
119 |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
120 def __init__(self, fh, alg, extras=None): |
30354
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30339
diff
changeset
|
121 if alg is None: |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30339
diff
changeset
|
122 alg = 'UN' |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30339
diff
changeset
|
123 if alg not in util.compengines.supportedbundletypes: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
124 raise error.Abort(_('unknown stream compression type: %s') |
26266
1e042e31bd0c
changegroup: move all compressions utilities in util
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25921
diff
changeset
|
125 % alg) |
26392
127b59787fd5
changegroup: use a different compression key for BZ in HG10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26272
diff
changeset
|
126 if alg == 'BZ': |
127b59787fd5
changegroup: use a different compression key for BZ in HG10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26272
diff
changeset
|
127 alg = '_truncatedBZ' |
30354
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30339
diff
changeset
|
128 |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30339
diff
changeset
|
129 compengine = util.compengines.forbundletype(alg) |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30339
diff
changeset
|
130 self._stream = compengine.decompressorreader(fh) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
12043
diff
changeset
|
131 self._type = alg |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
132 self.extras = extras or {} |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
133 self.callback = None |
26706
8c0c3059f478
changegroup: note why a few methods on cg1unpacker exist
Augie Fackler <augie@google.com>
parents:
26704
diff
changeset
|
134 |
8c0c3059f478
changegroup: note why a few methods on cg1unpacker exist
Augie Fackler <augie@google.com>
parents:
26704
diff
changeset
|
135 # These methods (compressed, read, seek, tell) all appear to only |
8c0c3059f478
changegroup: note why a few methods on cg1unpacker exist
Augie Fackler <augie@google.com>
parents:
26704
diff
changeset
|
136 # be used by bundlerepo, but it's a little hard to tell. |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
12043
diff
changeset
|
137 def compressed(self): |
30589
182cacaa4c32
cg1packer: fix `compressed` method
Stanislau Hlebik <stash@fb.com>
parents:
30354
diff
changeset
|
138 return self._type is not None and self._type != 'UN' |
12043
bef5effb3db0
bundle: introduce bundle class
Matt Mackall <mpm@selenic.com>
parents:
12042
diff
changeset
|
139 def read(self, l): |
bef5effb3db0
bundle: introduce bundle class
Matt Mackall <mpm@selenic.com>
parents:
12042
diff
changeset
|
140 return self._stream.read(l) |
12330
e527b8635881
bundle: make unbundle object seekable
Matt Mackall <mpm@selenic.com>
parents:
12329
diff
changeset
|
141 def seek(self, pos): |
e527b8635881
bundle: make unbundle object seekable
Matt Mackall <mpm@selenic.com>
parents:
12329
diff
changeset
|
142 return self._stream.seek(pos) |
e527b8635881
bundle: make unbundle object seekable
Matt Mackall <mpm@selenic.com>
parents:
12329
diff
changeset
|
143 def tell(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12330
diff
changeset
|
144 return self._stream.tell() |
12347
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12336
diff
changeset
|
145 def close(self): |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12336
diff
changeset
|
146 return self._stream.close() |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
147 |
26707
5ee6bd529300
changegroup: mark cg1unpacker.chunklength as private
Augie Fackler <augie@google.com>
parents:
26706
diff
changeset
|
148 def _chunklength(self): |
13459
acbe171c8fbe
changegroup: fix typo introduced in 9f2c407caf34
Jim Hague <jim.hague@acm.org>
parents:
13458
diff
changeset
|
149 d = readexactly(self._stream, 4) |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
150 l = struct.unpack(">l", d)[0] |
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
151 if l <= 4: |
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
152 if l: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
153 raise error.Abort(_("invalid chunk length %d") % l) |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
154 return 0 |
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
155 if self.callback: |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
156 self.callback() |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
157 return l - 4 |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
158 |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
159 def changelogheader(self): |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
160 """v10 does not have a changelog header chunk""" |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
161 return {} |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
162 |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
163 def manifestheader(self): |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
164 """v10 does not have a manifest header chunk""" |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
165 return {} |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
166 |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
167 def filelogheader(self): |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
168 """return the header of the filelogs chunk, v10 only has the filename""" |
26707
5ee6bd529300
changegroup: mark cg1unpacker.chunklength as private
Augie Fackler <augie@google.com>
parents:
26706
diff
changeset
|
169 l = self._chunklength() |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
170 if not l: |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
171 return {} |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
172 fname = readexactly(self._stream, l) |
20675
f8d50add83e1
changegroup: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
19708
diff
changeset
|
173 return {'filename': fname} |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
174 |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
175 def _deltaheader(self, headertuple, prevnode): |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
176 node, p1, p2, cs = headertuple |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
177 if prevnode is None: |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
178 deltabase = p1 |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
179 else: |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
180 deltabase = prevnode |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
181 flags = 0 |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
182 return node, p1, p2, deltabase, cs, flags |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
183 |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
184 def deltachunk(self, prevnode): |
26707
5ee6bd529300
changegroup: mark cg1unpacker.chunklength as private
Augie Fackler <augie@google.com>
parents:
26706
diff
changeset
|
185 l = self._chunklength() |
12336
9d234f7d8a77
bundle: move chunk parsing into unbundle class
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
186 if not l: |
9d234f7d8a77
bundle: move chunk parsing into unbundle class
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
187 return {} |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
188 headerdata = readexactly(self._stream, self.deltaheadersize) |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
189 header = struct.unpack(self.deltaheader, headerdata) |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
190 delta = readexactly(self._stream, l - self.deltaheadersize) |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
191 node, p1, p2, deltabase, cs, flags = self._deltaheader(header, prevnode) |
20675
f8d50add83e1
changegroup: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
19708
diff
changeset
|
192 return {'node': node, 'p1': p1, 'p2': p2, 'cs': cs, |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
193 'deltabase': deltabase, 'delta': delta, 'flags': flags} |
12336
9d234f7d8a77
bundle: move chunk parsing into unbundle class
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
194 |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
195 def getchunks(self): |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
196 """returns all the chunks contains in the bundle |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
197 |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
198 Used when you need to forward the binary stream to a file or another |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
199 network API. To do so, it parse the changegroup data, otherwise it will |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
200 block in case of sshrepo because it don't know the end of the stream. |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
201 """ |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
202 # an empty chunkgroup is the end of the changegroup |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
203 # a changegroup has at least 2 chunkgroups (changelog and manifest). |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
204 # after that, changegroup versions 1 and 2 have a series of groups |
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
205 # with one group per file. changegroup 3 has a series of directory |
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
206 # manifests before the files. |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
207 count = 0 |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
208 emptycount = 0 |
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
209 while emptycount < self._grouplistcount: |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
210 empty = True |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
211 count += 1 |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
212 while True: |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
213 chunk = getchunk(self) |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
214 if not chunk: |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
215 if empty and count > 2: |
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
216 emptycount += 1 |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
217 break |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
218 empty = False |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
219 yield chunkheader(len(chunk)) |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
220 pos = 0 |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
221 while pos < len(chunk): |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
222 next = pos + 2**20 |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
223 yield chunk[pos:next] |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
224 pos = next |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
225 yield closechunk() |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
226 |
26712
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
227 def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
228 # We know that we'll never have more manifests than we had |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
229 # changesets. |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
230 self.callback = prog(_('manifests'), numchanges) |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
231 # no need to check for empty manifest group here: |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
232 # if the result of the merge of 1 and 2 is the same in 3 and 4, |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
233 # no new manifest will be created and the manifest group will |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
234 # be empty during the pull |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
235 self.manifestheader() |
30339
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
236 repo.manifestlog._revlog.addgroup(self, revmap, trp) |
26712
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
237 repo.ui.progress(_('manifests'), None) |
28360
11287888ce4b
changegroup: exclude submanifests from manifest progress
Martin von Zweigbergk <martinvonz@google.com>
parents:
28281
diff
changeset
|
238 self.callback = None |
26712
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
239 |
33308
248d5890c80a
changegroup: remove option to allow empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33227
diff
changeset
|
240 def apply(self, repo, tr, srctype, url, targetphase=phases.draft, |
248d5890c80a
changegroup: remove option to allow empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33227
diff
changeset
|
241 expectedtotal=None): |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
242 """Add the changegroup returned by source.read() to this repo. |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
243 srctype is a string like 'push', 'pull', or 'unbundle'. url is |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
244 the URL of the repo where this changegroup is coming from. |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
245 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
246 Return an integer summarizing the change to this repo: |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
247 - nothing changed or no source: 0 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
248 - more heads than before: 1+added heads (2..n) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
249 - fewer heads than before: -1-removed heads (-2..-n) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
250 - number of heads stays the same: 1 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
251 """ |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
252 repo = repo.unfiltered() |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
253 def csmap(x): |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
254 repo.ui.debug("add changeset %s\n" % short(x)) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
255 return len(cl) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
256 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
257 def revmap(x): |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
258 return cl.rev(x) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
259 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
260 changesets = files = revisions = 0 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
261 |
26880
fa7f8b686633
changegroup: fix the scope of a try finally
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26859
diff
changeset
|
262 try: |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
263 # The transaction may already carry source information. In this |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
264 # case we use the top level data. We overwrite the argument |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
265 # because we need to use the top level value (if they exist) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
266 # in this function. |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
267 srctype = tr.hookargs.setdefault('source', srctype) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
268 url = tr.hookargs.setdefault('url', url) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
269 repo.hook('prechangegroup', throw=True, **tr.hookargs) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
270 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
271 # write changelog data to temp files so concurrent readers |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
272 # will not see an inconsistent view |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
273 cl = repo.changelog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
274 cl.delayupdate(tr) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
275 oldheads = set(cl.heads()) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
276 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
277 trp = weakref.proxy(tr) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
278 # pull off the changeset group |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
279 repo.ui.status(_("adding changesets\n")) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
280 clstart = len(cl) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
281 class prog(object): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
282 def __init__(self, step, total): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
283 self._step = step |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
284 self._total = total |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
285 self._count = 1 |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
286 def __call__(self): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
287 repo.ui.progress(self._step, self._count, unit=_('chunks'), |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
288 total=self._total) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
289 self._count += 1 |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
290 self.callback = prog(_('changesets'), expectedtotal) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
291 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
292 efiles = set() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
293 def onchangelog(cl, node): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
294 efiles.update(cl.readfiles(node)) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
295 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
296 self.changelogheader() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
297 cgnodes = cl.addgroup(self, csmap, trp, addrevisioncb=onchangelog) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
298 efiles = len(efiles) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
299 |
33308
248d5890c80a
changegroup: remove option to allow empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33227
diff
changeset
|
300 if not cgnodes: |
33309
69c4493a54f9
changegroup: don't fail on empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33308
diff
changeset
|
301 repo.ui.develwarn('applied empty changegroup', |
69c4493a54f9
changegroup: don't fail on empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33308
diff
changeset
|
302 config='empty-changegroup') |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
303 clend = len(cl) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
304 changesets = clend - clstart |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
305 repo.ui.progress(_('changesets'), None) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
306 self.callback = None |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
307 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
308 # pull off the manifest group |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
309 repo.ui.status(_("adding manifests\n")) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
310 self._unpackmanifests(repo, revmap, trp, prog, changesets) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
311 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
312 needfiles = {} |
33227
86c9aa1d598f
configitems: register the 'server.validate' config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33183
diff
changeset
|
313 if repo.ui.configbool('server', 'validate'): |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
314 cl = repo.changelog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
315 ml = repo.manifestlog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
316 # validate incoming csets have their manifests |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
317 for cset in xrange(clstart, clend): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
318 mfnode = cl.changelogrevision(cset).manifest |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
319 mfest = ml[mfnode].readdelta() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
320 # store file cgnodes we must see |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
321 for f, n in mfest.iteritems(): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
322 needfiles.setdefault(f, set()).add(n) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
323 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
324 # process the files |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
325 repo.ui.status(_("adding file changes\n")) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
326 newrevs, newfiles = _addchangegroupfiles( |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
327 repo, self, revmap, trp, efiles, needfiles) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
328 revisions += newrevs |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
329 files += newfiles |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
330 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
331 deltaheads = 0 |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
332 if oldheads: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
333 heads = cl.heads() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
334 deltaheads = len(heads) - len(oldheads) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
335 for h in heads: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
336 if h not in oldheads and repo[h].closesbranch(): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
337 deltaheads -= 1 |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
338 htext = "" |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
339 if deltaheads: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
340 htext = _(" (%+d heads)") % deltaheads |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
341 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
342 repo.ui.status(_("added %d changesets" |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
343 " with %d changes to %d files%s\n") |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
344 % (changesets, revisions, files, htext)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
345 repo.invalidatevolatilesets() |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
346 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
347 if changesets > 0: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
348 if 'node' not in tr.hookargs: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
349 tr.hookargs['node'] = hex(cl.node(clstart)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
350 tr.hookargs['node_last'] = hex(cl.node(clend - 1)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
351 hookargs = dict(tr.hookargs) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
352 else: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
353 hookargs = dict(tr.hookargs) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
354 hookargs['node'] = hex(cl.node(clstart)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
355 hookargs['node_last'] = hex(cl.node(clend - 1)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
356 repo.hook('pretxnchangegroup', throw=True, **hookargs) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
357 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
358 added = [cl.node(r) for r in xrange(clstart, clend)] |
33456
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
359 phaseall = None |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
360 if srctype in ('push', 'serve'): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
361 # Old servers can not push the boundary themselves. |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
362 # New servers won't push the boundary if changeset already |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
363 # exists locally as secret |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
364 # |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
365 # We should not use added here but the list of all change in |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
366 # the bundle |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
367 if repo.publishing(): |
33456
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
368 targetphase = phaseall = phases.public |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
369 else: |
33456
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
370 # closer target phase computation |
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
371 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
372 # Those changesets have been pushed from the |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
373 # outside, their phases are going to be pushed |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
374 # alongside. Therefor `targetphase` is |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
375 # ignored. |
33456
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
376 targetphase = phaseall = phases.draft |
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
377 if added: |
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
378 phases.registernew(repo, tr, targetphase, added) |
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
379 if phaseall is not None: |
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
380 phases.advanceboundary(repo, tr, phaseall, cgnodes) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
381 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
382 if changesets > 0: |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
383 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
384 def runhooks(): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
385 # These hooks run when the lock releases, not when the |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
386 # transaction closes. So it's possible for the changelog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
387 # to have changed since we last saw it. |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
388 if clstart >= len(repo): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
389 return |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
390 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
391 repo.hook("changegroup", **hookargs) |
27867
7ced54ebf972
with: use context manager for transaction in changegroup apply
Bryan O'Sullivan <bryano@fb.com>
parents:
27754
diff
changeset
|
392 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
393 for n in added: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
394 args = hookargs.copy() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
395 args['node'] = hex(n) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
396 del args['node_last'] |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
397 repo.hook("incoming", **args) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
398 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
399 newheads = [h for h in repo.heads() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
400 if h not in oldheads] |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
401 repo.ui.log("incoming", |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
402 "%s incoming changes - new heads: %s\n", |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
403 len(added), |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
404 ', '.join([hex(c[:6]) for c in newheads])) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
405 |
32931
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
406 tr.addpostclose('changegroup-runhooks-%020i' % clstart, |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32930
diff
changeset
|
407 lambda tr: repo._afterlock(runhooks)) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
408 finally: |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
409 repo.ui.flush() |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
410 # never return 0 here: |
32870
b441296f8e9c
changegroup: rename "dh" to the clearer "deltaheads"
Martin von Zweigbergk <martinvonz@google.com>
parents:
32869
diff
changeset
|
411 if deltaheads < 0: |
33030
3e102a8dd52c
bundle2: record changegroup data in 'op.records' (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32931
diff
changeset
|
412 ret = deltaheads - 1 |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
413 else: |
33030
3e102a8dd52c
bundle2: record changegroup data in 'op.records' (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32931
diff
changeset
|
414 ret = deltaheads + 1 |
33461
bb72031f0ea8
changegroup: stop returning and recording added nodes in 'cg.apply'
Boris Feld <boris.feld@octobus.net>
parents:
33456
diff
changeset
|
415 return ret |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
416 |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
417 class cg2unpacker(cg1unpacker): |
26708
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
418 """Unpacker for cg2 streams. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
419 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
420 cg2 streams add support for generaldelta, so the delta header |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
421 format is slightly different. All other features about the data |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
422 remain the same. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
423 """ |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
424 deltaheader = _CHANGEGROUPV2_DELTA_HEADER |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
425 deltaheadersize = struct.calcsize(deltaheader) |
23896
becfecaf9087
changegroup.writebundle: HG2Y support
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
426 version = '02' |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
427 |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
428 def _deltaheader(self, headertuple, prevnode): |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
429 node, p1, p2, deltabase, cs = headertuple |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
430 flags = 0 |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
431 return node, p1, p2, deltabase, cs, flags |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
432 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
433 class cg3unpacker(cg2unpacker): |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
434 """Unpacker for cg3 streams. |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
435 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
436 cg3 streams add support for exchanging treemanifests and revlog |
27753
d4071cc73f46
changegroup3: add empty chunk separating directories and files
Martin von Zweigbergk <martinvonz@google.com>
parents:
27752
diff
changeset
|
437 flags. It adds the revlog flags to the delta header and an empty chunk |
d4071cc73f46
changegroup3: add empty chunk separating directories and files
Martin von Zweigbergk <martinvonz@google.com>
parents:
27752
diff
changeset
|
438 separating manifests and files. |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
439 """ |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
440 deltaheader = _CHANGEGROUPV3_DELTA_HEADER |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
441 deltaheadersize = struct.calcsize(deltaheader) |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
442 version = '03' |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
443 _grouplistcount = 2 # One list of manifests and one list of files |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
444 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
445 def _deltaheader(self, headertuple, prevnode): |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
446 node, p1, p2, deltabase, cs, flags = headertuple |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
447 return node, p1, p2, deltabase, cs, flags |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
448 |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
449 def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
450 super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog, |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
451 numchanges) |
29724
4e7be6e33269
changegroup: use `iter(callable, sentinel)` instead of while True
Augie Fackler <augie@google.com>
parents:
29690
diff
changeset
|
452 for chunkdata in iter(self.filelogheader, {}): |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
453 # If we get here, there are directory manifests in the changegroup |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
454 d = chunkdata["filename"] |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
455 repo.ui.debug("adding %s revisions\n" % d) |
30339
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
456 dirlog = repo.manifestlog._revlog.dirlog(d) |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
457 if not dirlog.addgroup(self, revmap, trp): |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
458 raise error.Abort(_("received dir revlog group is empty")) |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
459 |
12329
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
460 class headerlessfixup(object): |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
461 def __init__(self, fh, h): |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
462 self._h = h |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
463 self._fh = fh |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
464 def read(self, n): |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
465 if self._h: |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
466 d, self._h = self._h[:n], self._h[n:] |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
467 if len(d) < n: |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
468 d += readexactly(self._fh, n - len(d)) |
12329
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
469 return d |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
470 return readexactly(self._fh, n) |
12329
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
471 |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
472 class cg1packer(object): |
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
473 deltaheader = _CHANGEGROUPV1_DELTA_HEADER |
23896
becfecaf9087
changegroup.writebundle: HG2Y support
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
474 version = '01' |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
475 def __init__(self, repo, bundlecaps=None): |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
476 """Given a source repo, construct a bundler. |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
477 |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
478 bundlecaps is optional and can be used to specify the set of |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
479 capabilities which can be used to build the bundle. While bundlecaps is |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
480 unused in core Mercurial, extensions rely on this feature to communicate |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
481 capabilities to customize the changegroup packer. |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
482 """ |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
483 # Set of capabilities we can use to build the bundle. |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
484 if bundlecaps is None: |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
485 bundlecaps = set() |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
486 self._bundlecaps = bundlecaps |
25831
578fc97904da
generaldelta: mark experimental reordering option
Matt Mackall <mpm@selenic.com>
parents:
25823
diff
changeset
|
487 # experimental config: bundle.reorder |
33183
9f95f0bb343b
configitems: register the 'bundle.reorder' config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33036
diff
changeset
|
488 reorder = repo.ui.config('bundle', 'reorder') |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
489 if reorder == 'auto': |
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
490 reorder = None |
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
491 else: |
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
492 reorder = util.parsebool(reorder) |
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
493 self._repo = repo |
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
494 self._reorder = reorder |
19208
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
495 self._progress = repo.ui.progress |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
496 if self._repo.ui.verbose and not self._repo.ui.debugflag: |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
497 self._verbosenote = self._repo.ui.note |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
498 else: |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
499 self._verbosenote = lambda s: None |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
500 |
13831
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
501 def close(self): |
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
502 return closechunk() |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
503 |
13831
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
504 def fileheader(self, fname): |
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
505 return chunkheader(len(fname)) + fname |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
506 |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
507 # Extracted both for clarity and for overriding in extensions. |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
508 def _sortgroup(self, revlog, nodelist, lookup): |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
509 """Sort nodes for change group and turn them into revnums.""" |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
510 # for generaldelta revlogs, we linearize the revs; this will both be |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
511 # much quicker and generate a much smaller bundle |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
512 if (revlog._generaldelta and self._reorder is None) or self._reorder: |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
513 dag = dagutil.revlogdag(revlog) |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
514 return dag.linearize(set(revlog.rev(n) for n in nodelist)) |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
515 else: |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
516 return sorted([revlog.rev(n) for n in nodelist]) |
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
517 |
24912
e285b98c65cc
changegroup.group: drop 'reorder' parameter
Martin von Zweigbergk <martinvonz@google.com>
parents:
24911
diff
changeset
|
518 def group(self, nodelist, revlog, lookup, units=None): |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
519 """Calculate a delta group, yielding a sequence of changegroup chunks |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
520 (strings). |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
521 |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
522 Given a list of changeset revs, return a set of deltas and |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
523 metadata corresponding to nodes. The first delta is |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
524 first parent(nodelist[0]) -> nodelist[0], the receiver is |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
525 guaranteed to have this parent as it has all history before |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
526 these changesets. In the case firstparent is nullrev the |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
527 changegroup starts with a full revision. |
19208
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
528 |
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
529 If units is not None, progress detail will be generated, units specifies |
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
530 the type of revlog that is touched (changelog, manifest, etc.). |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
531 """ |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
532 # if we don't have any revisions touched by these changesets, bail |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
533 if len(nodelist) == 0: |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
534 yield self.close() |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
535 return |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
536 |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
537 revs = self._sortgroup(revlog, nodelist, lookup) |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
538 |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
539 # add the parent of the first rev |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
540 p = revlog.parentrevs(revs[0])[0] |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
541 revs.insert(0, p) |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
542 |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
543 # build deltas |
19208
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
544 total = len(revs) - 1 |
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
545 msgbundling = _('bundling') |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
546 for r in xrange(len(revs) - 1): |
19208
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
547 if units is not None: |
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
548 self._progress(msgbundling, r + 1, unit=units, total=total) |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
549 prev, curr = revs[r], revs[r + 1] |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
550 linknode = lookup(revlog.node(curr)) |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
551 for c in self.revchunk(revlog, curr, prev, linknode): |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
552 yield c |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
553 |
24901
e9edd53770fb
changegroup: close progress in same function as it's started
Martin von Zweigbergk <martinvonz@google.com>
parents:
24900
diff
changeset
|
554 if units is not None: |
e9edd53770fb
changegroup: close progress in same function as it's started
Martin von Zweigbergk <martinvonz@google.com>
parents:
24900
diff
changeset
|
555 self._progress(msgbundling, None) |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
556 yield self.close() |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
557 |
19289
6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Durham Goode <durham@fb.com>
parents:
19208
diff
changeset
|
558 # filter any nodes that claim to be part of the known set |
24896
9183cb6886ef
changegroup: removed unused 'source' parameter from prune()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24717
diff
changeset
|
559 def prune(self, revlog, missing, commonrevs): |
19289
6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Durham Goode <durham@fb.com>
parents:
19208
diff
changeset
|
560 rr, rl = revlog.rev, revlog.linkrev |
6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Durham Goode <durham@fb.com>
parents:
19208
diff
changeset
|
561 return [n for n in missing if rl(rr(n)) not in commonrevs] |
6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Durham Goode <durham@fb.com>
parents:
19208
diff
changeset
|
562 |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
563 def _packmanifests(self, dir, mfnodes, lookuplinknode): |
26711
0ef0aec56090
changegroup: move manifest packing into a separate function
Augie Fackler <augie@google.com>
parents:
26710
diff
changeset
|
564 """Pack flat manifests into a changegroup stream.""" |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
565 assert not dir |
30339
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
566 for chunk in self.group(mfnodes, self._repo.manifestlog._revlog, |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
567 lookuplinknode, units=_('manifests')): |
26711
0ef0aec56090
changegroup: move manifest packing into a separate function
Augie Fackler <augie@google.com>
parents:
26710
diff
changeset
|
568 yield chunk |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
569 |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
570 def _manifestsdone(self): |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
571 return '' |
26711
0ef0aec56090
changegroup: move manifest packing into a separate function
Augie Fackler <augie@google.com>
parents:
26710
diff
changeset
|
572 |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
573 def generate(self, commonrevs, clnodes, fastpathlinkrev, source): |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
574 '''yield a sequence of changegroup chunks (strings)''' |
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
575 repo = self._repo |
24978
f52560c64953
changegroup: drop _changelog and _manifest properties
Martin von Zweigbergk <martinvonz@google.com>
parents:
24977
diff
changeset
|
576 cl = repo.changelog |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
577 |
23381
cc0ff93d0c0c
changegroup: fix file linkrevs during reorders (issue4462)
Durham Goode <durham@fb.com>
parents:
23226
diff
changeset
|
578 clrevorder = {} |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
579 mfs = {} # needed manifests |
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
580 fnodes = {} # needed file nodes |
28241
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
581 changedfiles = set() |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
582 |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
583 # Callback for the changelog, used to collect changed files and manifest |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
584 # nodes. |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
585 # Returns the linkrev node (identity in the changelog case). |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
586 def lookupcl(x): |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
587 c = cl.read(x) |
23381
cc0ff93d0c0c
changegroup: fix file linkrevs during reorders (issue4462)
Durham Goode <durham@fb.com>
parents:
23226
diff
changeset
|
588 clrevorder[x] = len(clrevorder) |
27237
c08814b48ae5
changegroup: avoid iterating the whole manifest
Augie Fackler <augie@google.com>
parents:
27219
diff
changeset
|
589 n = c[0] |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
590 # record the first changeset introducing this manifest version |
27237
c08814b48ae5
changegroup: avoid iterating the whole manifest
Augie Fackler <augie@google.com>
parents:
27219
diff
changeset
|
591 mfs.setdefault(n, x) |
c08814b48ae5
changegroup: avoid iterating the whole manifest
Augie Fackler <augie@google.com>
parents:
27219
diff
changeset
|
592 # Record a complete list of potentially-changed files in |
c08814b48ae5
changegroup: avoid iterating the whole manifest
Augie Fackler <augie@google.com>
parents:
27219
diff
changeset
|
593 # this manifest. |
28241
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
594 changedfiles.update(c[3]) |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
595 return x |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
596 |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
597 self._verbosenote(_('uncompressed size of bundle content:\n')) |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
598 size = 0 |
24912
e285b98c65cc
changegroup.group: drop 'reorder' parameter
Martin von Zweigbergk <martinvonz@google.com>
parents:
24911
diff
changeset
|
599 for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets')): |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
600 size += len(chunk) |
23224
f4ab47ccefde
changegroup: don't define lookupmf() until it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22971
diff
changeset
|
601 yield chunk |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
602 self._verbosenote(_('%8.i (changelog)\n') % size) |
23224
f4ab47ccefde
changegroup: don't define lookupmf() until it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22971
diff
changeset
|
603 |
24977
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
604 # We need to make sure that the linkrev in the changegroup refers to |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
605 # the first changeset that introduced the manifest or file revision. |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
606 # The fastpath is usually safer than the slowpath, because the filelogs |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
607 # are walked in revlog order. |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
608 # |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
609 # When taking the slowpath with reorder=None and the manifest revlog |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
610 # uses generaldelta, the manifest may be walked in the "wrong" order. |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
611 # Without 'clrevorder', we would get an incorrect linkrev (see fix in |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
612 # cc0ff93d0c0c). |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
613 # |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
614 # When taking the fastpath, we are only vulnerable to reordering |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
615 # of the changelog itself. The changelog never uses generaldelta, so |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
616 # it is only reordered when reorder=True. To handle this case, we |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
617 # simply take the slowpath, which already has the 'clrevorder' logic. |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
618 # This was also fixed in cc0ff93d0c0c. |
24976
147d8892fc4b
changegroup: extract condition for linkrev fastpath
Martin von Zweigbergk <martinvonz@google.com>
parents:
24912
diff
changeset
|
619 fastpathlinkrev = fastpathlinkrev and not self._reorder |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
620 # Treemanifests don't work correctly with fastpathlinkrev |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
621 # either, because we don't discover which directory nodes to |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
622 # send along with files. This could probably be fixed. |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
623 fastpathlinkrev = fastpathlinkrev and ( |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
624 'treemanifest' not in repo.requirements) |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
625 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
626 for chunk in self.generatemanifests(commonrevs, clrevorder, |
28241
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
627 fastpathlinkrev, mfs, fnodes): |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
628 yield chunk |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
629 mfs.clear() |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
630 clrevs = set(cl.rev(x) for x in clnodes) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
631 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
632 if not fastpathlinkrev: |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
633 def linknodes(unused, fname): |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
634 return fnodes.get(fname, {}) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
635 else: |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
636 cln = cl.node |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
637 def linknodes(filerevlog, fname): |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
638 llr = filerevlog.linkrev |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
639 fln = filerevlog.node |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
640 revs = ((r, llr(r)) for r in filerevlog) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
641 return dict((fln(r), cln(lr)) for r, lr in revs if lr in clrevs) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
642 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
643 for chunk in self.generatefiles(changedfiles, linknodes, commonrevs, |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
644 source): |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
645 yield chunk |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
646 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
647 yield self.close() |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
648 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
649 if clnodes: |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
650 repo.hook('outgoing', node=hex(clnodes[0]), source=source) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
651 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
652 def generatemanifests(self, commonrevs, clrevorder, fastpathlinkrev, mfs, |
28241
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
653 fnodes): |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
654 repo = self._repo |
30294
bce79dfcf5e4
manifest: get rid of manifest.readshallowfast
Durham Goode <durham@fb.com>
parents:
30268
diff
changeset
|
655 mfl = repo.manifestlog |
bce79dfcf5e4
manifest: get rid of manifest.readshallowfast
Durham Goode <durham@fb.com>
parents:
30268
diff
changeset
|
656 dirlog = mfl._revlog.dirlog |
28232
829d369fc5a8
changegroup: write root manifests and subdir manifests in a single loop
Martin von Zweigbergk <martinvonz@google.com>
parents:
28231
diff
changeset
|
657 tmfnodes = {'': mfs} |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
658 |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
659 # Callback for the manifest, used to collect linkrevs for filelog |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
660 # revisions. |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
661 # Returns the linkrev node (collected in lookupcl). |
28231
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
662 def makelookupmflinknode(dir): |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
663 if fastpathlinkrev: |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
664 assert not dir |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
665 return mfs.__getitem__ |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
666 |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
667 def lookupmflinknode(x): |
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
668 """Callback for looking up the linknode for manifests. |
27219
beb60a898dd0
changegroup: document manifest linkrev callback some more
Augie Fackler <augie@google.com>
parents:
27218
diff
changeset
|
669 |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
670 Returns the linkrev node for the specified manifest. |
27219
beb60a898dd0
changegroup: document manifest linkrev callback some more
Augie Fackler <augie@google.com>
parents:
27218
diff
changeset
|
671 |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
672 SIDE EFFECT: |
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
673 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
674 1) fclnodes gets populated with the list of relevant |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
675 file nodes if we're not using fastpathlinkrev |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
676 2) When treemanifests are in use, collects treemanifest nodes |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
677 to send |
27219
beb60a898dd0
changegroup: document manifest linkrev callback some more
Augie Fackler <augie@google.com>
parents:
27218
diff
changeset
|
678 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
679 Note that this means manifests must be completely sent to |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
680 the client before you can trust the list of files and |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
681 treemanifests to send. |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
682 """ |
28240
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
683 clnode = tmfnodes[dir][x] |
30294
bce79dfcf5e4
manifest: get rid of manifest.readshallowfast
Durham Goode <durham@fb.com>
parents:
30268
diff
changeset
|
684 mdata = mfl.get(dir, x).readfast(shallow=True) |
28241
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
685 for p, n, fl in mdata.iterentries(): |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
686 if fl == 't': # subdirectory manifest |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
687 subdir = dir + p + '/' |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
688 tmfclnodes = tmfnodes.setdefault(subdir, {}) |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
689 tmfclnode = tmfclnodes.setdefault(n, clnode) |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
690 if clrevorder[clnode] < clrevorder[tmfclnode]: |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
691 tmfclnodes[n] = clnode |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
692 else: |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
693 f = dir + p |
28240
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
694 fclnodes = fnodes.setdefault(f, {}) |
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
695 fclnode = fclnodes.setdefault(n, clnode) |
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
696 if clrevorder[clnode] < clrevorder[fclnode]: |
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
697 fclnodes[n] = clnode |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
698 return clnode |
28231
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
699 return lookupmflinknode |
19206
6308896b1d4a
bundle-ng: simplify bundle10.generate
Sune Foldager <cryo@cyanite.org>
parents:
19204
diff
changeset
|
700 |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
701 size = 0 |
28232
829d369fc5a8
changegroup: write root manifests and subdir manifests in a single loop
Martin von Zweigbergk <martinvonz@google.com>
parents:
28231
diff
changeset
|
702 while tmfnodes: |
829d369fc5a8
changegroup: write root manifests and subdir manifests in a single loop
Martin von Zweigbergk <martinvonz@google.com>
parents:
28231
diff
changeset
|
703 dir = min(tmfnodes) |
829d369fc5a8
changegroup: write root manifests and subdir manifests in a single loop
Martin von Zweigbergk <martinvonz@google.com>
parents:
28231
diff
changeset
|
704 nodes = tmfnodes[dir] |
28240
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
705 prunednodes = self.prune(dirlog(dir), nodes, commonrevs) |
29371
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
706 if not dir or prunednodes: |
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
707 for x in self._packmanifests(dir, prunednodes, |
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
708 makelookupmflinknode(dir)): |
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
709 size += len(x) |
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
710 yield x |
28232
829d369fc5a8
changegroup: write root manifests and subdir manifests in a single loop
Martin von Zweigbergk <martinvonz@google.com>
parents:
28231
diff
changeset
|
711 del tmfnodes[dir] |
28229
8e13b2379407
changegroup: include subdirectory manifests in verbose size
Martin von Zweigbergk <martinvonz@google.com>
parents:
28228
diff
changeset
|
712 self._verbosenote(_('%8.i (manifests)\n') % size) |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
713 yield self._manifestsdone() |
19206
6308896b1d4a
bundle-ng: simplify bundle10.generate
Sune Foldager <cryo@cyanite.org>
parents:
19204
diff
changeset
|
714 |
24897
5c35a6040352
changegroup: document that 'source' parameter exists for extensions
Martin von Zweigbergk <martinvonz@google.com>
parents:
24896
diff
changeset
|
715 # The 'source' parameter is useful for extensions |
19334
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
716 def generatefiles(self, changedfiles, linknodes, commonrevs, source): |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
717 repo = self._repo |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
718 progress = self._progress |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
719 msgbundling = _('bundling') |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
720 |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
721 total = len(changedfiles) |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
722 # for progress output |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
723 msgfiles = _('files') |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
724 for i, fname in enumerate(sorted(changedfiles)): |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
725 filerevlog = repo.file(fname) |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
726 if not filerevlog: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
727 raise error.Abort(_("empty or missing revlog for %s") % fname) |
19334
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
728 |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
729 linkrevnodes = linknodes(filerevlog, fname) |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
730 # Lookup for filenodes, we collected the linkrev nodes above in the |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
731 # fastpath case and with lookupmf in the slowpath case. |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
732 def lookupfilelog(x): |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
733 return linkrevnodes[x] |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
734 |
24896
9183cb6886ef
changegroup: removed unused 'source' parameter from prune()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24717
diff
changeset
|
735 filenodes = self.prune(filerevlog, linkrevnodes, commonrevs) |
19206
6308896b1d4a
bundle-ng: simplify bundle10.generate
Sune Foldager <cryo@cyanite.org>
parents:
19204
diff
changeset
|
736 if filenodes: |
19208
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
737 progress(msgbundling, i + 1, item=fname, unit=msgfiles, |
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
738 total=total) |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
739 h = self.fileheader(fname) |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
740 size = len(h) |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
741 yield h |
24912
e285b98c65cc
changegroup.group: drop 'reorder' parameter
Martin von Zweigbergk <martinvonz@google.com>
parents:
24911
diff
changeset
|
742 for chunk in self.group(filenodes, filerevlog, lookupfilelog): |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
743 size += len(chunk) |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
744 yield chunk |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
745 self._verbosenote(_('%8.i %s\n') % (size, fname)) |
24901
e9edd53770fb
changegroup: close progress in same function as it's started
Martin von Zweigbergk <martinvonz@google.com>
parents:
24900
diff
changeset
|
746 progress(msgbundling, None) |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
747 |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
748 def deltaparent(self, revlog, rev, p1, p2, prev): |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
749 return prev |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
750 |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
751 def revchunk(self, revlog, rev, prev, linknode): |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
752 node = revlog.node(rev) |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
753 p1, p2 = revlog.parentrevs(rev) |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
754 base = self.deltaparent(revlog, rev, p1, p2, prev) |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
755 |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
756 prefix = '' |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
757 if revlog.iscensored(base) or revlog.iscensored(rev): |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
758 try: |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30628
diff
changeset
|
759 delta = revlog.revision(node, raw=True) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25624
diff
changeset
|
760 except error.CensoredNodeError as e: |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
761 delta = e.tombstone |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
762 if base == nullrev: |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
763 prefix = mdiff.trivialdiffheader(len(delta)) |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
764 else: |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
765 baselen = revlog.rawsize(base) |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
766 prefix = mdiff.replacediffheader(baselen, len(delta)) |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
767 elif base == nullrev: |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30628
diff
changeset
|
768 delta = revlog.revision(node, raw=True) |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
769 prefix = mdiff.trivialdiffheader(len(delta)) |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
770 else: |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
771 delta = revlog.revdiff(base, rev) |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
772 p1n, p2n = revlog.parents(node) |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
773 basenode = revlog.node(base) |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
774 flags = revlog.flags(rev) |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
775 meta = self.builddeltaheader(node, p1n, p2n, basenode, linknode, flags) |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
776 meta += prefix |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
777 l = len(meta) + len(delta) |
13831
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
778 yield chunkheader(l) |
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
779 yield meta |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
780 yield delta |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
781 def builddeltaheader(self, node, p1n, p2n, basenode, linknode, flags): |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
782 # do nothing with basenode, it is implicitly the previous one in HG10 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
783 # do nothing with flags, it is implicitly 0 for cg1 and cg2 |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
784 return struct.pack(self.deltaheader, node, p1n, p2n, linknode) |
20925
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
785 |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
786 class cg2packer(cg1packer): |
23896
becfecaf9087
changegroup.writebundle: HG2Y support
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
787 version = '02' |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
788 deltaheader = _CHANGEGROUPV2_DELTA_HEADER |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
789 |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
790 def __init__(self, repo, bundlecaps=None): |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
791 super(cg2packer, self).__init__(repo, bundlecaps) |
24911
5447b8523fef
cg2packer: set reorder=False in __init__ instead of in group()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24910
diff
changeset
|
792 if self._reorder is None: |
5447b8523fef
cg2packer: set reorder=False in __init__ instead of in group()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24910
diff
changeset
|
793 # Since generaldelta is directly supported by cg2, reordering |
5447b8523fef
cg2packer: set reorder=False in __init__ instead of in group()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24910
diff
changeset
|
794 # generally doesn't help, so we disable it by default (treating |
5447b8523fef
cg2packer: set reorder=False in __init__ instead of in group()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24910
diff
changeset
|
795 # bundle.reorder=auto just like bundle.reorder=False). |
5447b8523fef
cg2packer: set reorder=False in __init__ instead of in group()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24910
diff
changeset
|
796 self._reorder = False |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
797 |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
798 def deltaparent(self, revlog, rev, p1, p2, prev): |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
799 dp = revlog.deltaparent(rev) |
30211
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
800 if dp == nullrev and revlog.storedeltachains: |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
801 # Avoid sending full revisions when delta parent is null. Pick prev |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
802 # in that case. It's tempting to pick p1 in this case, as p1 will |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
803 # be smaller in the common case. However, computing a delta against |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
804 # p1 may require resolving the raw text of p1, which could be |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
805 # expensive. The revlog caches should have prev cached, meaning |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
806 # less CPU for changegroup generation. There is likely room to add |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
807 # a flag and/or config option to control this behavior. |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
808 return prev |
30211
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
809 elif dp == nullrev: |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
810 # revlog is configured to use full snapshot for a reason, |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
811 # stick to full snapshot. |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
812 return nullrev |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
813 elif dp not in (p1, p2, prev): |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
814 # Pick prev when we can't be sure remote has the base revision. |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
815 return prev |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
816 else: |
6b0741d6d234
changegroup: skip delta when the underlying revlog do not use them
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30153
diff
changeset
|
817 return dp |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
818 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
819 def builddeltaheader(self, node, p1n, p2n, basenode, linknode, flags): |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
820 # Do nothing with flags, it is implicitly 0 in cg1 and cg2 |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
821 return struct.pack(self.deltaheader, node, p1n, p2n, basenode, linknode) |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
822 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
823 class cg3packer(cg2packer): |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
824 version = '03' |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
825 deltaheader = _CHANGEGROUPV3_DELTA_HEADER |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
826 |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
827 def _packmanifests(self, dir, mfnodes, lookuplinknode): |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
828 if dir: |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
829 yield self.fileheader(dir) |
30339
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
830 |
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
831 dirlog = self._repo.manifestlog._revlog.dirlog(dir) |
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
832 for chunk in self.group(mfnodes, dirlog, lookuplinknode, |
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30294
diff
changeset
|
833 units=_('manifests')): |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
834 yield chunk |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
835 |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
836 def _manifestsdone(self): |
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
837 return self.close() |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
838 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
839 def builddeltaheader(self, node, p1n, p2n, basenode, linknode, flags): |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
840 return struct.pack( |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
841 self.deltaheader, node, p1n, p2n, basenode, linknode, flags) |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
842 |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
843 _packermap = {'01': (cg1packer, cg1unpacker), |
26709
42733e956887
changegroup: reformat packermap and add comment
Augie Fackler <augie@google.com>
parents:
26708
diff
changeset
|
844 # cg2 adds support for exchanging generaldelta |
42733e956887
changegroup: reformat packermap and add comment
Augie Fackler <augie@google.com>
parents:
26708
diff
changeset
|
845 '02': (cg2packer, cg2unpacker), |
27753
d4071cc73f46
changegroup3: add empty chunk separating directories and files
Martin von Zweigbergk <martinvonz@google.com>
parents:
27752
diff
changeset
|
846 # cg3 adds support for exchanging revlog flags and treemanifests |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
847 '03': (cg3packer, cg3unpacker), |
26709
42733e956887
changegroup: reformat packermap and add comment
Augie Fackler <augie@google.com>
parents:
26708
diff
changeset
|
848 } |
23168
a92ba36a1a9d
changegroup: add a "packermap" dictionary to track different packer versions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22971
diff
changeset
|
849 |
30627
7ace5304fec5
changegroup: pass 'repo' to allsupportedversions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30626
diff
changeset
|
850 def allsupportedversions(repo): |
27928
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
851 versions = set(_packermap.keys()) |
30627
7ace5304fec5
changegroup: pass 'repo' to allsupportedversions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30626
diff
changeset
|
852 if not (repo.ui.configbool('experimental', 'changegroup3') or |
30628
a001cd7296a5
changegroup: simplify logic around enabling changegroup 03
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30627
diff
changeset
|
853 repo.ui.configbool('experimental', 'treemanifest') or |
a001cd7296a5
changegroup: simplify logic around enabling changegroup 03
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30627
diff
changeset
|
854 'treemanifest' in repo.requirements): |
30626
438532c99b54
changegroup: simplify 'allsupportedversions' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30589
diff
changeset
|
855 versions.discard('03') |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
856 return versions |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
857 |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
858 # Changegroup versions that can be applied to the repo |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
859 def supportedincomingversions(repo): |
30628
a001cd7296a5
changegroup: simplify logic around enabling changegroup 03
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30627
diff
changeset
|
860 return allsupportedversions(repo) |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
861 |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
862 # Changegroup versions that can be created from the repo |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
863 def supportedoutgoingversions(repo): |
30627
7ace5304fec5
changegroup: pass 'repo' to allsupportedversions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30626
diff
changeset
|
864 versions = allsupportedversions(repo) |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
865 if 'treemanifest' in repo.requirements: |
27928
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
866 # Versions 01 and 02 support only flat manifests and it's just too |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
867 # expensive to convert between the flat manifest and tree manifest on |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
868 # the fly. Since tree manifests are hashed differently, all of history |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
869 # would have to be converted. Instead, we simply don't even pretend to |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
870 # support versions 01 and 02. |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
871 versions.discard('01') |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
872 versions.discard('02') |
27752
29cfc474c5fd
changegroup3: introduce experimental.changegroup3 boolean config
Martin von Zweigbergk <martinvonz@google.com>
parents:
27751
diff
changeset
|
873 return versions |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
874 |
27929
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
875 def safeversion(repo): |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
876 # Finds the smallest version that it's safe to assume clients of the repo |
27931
1289a122cf3f
shelve: use cg3 for treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27929
diff
changeset
|
877 # will support. For example, all hg versions that support generaldelta also |
1289a122cf3f
shelve: use cg3 for treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27929
diff
changeset
|
878 # support changegroup 02. |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
879 versions = supportedoutgoingversions(repo) |
27929
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
880 if 'generaldelta' in repo.requirements: |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
881 versions.discard('01') |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
882 assert versions |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
883 return min(versions) |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
884 |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
885 def getbundler(version, repo, bundlecaps=None): |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
886 assert version in supportedoutgoingversions(repo) |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
887 return _packermap[version][0](repo, bundlecaps) |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
888 |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
889 def getunbundler(version, fh, alg, extras=None): |
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
890 return _packermap[version][1](fh, alg, extras=extras) |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
891 |
20926
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
892 def _changegroupinfo(repo, nodes, source): |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
893 if repo.ui.verbose or source == 'bundle': |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
894 repo.ui.status(_("%d changesets found\n") % len(nodes)) |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
895 if repo.ui.debugflag: |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
896 repo.ui.debug("list of changesets:\n") |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
897 for node in nodes: |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
898 repo.ui.debug("%s\n" % hex(node)) |
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
899 |
23177
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
900 def getsubsetraw(repo, outgoing, bundler, source, fastpath=False): |
20925
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
901 repo = repo.unfiltered() |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
902 commonrevs = outgoing.common |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
903 csets = outgoing.missing |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
904 heads = outgoing.missingheads |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
905 # We go through the fast path if we get told to, or if all (unfiltered |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
906 # heads have been requested (since we then know there all linkrevs will |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
907 # be pulled by the client). |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
908 heads.sort() |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
909 fastpathlinkrev = fastpath or ( |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
910 repo.filtername is None and heads == sorted(repo.heads())) |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
911 |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
912 repo.hook('preoutgoing', throw=True, source=source) |
20926
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
913 _changegroupinfo(repo, csets, source) |
23177
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
914 return bundler.generate(commonrevs, csets, fastpathlinkrev, source) |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
915 |
26595
be0489770925
getsubset: get the unpacker version from the bundler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
916 def getsubset(repo, outgoing, bundler, source, fastpath=False): |
23177
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
917 gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath) |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
918 return getunbundler(bundler.version, util.chunkbuffer(gengroup), None, |
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
919 {'clcount': len(outgoing.missing)}) |
20927
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
920 |
23897
f99a6e1865e5
changegroup.getsubset: support multiple versions
Eric Sumner <ericsumner@fb.com>
parents:
23896
diff
changeset
|
921 def changegroupsubset(repo, roots, heads, source, version='01'): |
20927
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
922 """Compute a changegroup consisting of all the nodes that are |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
923 descendants of any of the roots and ancestors of any of the heads. |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
924 Return a chunkbuffer object whose read() method will return |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
925 successive changegroup chunks. |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
926 |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
927 It is fairly complex as determining which filenodes and which |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
928 manifest nodes need to be included for the changeset to be complete |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
929 is non-trivial. |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
930 |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
931 Another wrinkle is doing the reverse, figuring out which changeset in |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
932 the changegroup a particular filenode or manifestnode belongs to. |
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
933 """ |
29806
82e8c86cdd6d
outgoing: add a 'missingroots' argument
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29804
diff
changeset
|
934 outgoing = discovery.outgoing(repo, missingroots=roots, missingheads=heads) |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
935 bundler = getbundler(version, repo) |
26595
be0489770925
getsubset: get the unpacker version from the bundler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
936 return getsubset(repo, outgoing, bundler, source) |
20927
24a443948627
localrepo: move the changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20926
diff
changeset
|
937 |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
938 def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None, |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
939 version='01'): |
23177
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
940 """Like getbundle, but taking a discovery.outgoing as an argument. |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
941 |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
942 This is only implemented for local repos and reuses potentially |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
943 precomputed sets in outgoing. Returns a raw changegroup generator.""" |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
944 if not outgoing.missing: |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
945 return None |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
946 bundler = getbundler(version, repo, bundlecaps) |
23177
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
947 return getsubsetraw(repo, outgoing, bundler, source) |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
948 |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
949 def getchangegroup(repo, source, outgoing, bundlecaps=None, |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
950 version='01'): |
20928
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
951 """Like getbundle, but taking a discovery.outgoing as an argument. |
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
952 |
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
953 This is only implemented for local repos and reuses potentially |
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
954 precomputed sets in outgoing.""" |
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
955 if not outgoing.missing: |
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
956 return None |
32287
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32268
diff
changeset
|
957 bundler = getbundler(version, repo, bundlecaps) |
20928
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
958 return getsubset(repo, outgoing, bundler, source) |
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20927
diff
changeset
|
959 |
32168
4e6aab69a98b
changegroup: deprecate 'getlocalchangroup' (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32164
diff
changeset
|
960 def getlocalchangegroup(repo, *args, **kwargs): |
4e6aab69a98b
changegroup: deprecate 'getlocalchangroup' (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32164
diff
changeset
|
961 repo.ui.deprecwarn('getlocalchangegroup is deprecated, use getchangegroup', |
4e6aab69a98b
changegroup: deprecate 'getlocalchangroup' (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32164
diff
changeset
|
962 '4.3') |
4e6aab69a98b
changegroup: deprecate 'getlocalchangroup' (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32164
diff
changeset
|
963 return getchangegroup(repo, *args, **kwargs) |
20930
4a987060d97e
localrepo: move the getbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20928
diff
changeset
|
964 |
20931
de60ca3a390e
localrepo: move the changegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20930
diff
changeset
|
965 def changegroup(repo, basenodes, source): |
de60ca3a390e
localrepo: move the changegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20930
diff
changeset
|
966 # to avoid a race we use changegroupsubset() (issue1320) |
de60ca3a390e
localrepo: move the changegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20930
diff
changeset
|
967 return changegroupsubset(repo, basenodes, repo.heads(), source) |
de60ca3a390e
localrepo: move the changegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20930
diff
changeset
|
968 |
28361
277a22cd8741
changegroup: progress for added files is not measured in "chunks"
Martin von Zweigbergk <martinvonz@google.com>
parents:
28360
diff
changeset
|
969 def _addchangegroupfiles(repo, source, revmap, trp, expectedfiles, needfiles): |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
970 revisions = 0 |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
971 files = 0 |
29724
4e7be6e33269
changegroup: use `iter(callable, sentinel)` instead of while True
Augie Fackler <augie@google.com>
parents:
29690
diff
changeset
|
972 for chunkdata in iter(source.filelogheader, {}): |
28361
277a22cd8741
changegroup: progress for added files is not measured in "chunks"
Martin von Zweigbergk <martinvonz@google.com>
parents:
28360
diff
changeset
|
973 files += 1 |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
974 f = chunkdata["filename"] |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
975 repo.ui.debug("adding %s revisions\n" % f) |
28361
277a22cd8741
changegroup: progress for added files is not measured in "chunks"
Martin von Zweigbergk <martinvonz@google.com>
parents:
28360
diff
changeset
|
976 repo.ui.progress(_('files'), files, unit=_('files'), |
277a22cd8741
changegroup: progress for added files is not measured in "chunks"
Martin von Zweigbergk <martinvonz@google.com>
parents:
28360
diff
changeset
|
977 total=expectedfiles) |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
978 fl = repo.file(f) |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
979 o = len(fl) |
24120
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
23897
diff
changeset
|
980 try: |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
23897
diff
changeset
|
981 if not fl.addgroup(source, revmap, trp): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
982 raise error.Abort(_("received file revlog group is empty")) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25624
diff
changeset
|
983 except error.CensoredBaseError as e: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
984 raise error.Abort(_("received delta base is censored: %s") % e) |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
985 revisions += len(fl) - o |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
986 if f in needfiles: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
987 needs = needfiles[f] |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
988 for new in xrange(o, len(fl)): |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
989 n = fl.node(new) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
990 if n in needs: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
991 needs.remove(n) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
992 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
993 raise error.Abort( |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
994 _("received spurious file revlog entry")) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
995 if not needs: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
996 del needfiles[f] |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
997 repo.ui.progress(_('files'), None) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
998 |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
999 for f, needs in needfiles.iteritems(): |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1000 fl = repo.file(f) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1001 for n in needs: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1002 try: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1003 fl.rev(n) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1004 except error.LookupError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
1005 raise error.Abort( |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1006 _('missing file data for %s:%s - run hg verify') % |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1007 (f, hex(n))) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1008 |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1009 return revisions, files |