Mercurial > hg-stable
annotate mercurial/changegroup.py @ 38943:cdb9bc216771
changegroup: declare shallow flag in constructor
Thus begins the process of better formalizing ellipses and shallow
changegroup generation mode so it is tracked by cgpacker at
construction time instead of bolted on after the fact by a
wrapper function.
Differential Revision: https://phab.mercurial-scm.org/D4086
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 03 Aug 2018 12:57:11 -0700 |
parents | 68e490ed640e |
children | 379d90327861 |
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 |
20933
d3775db748a0
localrepo: move the addchangegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20932
diff
changeset
|
12 import weakref |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
13 |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
14 from .i18n import _ |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
15 from .node import ( |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
16 hex, |
38922
ee1ea96cf9c9
changegroup: move ellipsisdata() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38874
diff
changeset
|
17 nullid, |
25921
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 |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
22 from .thirdparty import ( |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
23 attr, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
24 ) |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
25 |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
26 from . import ( |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
27 dagutil, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
28 error, |
38846
5742d0428ed9
changegroup: inline prune() logic from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38834
diff
changeset
|
29 manifest, |
38834
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
30 match as matchmod, |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
31 mdiff, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
32 phases, |
30945
82f1ef8b4477
py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30743
diff
changeset
|
33 pycompat, |
38874
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38846
diff
changeset
|
34 repository, |
38922
ee1ea96cf9c9
changegroup: move ellipsisdata() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38874
diff
changeset
|
35 revlog, |
25921
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
36 util, |
74b303a637bc
changegroup: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25831
diff
changeset
|
37 ) |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
38 |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
39 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
40 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
41 ) |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
42 |
38935
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
43 _CHANGEGROUPV1_DELTA_HEADER = struct.Struct("20s20s20s20s") |
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
44 _CHANGEGROUPV2_DELTA_HEADER = struct.Struct("20s20s20s20s20s") |
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
45 _CHANGEGROUPV3_DELTA_HEADER = struct.Struct(">20s20s20s20s20sH") |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
46 |
37135
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
47 LFS_REQUIREMENT = 'lfs' |
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
48 |
35754
fb0be099063f
util: move 'readexactly' in the util module
Boris Feld <boris.feld@octobus.net>
parents:
35051
diff
changeset
|
49 readexactly = util.readexactly |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
50 |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
51 def getchunk(stream): |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
52 """return the next chunk from stream as a string""" |
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
53 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
|
54 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
|
55 if l <= 4: |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
56 if l: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
57 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
|
58 return "" |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
59 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
|
60 |
5368
61462e7d62ed
changegroup: avoid large copies
Matt Mackall <mpm@selenic.com>
parents:
3932
diff
changeset
|
61 def chunkheader(length): |
9437
1c4e4004f3a6
Improve some docstrings relating to changegroups and prepush().
Greg Ward <greg-hg@gerg.ca>
parents:
9087
diff
changeset
|
62 """return a changegroup chunk header (string)""" |
5368
61462e7d62ed
changegroup: avoid large copies
Matt Mackall <mpm@selenic.com>
parents:
3932
diff
changeset
|
63 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
|
64 |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
65 def closechunk(): |
9437
1c4e4004f3a6
Improve some docstrings relating to changegroups and prepush().
Greg Ward <greg-hg@gerg.ca>
parents:
9087
diff
changeset
|
66 """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
|
67 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
|
68 |
26540
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
69 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
|
70 """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
|
71 |
26540
7469067de2ba
changegroup: extract the file management part in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26509
diff
changeset
|
72 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
|
73 Existing files will not be overwritten. |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
74 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
|
75 """ |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
76 fh = None |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
77 cleanup = None |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
78 try: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 else: |
30212
260af19891f2
changegroup: increase write buffer size to 128k
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30211
diff
changeset
|
83 # 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
|
84 # small (4k is common on Linux). |
260af19891f2
changegroup: increase write buffer size to 128k
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30211
diff
changeset
|
85 fh = open(filename, "wb", 131072) |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
86 else: |
38197
aac4be30e250
py3: wrap tempfile.mkstemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
37339
diff
changeset
|
87 fd, filename = pycompat.mkstemp(prefix="hg-bundle-", suffix=".hg") |
36843
5bc7ff103081
py3: use r'' instead of sysstr('') to get around code transformer
Yuya Nishihara <yuya@tcha.org>
parents:
36768
diff
changeset
|
88 fh = os.fdopen(fd, r"wb") |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
89 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
|
90 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
|
91 fh.write(c) |
3659
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
92 cleanup = None |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
93 return filename |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
94 finally: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
95 if fh is not None: |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
96 fh.close() |
025f68f22ae2
move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents:
2470
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 else: |
c20f4898631e
changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20966
diff
changeset
|
101 os.unlink(cleanup) |
3660
8500a13ec44b
create a readbundle function
Matt Mackall <mpm@selenic.com>
parents:
3659
diff
changeset
|
102 |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
103 class cg1unpacker(object): |
26708
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
104 """Unpacker for cg1 changegroup streams. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
105 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 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
|
114 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
115 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
|
116 consumers should prefer apply() instead. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
117 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
118 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
|
119 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
|
120 """ |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22070
diff
changeset
|
121 deltaheader = _CHANGEGROUPV1_DELTA_HEADER |
38935
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
122 deltaheadersize = deltaheader.size |
23896
becfecaf9087
changegroup.writebundle: HG2Y support
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
123 version = '01' |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
124 _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
|
125 |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
126 def __init__(self, fh, alg, extras=None): |
30364
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30349
diff
changeset
|
127 if alg is None: |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30349
diff
changeset
|
128 alg = 'UN' |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30349
diff
changeset
|
129 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
|
130 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
|
131 % 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
|
132 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
|
133 alg = '_truncatedBZ' |
30364
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30349
diff
changeset
|
134 |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30349
diff
changeset
|
135 compengine = util.compengines.forbundletype(alg) |
a37a96d838b9
changegroup: use compression engines API
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30349
diff
changeset
|
136 self._stream = compengine.decompressorreader(fh) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
12043
diff
changeset
|
137 self._type = alg |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
138 self.extras = extras or {} |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
139 self.callback = None |
26706
8c0c3059f478
changegroup: note why a few methods on cg1unpacker exist
Augie Fackler <augie@google.com>
parents:
26704
diff
changeset
|
140 |
8c0c3059f478
changegroup: note why a few methods on cg1unpacker exist
Augie Fackler <augie@google.com>
parents:
26704
diff
changeset
|
141 # 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
|
142 # 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
|
143 def compressed(self): |
30594
182cacaa4c32
cg1packer: fix `compressed` method
Stanislau Hlebik <stash@fb.com>
parents:
30364
diff
changeset
|
144 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
|
145 def read(self, l): |
bef5effb3db0
bundle: introduce bundle class
Matt Mackall <mpm@selenic.com>
parents:
12042
diff
changeset
|
146 return self._stream.read(l) |
12330
e527b8635881
bundle: make unbundle object seekable
Matt Mackall <mpm@selenic.com>
parents:
12329
diff
changeset
|
147 def seek(self, pos): |
e527b8635881
bundle: make unbundle object seekable
Matt Mackall <mpm@selenic.com>
parents:
12329
diff
changeset
|
148 return self._stream.seek(pos) |
e527b8635881
bundle: make unbundle object seekable
Matt Mackall <mpm@selenic.com>
parents:
12329
diff
changeset
|
149 def tell(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12330
diff
changeset
|
150 return self._stream.tell() |
12347
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12336
diff
changeset
|
151 def close(self): |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12336
diff
changeset
|
152 return self._stream.close() |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
153 |
26707
5ee6bd529300
changegroup: mark cg1unpacker.chunklength as private
Augie Fackler <augie@google.com>
parents:
26706
diff
changeset
|
154 def _chunklength(self): |
13459
acbe171c8fbe
changegroup: fix typo introduced in 9f2c407caf34
Jim Hague <jim.hague@acm.org>
parents:
13458
diff
changeset
|
155 d = readexactly(self._stream, 4) |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
156 l = struct.unpack(">l", d)[0] |
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
157 if l <= 4: |
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
158 if l: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
159 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
|
160 return 0 |
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
161 if self.callback: |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
162 self.callback() |
13458
9f2c407caf34
changegroup: don't accept odd chunk headers
Mads Kiilerich <mads@kiilerich.com>
parents:
13457
diff
changeset
|
163 return l - 4 |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
164 |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
165 def changelogheader(self): |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
166 """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
|
167 return {} |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
168 |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
169 def manifestheader(self): |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
170 """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
|
171 return {} |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
172 |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
173 def filelogheader(self): |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
174 """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
|
175 l = self._chunklength() |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
176 if not l: |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
177 return {} |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
178 fname = readexactly(self._stream, l) |
20675
f8d50add83e1
changegroup: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
19708
diff
changeset
|
179 return {'filename': fname} |
12334
50946802593d
bundle: refactor progress callback
Matt Mackall <mpm@selenic.com>
parents:
12333
diff
changeset
|
180 |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 deltabase = p1 |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
185 else: |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
186 deltabase = prevnode |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
187 flags = 0 |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
188 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
|
189 |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14143
diff
changeset
|
190 def deltachunk(self, prevnode): |
26707
5ee6bd529300
changegroup: mark cg1unpacker.chunklength as private
Augie Fackler <augie@google.com>
parents:
26706
diff
changeset
|
191 l = self._chunklength() |
12336
9d234f7d8a77
bundle: move chunk parsing into unbundle class
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
192 if not l: |
9d234f7d8a77
bundle: move chunk parsing into unbundle class
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
193 return {} |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
194 headerdata = readexactly(self._stream, self.deltaheadersize) |
38935
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
195 header = self.deltaheader.unpack(headerdata) |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14060
diff
changeset
|
196 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
|
197 node, p1, p2, deltabase, cs, flags = self._deltaheader(header, prevnode) |
34301
05131c963767
changegroup: remove dictionary creation from deltachunk
Durham Goode <durham@fb.com>
parents:
34298
diff
changeset
|
198 return (node, p1, p2, cs, deltabase, delta, flags) |
12336
9d234f7d8a77
bundle: move chunk parsing into unbundle class
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
199 |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
200 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
|
201 """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
|
202 |
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 """ |
34106
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
207 # For changegroup 1 and 2, we expect 3 parts: changelog, manifestlog, |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
208 # and a list of filelogs. For changegroup 3, we expect 4 parts: |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
209 # changelog, manifestlog, a list of tree manifestlogs, and a list of |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
210 # filelogs. |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
211 # |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
212 # Changelog and manifestlog parts are terminated with empty chunks. The |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
213 # tree and file parts are a list of entry sections. Each entry section |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
214 # is a series of chunks terminating in an empty chunk. The list of these |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
215 # entry sections is terminated in yet another empty chunk, so we know |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
216 # we've reached the end of the tree/file list when we reach an empty |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
217 # chunk that was proceeded by no non-empty chunks. |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
218 |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
219 parts = 0 |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
220 while parts < 2 + self._grouplistcount: |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
221 noentries = True |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
222 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
|
223 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
|
224 if not chunk: |
34106
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
225 # The first two empty chunks represent the end of the |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
226 # changelog and the manifestlog portions. The remaining |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
227 # empty chunks represent either A) the end of individual |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
228 # tree or file entries in the file list, or B) the end of |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
229 # the entire list. It's the end of the entire list if there |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
230 # were no entries (i.e. noentries is True). |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
231 if parts < 2: |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
232 parts += 1 |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
233 elif noentries: |
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
234 parts += 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
|
235 break |
34106
bbdca7e460c0
changegroup: fix to allow empty manifest parts
Durham Goode <durham@fb.com>
parents:
33738
diff
changeset
|
236 noentries = False |
20999
1e28ec9744bf
changegroup: move chunk extraction into a getchunks method of unbundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20978
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 |
38352
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
245 def _unpackmanifests(self, repo, revmap, trp, prog): |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
246 self.callback = prog.increment |
26712
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
247 # 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
|
248 # 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
|
249 # 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
|
250 # be empty during the pull |
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
251 self.manifestheader() |
34298
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
252 deltas = self.deltaiter() |
38557
0db41eb0a3ac
manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38416
diff
changeset
|
253 repo.manifestlog.addgroup(deltas, revmap, trp) |
38379
ef692614e601
progress: hide update(None) in a new complete() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
38352
diff
changeset
|
254 prog.complete() |
28360
11287888ce4b
changegroup: exclude submanifests from manifest progress
Martin von Zweigbergk <martinvonz@google.com>
parents:
28281
diff
changeset
|
255 self.callback = None |
26712
04176eaf911b
changegroup: move manifest unpacking into its own method
Augie Fackler <augie@google.com>
parents:
26711
diff
changeset
|
256 |
33308
248d5890c80a
changegroup: remove option to allow empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33227
diff
changeset
|
257 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
|
258 expectedtotal=None): |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
259 """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
|
260 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
|
261 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
|
262 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
263 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
|
264 - 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
|
265 - 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
|
266 - 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
|
267 - 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
|
268 """ |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
269 repo = repo.unfiltered() |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
270 def csmap(x): |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
271 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
|
272 return len(cl) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
273 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
274 def revmap(x): |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
275 return cl.rev(x) |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
276 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
277 changesets = files = revisions = 0 |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
278 |
26880
fa7f8b686633
changegroup: fix the scope of a try finally
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26859
diff
changeset
|
279 try: |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
280 # The transaction may already carry source information. In this |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
281 # 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:
32948
diff
changeset
|
282 # 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:
32948
diff
changeset
|
283 # in this function. |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
284 srctype = tr.hookargs.setdefault('source', srctype) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
285 url = tr.hookargs.setdefault('url', url) |
33697
38fc45721334
changegroup: wrap some ** expansions in strkwargs
Augie Fackler <augie@google.com>
parents:
33461
diff
changeset
|
286 repo.hook('prechangegroup', |
38fc45721334
changegroup: wrap some ** expansions in strkwargs
Augie Fackler <augie@google.com>
parents:
33461
diff
changeset
|
287 throw=True, **pycompat.strkwargs(tr.hookargs)) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
288 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
289 # write changelog data to temp files so concurrent readers |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
290 # will not see an inconsistent view |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
291 cl = repo.changelog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
292 cl.delayupdate(tr) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
293 oldheads = set(cl.heads()) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
294 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
295 trp = weakref.proxy(tr) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
296 # pull off the changeset group |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
297 repo.ui.status(_("adding changesets\n")) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
298 clstart = len(cl) |
38352
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
299 progress = repo.ui.makeprogress(_('changesets'), unit=_('chunks'), |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
300 total=expectedtotal) |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
301 self.callback = progress.increment |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
302 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
303 efiles = set() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
304 def onchangelog(cl, node): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
305 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
|
306 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
307 self.changelogheader() |
34298
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
308 deltas = self.deltaiter() |
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
309 cgnodes = cl.addgroup(deltas, csmap, trp, addrevisioncb=onchangelog) |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
310 efiles = len(efiles) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
311 |
33308
248d5890c80a
changegroup: remove option to allow empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33227
diff
changeset
|
312 if not cgnodes: |
33309
69c4493a54f9
changegroup: don't fail on empty changegroup (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33308
diff
changeset
|
313 repo.ui.develwarn('applied empty changegroup', |
34734
3572b2031cec
devel-warn: add 'warn-' to 'devel.empty-changegroup' config
Boris Feld <boris.feld@octobus.net>
parents:
34301
diff
changeset
|
314 config='warn-empty-changegroup') |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
315 clend = len(cl) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
316 changesets = clend - clstart |
38379
ef692614e601
progress: hide update(None) in a new complete() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
38352
diff
changeset
|
317 progress.complete() |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
318 self.callback = None |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
319 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
320 # pull off the manifest group |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
321 repo.ui.status(_("adding manifests\n")) |
38352
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
322 # We know that we'll never have more manifests than we had |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
323 # changesets. |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
324 progress = repo.ui.makeprogress(_('manifests'), unit=_('chunks'), |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
325 total=changesets) |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
326 self._unpackmanifests(repo, revmap, trp, progress) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
327 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
328 needfiles = {} |
33227
86c9aa1d598f
configitems: register the 'server.validate' config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33185
diff
changeset
|
329 if repo.ui.configbool('server', 'validate'): |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
330 cl = repo.changelog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
331 ml = repo.manifestlog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
332 # validate incoming csets have their manifests |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38557
diff
changeset
|
333 for cset in pycompat.xrange(clstart, clend): |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
334 mfnode = cl.changelogrevision(cset).manifest |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
335 mfest = ml[mfnode].readdelta() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
336 # store file cgnodes we must see |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
337 for f, n in mfest.iteritems(): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
338 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
|
339 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
340 # process the files |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
341 repo.ui.status(_("adding file changes\n")) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
342 newrevs, newfiles = _addchangegroupfiles( |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
343 repo, self, revmap, trp, efiles, needfiles) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
344 revisions += newrevs |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
345 files += newfiles |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
346 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
347 deltaheads = 0 |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
348 if oldheads: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
349 heads = cl.heads() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
350 deltaheads = len(heads) - len(oldheads) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
351 for h in heads: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
352 if h not in oldheads and repo[h].closesbranch(): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
353 deltaheads -= 1 |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
354 htext = "" |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
355 if deltaheads: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
356 htext = _(" (%+d heads)") % deltaheads |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
357 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
358 repo.ui.status(_("added %d changesets" |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
359 " with %d changes to %d files%s\n") |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
360 % (changesets, revisions, files, htext)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
361 repo.invalidatevolatilesets() |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
362 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
363 if changesets > 0: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
364 if 'node' not in tr.hookargs: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
365 tr.hookargs['node'] = hex(cl.node(clstart)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
366 tr.hookargs['node_last'] = hex(cl.node(clend - 1)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
367 hookargs = dict(tr.hookargs) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
368 else: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
369 hookargs = dict(tr.hookargs) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
370 hookargs['node'] = hex(cl.node(clstart)) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
371 hookargs['node_last'] = hex(cl.node(clend - 1)) |
33697
38fc45721334
changegroup: wrap some ** expansions in strkwargs
Augie Fackler <augie@google.com>
parents:
33461
diff
changeset
|
372 repo.hook('pretxnchangegroup', |
38fc45721334
changegroup: wrap some ** expansions in strkwargs
Augie Fackler <augie@google.com>
parents:
33461
diff
changeset
|
373 throw=True, **pycompat.strkwargs(hookargs)) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
374 |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38557
diff
changeset
|
375 added = [cl.node(r) for r in pycompat.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
|
376 phaseall = None |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
377 if srctype in ('push', 'serve'): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
378 # Old servers can not push the boundary themselves. |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
379 # New servers won't push the boundary if changeset already |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
380 # exists locally as secret |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
381 # |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
382 # 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:
32948
diff
changeset
|
383 # the bundle |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
384 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
|
385 targetphase = phaseall = phases.public |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
386 else: |
33456
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
387 # 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
|
388 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
389 # Those changesets have been pushed from the |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
390 # outside, their phases are going to be pushed |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
391 # alongside. Therefor `targetphase` is |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
392 # ignored. |
33456
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
393 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
|
394 if added: |
ae052d04b89e
phases: rework phase movement code in 'cg.apply' to use 'registernew'
Boris Feld <boris.feld@octobus.net>
parents:
33406
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
399 if changesets > 0: |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
400 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
401 def runhooks(): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
402 # These hooks run when the lock releases, not when the |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
403 # transaction closes. So it's possible for the changelog |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
404 # to have changed since we last saw it. |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
405 if clstart >= len(repo): |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
406 return |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
407 |
33738
672ad4f3bb84
changegroup: more **kwargs
Augie Fackler <augie@google.com>
parents:
33697
diff
changeset
|
408 repo.hook("changegroup", **pycompat.strkwargs(hookargs)) |
27867
7ced54ebf972
with: use context manager for transaction in changegroup apply
Bryan O'Sullivan <bryano@fb.com>
parents:
27754
diff
changeset
|
409 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
410 for n in added: |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
411 args = hookargs.copy() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
412 args['node'] = hex(n) |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
413 del args['node_last'] |
33738
672ad4f3bb84
changegroup: more **kwargs
Augie Fackler <augie@google.com>
parents:
33697
diff
changeset
|
414 repo.hook("incoming", **pycompat.strkwargs(args)) |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
415 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
416 newheads = [h for h in repo.heads() |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
417 if h not in oldheads] |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
418 repo.ui.log("incoming", |
36760
2a5024109490
py3: fix int formatting of "incoming changes" log
Yuya Nishihara <yuya@tcha.org>
parents:
36495
diff
changeset
|
419 "%d incoming changes - new heads: %s\n", |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
420 len(added), |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
421 ', '.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
|
422 |
32949
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
423 tr.addpostclose('changegroup-runhooks-%020i' % clstart, |
b08431e1b062
changegroup: delete "if True" and reflow
Martin von Zweigbergk <martinvonz@google.com>
parents:
32948
diff
changeset
|
424 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
|
425 finally: |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
426 repo.ui.flush() |
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
427 # never return 0 here: |
32888
b441296f8e9c
changegroup: rename "dh" to the clearer "deltaheads"
Martin von Zweigbergk <martinvonz@google.com>
parents:
32887
diff
changeset
|
428 if deltaheads < 0: |
33042
3e102a8dd52c
bundle2: record changegroup data in 'op.records' (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32949
diff
changeset
|
429 ret = deltaheads - 1 |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
430 else: |
33042
3e102a8dd52c
bundle2: record changegroup data in 'op.records' (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32949
diff
changeset
|
431 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
|
432 return ret |
26695
1121fced5b20
changegroup: migrate addchangegroup() to forward to cg?unpacker.apply()
Augie Fackler <augie@google.com>
parents:
26694
diff
changeset
|
433 |
34298
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
434 def deltaiter(self): |
34160
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
435 """ |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
436 returns an iterator of the deltas in this changegroup |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
437 |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
438 Useful for passing to the underlying storage system to be stored. |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
439 """ |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
440 chain = None |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
441 for chunkdata in iter(lambda: self.deltachunk(chain), {}): |
34301
05131c963767
changegroup: remove dictionary creation from deltachunk
Durham Goode <durham@fb.com>
parents:
34298
diff
changeset
|
442 # Chunkdata: (node, p1, p2, cs, deltabase, delta, flags) |
05131c963767
changegroup: remove dictionary creation from deltachunk
Durham Goode <durham@fb.com>
parents:
34298
diff
changeset
|
443 yield chunkdata |
05131c963767
changegroup: remove dictionary creation from deltachunk
Durham Goode <durham@fb.com>
parents:
34298
diff
changeset
|
444 chain = chunkdata[0] |
34160
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34118
diff
changeset
|
445 |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
446 class cg2unpacker(cg1unpacker): |
26708
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
447 """Unpacker for cg2 streams. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
448 |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
449 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
|
450 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
|
451 remain the same. |
749d913f24b8
changegroup: document the public surface area of cg?unpackers
Augie Fackler <augie@google.com>
parents:
26707
diff
changeset
|
452 """ |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
453 deltaheader = _CHANGEGROUPV2_DELTA_HEADER |
38935
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
454 deltaheadersize = deltaheader.size |
23896
becfecaf9087
changegroup.writebundle: HG2Y support
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
455 version = '02' |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
456 |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
457 def _deltaheader(self, headertuple, prevnode): |
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
458 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
|
459 flags = 0 |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
460 return node, p1, p2, deltabase, cs, flags |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
461 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
462 class cg3unpacker(cg2unpacker): |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
463 """Unpacker for cg3 streams. |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
464 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
465 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
|
466 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
|
467 separating manifests and files. |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
468 """ |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
469 deltaheader = _CHANGEGROUPV3_DELTA_HEADER |
38935
271854adc3a6
changegroup: make delta header struct formatters actual structs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38934
diff
changeset
|
470 deltaheadersize = deltaheader.size |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
471 version = '03' |
27920
da5f23362517
changegroup: cg3 has two empty groups *after* manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27867
diff
changeset
|
472 _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
|
473 |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
474 def _deltaheader(self, headertuple, prevnode): |
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
27432
diff
changeset
|
475 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
|
476 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
|
477 |
38352
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
478 def _unpackmanifests(self, repo, revmap, trp, prog): |
83534c4ec58b
changegroup: use progress helper in apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38197
diff
changeset
|
479 super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog) |
29736
4e7be6e33269
changegroup: use `iter(callable, sentinel)` instead of while True
Augie Fackler <augie@google.com>
parents:
29704
diff
changeset
|
480 for chunkdata in iter(self.filelogheader, {}): |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
481 # 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
|
482 d = chunkdata["filename"] |
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
483 repo.ui.debug("adding %s revisions\n" % d) |
30349
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30308
diff
changeset
|
484 dirlog = repo.manifestlog._revlog.dirlog(d) |
34298
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
485 deltas = self.deltaiter() |
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
486 if not dirlog.addgroup(deltas, revmap, trp): |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
487 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
|
488 |
12329
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
489 class headerlessfixup(object): |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
490 def __init__(self, fh, h): |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
491 self._h = h |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
492 self._fh = fh |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
493 def read(self, n): |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
494 if self._h: |
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
495 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
|
496 if len(d) < n: |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
497 d += readexactly(self._fh, n - len(d)) |
12329
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
498 return d |
13457
e74fe15dc7fd
changegroup: verify all stream reads
Mads Kiilerich <mads@kiilerich.com>
parents:
13456
diff
changeset
|
499 return readexactly(self._fh, n) |
12329
7458de933f26
bundle: push chunkbuffer down into decompress
Matt Mackall <mpm@selenic.com>
parents:
12044
diff
changeset
|
500 |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
501 @attr.s(slots=True, frozen=True) |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
502 class revisiondelta(object): |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
503 """Describes a delta entry in a changegroup. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
504 |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
505 Captured data is sufficient to serialize the delta into multiple |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
506 formats. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
507 """ |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
508 # 20 byte node of this revision. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
509 node = attr.ib() |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
510 # 20 byte nodes of parent revisions. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
511 p1node = attr.ib() |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
512 p2node = attr.ib() |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
513 # 20 byte node of node this delta is against. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
514 basenode = attr.ib() |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
515 # 20 byte node of changeset revision this delta is associated with. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
516 linknode = attr.ib() |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
517 # 2 bytes of flags to apply to revision data. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
518 flags = attr.ib() |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
519 # Iterable of chunks holding raw delta data. |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
520 deltachunks = attr.ib() |
38922
ee1ea96cf9c9
changegroup: move ellipsisdata() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38874
diff
changeset
|
521 |
38941
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
522 class cgpacker(object): |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
523 def __init__(self, repo, filematcher, version, allowreorder, |
38940
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
524 useprevdelta, builddeltaheader, manifestsend, |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
525 sendtreemanifests, bundlecaps=None, shallow=False): |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
526 """Given a source repo, construct a bundler. |
32327
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
527 |
38834
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
528 filematcher is a matcher that matches on files to include in the |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
529 changegroup. Used to facilitate sparse changegroups. |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
530 |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
531 allowreorder controls whether reordering of revisions is allowed. |
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
532 This value is used when ``bundle.reorder`` is ``auto`` or isn't |
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
533 set. |
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
534 |
38940
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
535 useprevdelta controls whether revisions should always delta against |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
536 the previous revision in the changegroup. |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
537 |
38936
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
538 builddeltaheader is a callable that constructs the header for a group |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
539 delta. |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
540 |
38937
67f37e8a5490
changegroup: pass end of manifests marker into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38936
diff
changeset
|
541 manifestsend is a chunk to send after manifests have been fully emitted. |
67f37e8a5490
changegroup: pass end of manifests marker into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38936
diff
changeset
|
542 |
38938
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
543 sendtreemanifests indicates whether tree manifests should be emitted. |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
544 |
32327
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
545 bundlecaps is optional and can be used to specify the set of |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
546 capabilities which can be used to build the bundle. While bundlecaps is |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
547 unused in core Mercurial, extensions rely on this feature to communicate |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
548 capabilities to customize the changegroup packer. |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
549 |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
550 shallow indicates whether shallow data might be sent. The packer may |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
551 need to pack file contents not introduced by the changes being packed. |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
552 """ |
38834
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
553 assert filematcher |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
554 self._filematcher = filematcher |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
555 |
38934
d7ac49c2353c
changegroup: pass version into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38933
diff
changeset
|
556 self.version = version |
38940
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
557 self._useprevdelta = useprevdelta |
38936
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
558 self._builddeltaheader = builddeltaheader |
38937
67f37e8a5490
changegroup: pass end of manifests marker into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38936
diff
changeset
|
559 self._manifestsend = manifestsend |
38938
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
560 self._sendtreemanifests = sendtreemanifests |
38934
d7ac49c2353c
changegroup: pass version into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38933
diff
changeset
|
561 |
32327
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
562 # Set of capabilities we can use to build the bundle. |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
563 if bundlecaps is None: |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
564 bundlecaps = set() |
df3cf9422e1b
changegroup: add bundlecaps back
Durham Goode <durham@fb.com>
parents:
32308
diff
changeset
|
565 self._bundlecaps = bundlecaps |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
566 self._isshallow = shallow |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
567 |
25831
578fc97904da
generaldelta: mark experimental reordering option
Matt Mackall <mpm@selenic.com>
parents:
25823
diff
changeset
|
568 # experimental config: bundle.reorder |
33185
9f95f0bb343b
configitems: register the 'bundle.reorder' config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33048
diff
changeset
|
569 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
|
570 if reorder == 'auto': |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
571 self._reorder = allowreorder |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
572 else: |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
573 self._reorder = stringutil.parsebool(reorder) |
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
574 |
19202
0455fc94ae00
bundle-ng: move gengroup into bundler, pass repo object to bundler
Sune Foldager <cryo@cyanite.org>
parents:
19201
diff
changeset
|
575 self._repo = repo |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
576 |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
577 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
|
578 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
|
579 else: |
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
580 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
|
581 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
582 def _close(self): |
38926
75d6139e69f9
changegroup: move close() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38925
diff
changeset
|
583 # Ellipses serving mode. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
584 getattr(self, '_clrev_to_localrev', {}).clear() |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
585 if getattr(self, '_next_clrev_to_localrev', {}): |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
586 self._clrev_to_localrev = self._next_clrev_to_localrev |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
587 del self._next_clrev_to_localrev |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
588 self._changelog_done = True |
38926
75d6139e69f9
changegroup: move close() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38925
diff
changeset
|
589 |
13831
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
590 return closechunk() |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
591 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
592 def _fileheader(self, fname): |
13831
d69c9510d648
changegroup: introduce bundler objects
Matt Mackall <mpm@selenic.com>
parents:
13786
diff
changeset
|
593 return chunkheader(len(fname)) + fname |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
594 |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
595 # Extracted both for clarity and for overriding in extensions. |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
596 def _sortgroup(self, store, nodelist, lookup): |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
597 """Sort nodes for change group and turn them into revnums.""" |
38927
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
598 # Ellipses serving mode. |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
599 # |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
600 # In a perfect world, we'd generate better ellipsis-ified graphs |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
601 # for non-changelog revlogs. In practice, we haven't started doing |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
602 # that yet, so the resulting DAGs for the manifestlog and filelogs |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
603 # are actually full of bogus parentage on all the ellipsis |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
604 # nodes. This has the side effect that, while the contents are |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
605 # correct, the individual DAGs might be completely out of whack in |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
606 # a case like 882681bc3166 and its ancestors (back about 10 |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
607 # revisions or so) in the main hg repo. |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
608 # |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
609 # The one invariant we *know* holds is that the new (potentially |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
610 # bogus) DAG shape will be valid if we order the nodes in the |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
611 # order that they're introduced in dramatis personae by the |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
612 # changelog, so what we do is we sort the non-changelog histories |
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
613 # by the order in which they are used by the changelog. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
614 if util.safehasattr(self, '_full_nodes') and self._clnode_to_rev: |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
615 key = lambda n: self._clnode_to_rev[lookup(n)] |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
616 return [store.rev(n) for n in sorted(nodelist, key=key)] |
38927
c9315bc578bc
changegroup: move _sortgroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38926
diff
changeset
|
617 |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
618 # 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
|
619 # much quicker and generate a much smaller bundle |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
620 if (store._generaldelta and self._reorder is None) or self._reorder: |
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
621 dag = dagutil.revlogdag(store) |
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
622 return dag.linearize(set(store.rev(n) for n in nodelist)) |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
623 else: |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
624 return sorted([store.rev(n) for n in nodelist]) |
29236
1b7d907ec18a
changegroup: extract method that sorts nodes to send
Augie Fackler <augie@google.com>
parents:
28666
diff
changeset
|
625 |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
626 def group(self, nodelist, store, lookup, units=None): |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
627 """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
|
628 (strings). |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
629 |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 |
0b564cf359a7
bundle-ng: move progress handling out of the linkrev callback
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19207
diff
changeset
|
637 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
|
638 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
|
639 """ |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
640 # 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
|
641 if len(nodelist) == 0: |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
642 yield self._close() |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
643 return |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
644 |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
645 revs = self._sortgroup(store, nodelist, lookup) |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
646 |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
647 # add the parent of the first rev |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
648 p = store.parentrevs(revs[0])[0] |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
649 revs.insert(0, p) |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
650 |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
651 # build deltas |
38416
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
652 progress = None |
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
653 if units is not None: |
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
654 progress = self._repo.ui.makeprogress(_('bundling'), unit=units, |
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
655 total=(len(revs) - 1)) |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38557
diff
changeset
|
656 for r in pycompat.xrange(len(revs) - 1): |
38416
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
657 if progress: |
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
658 progress.update(r + 1) |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
659 prev, curr = revs[r], revs[r + 1] |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
660 linknode = lookup(store.node(curr)) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
661 for c in self._revchunk(store, curr, prev, linknode): |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
662 yield c |
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
663 |
38416
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
664 if progress: |
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
665 progress.complete() |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
666 yield self._close() |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
667 |
19289
6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Durham Goode <durham@fb.com>
parents:
19208
diff
changeset
|
668 # filter any nodes that claim to be part of the known set |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
669 def _prune(self, store, missing, commonrevs): |
38846
5742d0428ed9
changegroup: inline prune() logic from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38834
diff
changeset
|
670 # TODO this violates storage abstraction for manifests. |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
671 if isinstance(store, manifest.manifestrevlog): |
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
672 if not self._filematcher.visitdir(store._dir[:-1] or '.'): |
38846
5742d0428ed9
changegroup: inline prune() logic from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38834
diff
changeset
|
673 return [] |
5742d0428ed9
changegroup: inline prune() logic from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38834
diff
changeset
|
674 |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
675 rr, rl = store.rev, store.linkrev |
19289
6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Durham Goode <durham@fb.com>
parents:
19208
diff
changeset
|
676 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
|
677 |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
678 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
|
679 """Pack flat manifests into a changegroup stream.""" |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
680 assert not dir |
30349
6cdfb7e15a35
changegroup: remove remaining uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30308
diff
changeset
|
681 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
|
682 lookuplinknode, units=_('manifests')): |
26711
0ef0aec56090
changegroup: move manifest packing into a separate function
Augie Fackler <augie@google.com>
parents:
26710
diff
changeset
|
683 yield chunk |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
684 |
38938
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
685 def _packtreemanifests(self, dir, mfnodes, lookuplinknode): |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
686 """Version of _packmanifests that operates on directory manifests. |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
687 |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
688 Encodes the directory name in the output so multiple manifests |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
689 can be sent. |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
690 """ |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
691 assert self.version == b'03' |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
692 |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
693 if dir: |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
694 yield self._fileheader(dir) |
38938
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
695 |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
696 # TODO violates storage abstractions by assuming revlogs. |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
697 dirlog = self._repo.manifestlog._revlog.dirlog(dir) |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
698 for chunk in self.group(mfnodes, dirlog, lookuplinknode, |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
699 units=_('manifests')): |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
700 yield chunk |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
701 |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
702 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
|
703 '''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
|
704 repo = self._repo |
24978
f52560c64953
changegroup: drop _changelog and _manifest properties
Martin von Zweigbergk <martinvonz@google.com>
parents:
24977
diff
changeset
|
705 cl = repo.changelog |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
706 |
23381
cc0ff93d0c0c
changegroup: fix file linkrevs during reorders (issue4462)
Durham Goode <durham@fb.com>
parents:
23226
diff
changeset
|
707 clrevorder = {} |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
708 mfs = {} # needed manifests |
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
709 fnodes = {} # needed file nodes |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
710 mfl = repo.manifestlog |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
711 # TODO violates storage abstraction. |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
712 mfrevlog = mfl._revlog |
28241
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
713 changedfiles = set() |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
714 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
715 ellipsesmode = util.safehasattr(self, '_full_nodes') |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
716 |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
717 # Callback for the changelog, used to collect changed files and |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
718 # manifest nodes. |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
719 # 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
|
720 def lookupcl(x): |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
721 c = cl.read(x) |
23381
cc0ff93d0c0c
changegroup: fix file linkrevs during reorders (issue4462)
Durham Goode <durham@fb.com>
parents:
23226
diff
changeset
|
722 clrevorder[x] = len(clrevorder) |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
723 |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
724 if ellipsesmode: |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
725 # Only update mfs if x is going to be sent. Otherwise we |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
726 # end up with bogus linkrevs specified for manifests and |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
727 # we skip some manifest nodes that we should otherwise |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
728 # have sent. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
729 if (x in self._full_nodes |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
730 or cl.rev(x) in self._precomputed_ellipsis): |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
731 n = c[0] |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
732 # Record the first changeset introducing this manifest |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
733 # version. |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
734 mfs.setdefault(n, x) |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
735 # Set this narrow-specific dict so we have the lowest |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
736 # manifest revnum to look up for this cl revnum. (Part of |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
737 # mapping changelog ellipsis parents to manifest ellipsis |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
738 # parents) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
739 self._next_clrev_to_localrev.setdefault(cl.rev(x), |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
740 mfrevlog.rev(n)) |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
741 # We can't trust the changed files list in the changeset if the |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
742 # client requested a shallow clone. |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
743 if self._isshallow: |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
744 changedfiles.update(mfl[c[0]].read().keys()) |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
745 else: |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
746 changedfiles.update(c[3]) |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
747 else: |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
748 |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
749 n = c[0] |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
750 # record the first changeset introducing this manifest version |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
751 mfs.setdefault(n, x) |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
752 # Record a complete list of potentially-changed files in |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
753 # this manifest. |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
754 changedfiles.update(c[3]) |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
755 |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
756 return x |
19204
e9c5b1c246dc
bundle-ng: move bundle generation to changegroup.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19202
diff
changeset
|
757 |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
758 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
|
759 size = 0 |
24912
e285b98c65cc
changegroup.group: drop 'reorder' parameter
Martin von Zweigbergk <martinvonz@google.com>
parents:
24911
diff
changeset
|
760 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
|
761 size += len(chunk) |
23224
f4ab47ccefde
changegroup: don't define lookupmf() until it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22971
diff
changeset
|
762 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
|
763 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
|
764 |
24977
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
765 # 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
|
766 # 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
|
767 # 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
|
768 # are walked in revlog order. |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
769 # |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
770 # 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
|
771 # 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
|
772 # 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
|
773 # cc0ff93d0c0c). |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
774 # |
4289383cb9d2
changegroup: document the cases where reordering complicates linkrevs
Martin von Zweigbergk <martinvonz@google.com>
parents:
24976
diff
changeset
|
775 # 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
|
776 # 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
|
777 # 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
|
778 # 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
|
779 # This was also fixed in cc0ff93d0c0c. |
24976
147d8892fc4b
changegroup: extract condition for linkrev fastpath
Martin von Zweigbergk <martinvonz@google.com>
parents:
24912
diff
changeset
|
780 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
|
781 # 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
|
782 # 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
|
783 # 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
|
784 fastpathlinkrev = fastpathlinkrev and ( |
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
785 'treemanifest' not in repo.requirements) |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
786 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
787 for chunk in self.generatemanifests(commonrevs, clrevorder, |
34161
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
788 fastpathlinkrev, mfs, fnodes, source): |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
789 yield chunk |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
790 |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
791 if ellipsesmode: |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
792 mfdicts = None |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
793 if self._isshallow: |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
794 mfdicts = [(self._repo.manifestlog[n].read(), lr) |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
795 for (n, lr) in mfs.iteritems()] |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
796 |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
797 mfs.clear() |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
798 clrevs = set(cl.rev(x) for x in clnodes) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
799 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
800 if not fastpathlinkrev: |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
801 def linknodes(unused, fname): |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
802 return fnodes.get(fname, {}) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
803 else: |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
804 cln = cl.node |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
805 def linknodes(filerevlog, fname): |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
806 llr = filerevlog.linkrev |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
807 fln = filerevlog.node |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
808 revs = ((r, llr(r)) for r in filerevlog) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
809 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
|
810 |
38929
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
811 if ellipsesmode: |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
812 # We need to pass the mfdicts variable down into |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
813 # generatefiles(), but more than one command might have |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
814 # wrapped generatefiles so we can't modify the function |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
815 # signature. Instead, we pass the data to ourselves using an |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
816 # instance attribute. I'm sorry. |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
817 self._mfdicts = mfdicts |
d706c77449f9
changegroup: move generate() modifications from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38928
diff
changeset
|
818 |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
819 for chunk in self.generatefiles(changedfiles, linknodes, commonrevs, |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
820 source): |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
821 yield chunk |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
822 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
823 yield self._close() |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
824 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
825 if clnodes: |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
826 repo.hook('outgoing', node=hex(clnodes[0]), source=source) |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
827 |
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
828 def generatemanifests(self, commonrevs, clrevorder, fastpathlinkrev, mfs, |
34161
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
829 fnodes, source): |
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
830 """Returns an iterator of changegroup chunks containing manifests. |
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
831 |
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
832 `source` is unused here, but is used by extensions like remotefilelog to |
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
833 change what is sent based in pulls vs pushes, etc. |
75cc1f1e11f2
changegroup: add source parameter to generatemanifests
Durham Goode <durham@fb.com>
parents:
34160
diff
changeset
|
834 """ |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
835 repo = self._repo |
30308
bce79dfcf5e4
manifest: get rid of manifest.readshallowfast
Durham Goode <durham@fb.com>
parents:
30282
diff
changeset
|
836 mfl = repo.manifestlog |
bce79dfcf5e4
manifest: get rid of manifest.readshallowfast
Durham Goode <durham@fb.com>
parents:
30282
diff
changeset
|
837 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
|
838 tmfnodes = {'': mfs} |
28227
1c36cc8e7870
changegroup: extract generatemanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27953
diff
changeset
|
839 |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
840 # 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
|
841 # revisions. |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
842 # Returns the linkrev node (collected in lookupcl). |
35051
d80380ba8e7d
changegroup: use any node, not min(), in treemanifest's generatemanifests
Kyle Lippincott <spectral@google.com>
parents:
34734
diff
changeset
|
843 def makelookupmflinknode(dir, nodes): |
28231
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
844 if fastpathlinkrev: |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
845 assert not dir |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
846 return mfs.__getitem__ |
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
847 |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
848 def lookupmflinknode(x): |
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
849 """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
|
850 |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
851 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
|
852 |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
853 SIDE EFFECT: |
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
854 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
855 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
|
856 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
|
857 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
|
858 to send |
27219
beb60a898dd0
changegroup: document manifest linkrev callback some more
Augie Fackler <augie@google.com>
parents:
27218
diff
changeset
|
859 |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
860 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
|
861 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
|
862 treemanifests to send. |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
863 """ |
35051
d80380ba8e7d
changegroup: use any node, not min(), in treemanifest's generatemanifests
Kyle Lippincott <spectral@google.com>
parents:
34734
diff
changeset
|
864 clnode = nodes[x] |
30308
bce79dfcf5e4
manifest: get rid of manifest.readshallowfast
Durham Goode <durham@fb.com>
parents:
30282
diff
changeset
|
865 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
|
866 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
|
867 if fl == 't': # subdirectory manifest |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
868 subdir = dir + p + '/' |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
869 tmfclnodes = tmfnodes.setdefault(subdir, {}) |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
870 tmfclnode = tmfclnodes.setdefault(n, clnode) |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
871 if clrevorder[clnode] < clrevorder[tmfclnode]: |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
872 tmfclnodes[n] = clnode |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
873 else: |
a4286175ecba
changegroup: drop special-casing of flat manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
28240
diff
changeset
|
874 f = dir + p |
28240
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
875 fclnodes = fnodes.setdefault(f, {}) |
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
876 fclnode = fclnodes.setdefault(n, clnode) |
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
877 if clrevorder[clnode] < clrevorder[fclnode]: |
1ac8ce137377
changegroup: fix treemanifests on merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
28232
diff
changeset
|
878 fclnodes[n] = clnode |
27239
65c47779bcb5
changegroup: remove one special case from lookupmflinknode
Augie Fackler <augie@google.com>
parents:
27238
diff
changeset
|
879 return clnode |
28231
3faba927dd93
changegroup: introduce makelookupmflinknode(dir)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28230
diff
changeset
|
880 return lookupmflinknode |
19206
6308896b1d4a
bundle-ng: simplify bundle10.generate
Sune Foldager <cryo@cyanite.org>
parents:
19204
diff
changeset
|
881 |
38938
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
882 fn = (self._packtreemanifests if self._sendtreemanifests |
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
883 else self._packmanifests) |
28228
abf120262683
changegroup: make _packmanifests() dumber
Martin von Zweigbergk <martinvonz@google.com>
parents:
28227
diff
changeset
|
884 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
|
885 while tmfnodes: |
35051
d80380ba8e7d
changegroup: use any node, not min(), in treemanifest's generatemanifests
Kyle Lippincott <spectral@google.com>
parents:
34734
diff
changeset
|
886 dir, nodes = tmfnodes.popitem() |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
887 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
|
888 if not dir or prunednodes: |
38938
7a154778fb46
changegroup: consolidate tree manifests sending into cg1packer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38937
diff
changeset
|
889 for x in fn(dir, prunednodes, makelookupmflinknode(dir, nodes)): |
29371
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
890 size += len(x) |
1b699c7eb2b7
changegroup: don't send empty subdirectory manifest groups
Martin von Zweigbergk <martinvonz@google.com>
parents:
29236
diff
changeset
|
891 yield x |
28229
8e13b2379407
changegroup: include subdirectory manifests in verbose size
Martin von Zweigbergk <martinvonz@google.com>
parents:
28228
diff
changeset
|
892 self._verbosenote(_('%8.i (manifests)\n') % size) |
38937
67f37e8a5490
changegroup: pass end of manifests marker into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38936
diff
changeset
|
893 yield self._manifestsend |
19206
6308896b1d4a
bundle-ng: simplify bundle10.generate
Sune Foldager <cryo@cyanite.org>
parents:
19204
diff
changeset
|
894 |
24897
5c35a6040352
changegroup: document that 'source' parameter exists for extensions
Martin von Zweigbergk <martinvonz@google.com>
parents:
24896
diff
changeset
|
895 # 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
|
896 def generatefiles(self, changedfiles, linknodes, commonrevs, source): |
38928
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
897 changedfiles = list(filter(self._filematcher, changedfiles)) |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
898 |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
899 if self._isshallow: |
38928
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
900 # See comment in generate() for why this sadness is a thing. |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
901 mfdicts = self._mfdicts |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
902 del self._mfdicts |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
903 # In a shallow clone, the linknodes callback needs to also include |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
904 # those file nodes that are in the manifests we sent but weren't |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
905 # introduced by those manifests. |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
906 commonctxs = [self._repo[c] for c in commonrevs] |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
907 oldlinknodes = linknodes |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
908 clrev = self._repo.changelog.rev |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
909 |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
910 # Defining this function has a side-effect of overriding the |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
911 # function of the same name that was passed in as an argument. |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
912 # TODO have caller pass in appropriate function. |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
913 def linknodes(flog, fname): |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
914 for c in commonctxs: |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
915 try: |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
916 fnode = c.filenode(fname) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
917 self._clrev_to_localrev[c.rev()] = flog.rev(fnode) |
38928
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
918 except error.ManifestLookupError: |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
919 pass |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
920 links = oldlinknodes(flog, fname) |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
921 if len(links) != len(mfdicts): |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
922 for mf, lr in mfdicts: |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
923 fnode = mf.get(fname, None) |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
924 if fnode in links: |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
925 links[fnode] = min(links[fnode], lr, key=clrev) |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
926 elif fnode: |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
927 links[fnode] = lr |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
928 return links |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
929 |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
930 return self._generatefiles(changedfiles, linknodes, commonrevs, source) |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
931 |
a06aab274aef
changegroup: move generatefiles() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38927
diff
changeset
|
932 def _generatefiles(self, changedfiles, linknodes, commonrevs, source): |
19334
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
933 repo = self._repo |
38416
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
934 progress = repo.ui.makeprogress(_('bundling'), unit=_('files'), |
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
935 total=len(changedfiles)) |
19334
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
936 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
|
937 filerevlog = repo.file(fname) |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
938 if not filerevlog: |
37339
5859800edfc5
changegroup: remove "revlog" from error message
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37135
diff
changeset
|
939 raise error.Abort(_("empty or missing file data for %s") % |
5859800edfc5
changegroup: remove "revlog" from error message
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37135
diff
changeset
|
940 fname) |
19334
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
941 |
95a49112e7ab
bundle: move file chunk generation to it's own function
Durham Goode <durham@fb.com>
parents:
19325
diff
changeset
|
942 linkrevnodes = linknodes(filerevlog, fname) |
19207
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
943 # 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
|
944 # 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
|
945 def lookupfilelog(x): |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
946 return linkrevnodes[x] |
a67e1380dfbd
bundle-ng: simplify lookup and state handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
19206
diff
changeset
|
947 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
948 filenodes = self._prune(filerevlog, linkrevnodes, commonrevs) |
19206
6308896b1d4a
bundle-ng: simplify bundle10.generate
Sune Foldager <cryo@cyanite.org>
parents:
19204
diff
changeset
|
949 if filenodes: |
38416
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
950 progress.update(i + 1, item=fname) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
951 h = self._fileheader(fname) |
23748
4ab66de46a96
bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich <madski@unity3d.com>
parents:
23382
diff
changeset
|
952 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
|
953 yield h |
24912
e285b98c65cc
changegroup.group: drop 'reorder' parameter
Martin von Zweigbergk <martinvonz@google.com>
parents:
24911
diff
changeset
|
954 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
|
955 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
|
956 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
|
957 self._verbosenote(_('%8.i %s\n') % (size, fname)) |
38416
1c5c4a5dd86d
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38388
diff
changeset
|
958 progress.complete() |
19200
4cfdec944edf
bundle-ng: move group into the bundler
Sune Foldager <cryo@cyanite.org>
parents:
19199
diff
changeset
|
959 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
960 def _deltaparent(self, store, rev, p1, p2, prev): |
38940
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
961 if self._useprevdelta: |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
962 if not store.candelta(prev, rev): |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
963 raise error.ProgrammingError( |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
964 'cg1 should not be used in this case') |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
965 return prev |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
966 |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
967 # Narrow ellipses mode. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
968 if util.safehasattr(self, '_full_nodes'): |
38940
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
969 # TODO: send better deltas when in narrow mode. |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
970 # |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
971 # changegroup.group() loops over revisions to send, |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
972 # including revisions we'll skip. What this means is that |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
973 # `prev` will be a potentially useless delta base for all |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
974 # ellipsis nodes, as the client likely won't have it. In |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
975 # the future we should do bookkeeping about which nodes |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
976 # have been sent to the client, and try to be |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
977 # significantly smarter about delta bases. This is |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
978 # slightly tricky because this same code has to work for |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
979 # all revlogs, and we don't have the linkrev/linknode here. |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
980 return p1 |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
981 |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
982 dp = store.deltaparent(rev) |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
983 if dp == nullrev and store.storedeltachains: |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
984 # Avoid sending full revisions when delta parent is null. Pick prev |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
985 # in that case. It's tempting to pick p1 in this case, as p1 will |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
986 # be smaller in the common case. However, computing a delta against |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
987 # p1 may require resolving the raw text of p1, which could be |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
988 # expensive. The revlog caches should have prev cached, meaning |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
989 # less CPU for changegroup generation. There is likely room to add |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
990 # a flag and/or config option to control this behavior. |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
991 base = prev |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
992 elif dp == nullrev: |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
993 # revlog is configured to use full snapshot for a reason, |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
994 # stick to full snapshot. |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
995 base = nullrev |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
996 elif dp not in (p1, p2, prev): |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
997 # Pick prev when we can't be sure remote has the base revision. |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
998 return prev |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
999 else: |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
1000 base = dp |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
1001 |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
1002 if base != nullrev and not store.candelta(base, rev): |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
1003 base = nullrev |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
1004 |
23ae0c07a3e1
changegroup: control delta parent behavior via constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38939
diff
changeset
|
1005 return base |
23181
832b7ef275c8
changegroup: introduce cg2packer/unpacker
Sune Foldager <cryo@cyanite.org>
parents:
23178
diff
changeset
|
1006 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1007 def _revchunk(self, store, rev, prev, linknode): |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1008 if util.safehasattr(self, '_full_nodes'): |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1009 fn = self._revisiondeltanarrow |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1010 else: |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1011 fn = self._revisiondeltanormal |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1012 |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1013 delta = fn(store, rev, prev, linknode) |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1014 if not delta: |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1015 return |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1016 |
38936
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1017 meta = self._builddeltaheader(delta) |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1018 l = len(meta) + sum(len(x) for x in delta.deltachunks) |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1019 |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1020 yield chunkheader(l) |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1021 yield meta |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1022 for x in delta.deltachunks: |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1023 yield x |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1024 |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1025 def _revisiondeltanormal(self, store, rev, prev, linknode): |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1026 node = store.node(rev) |
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1027 p1, p2 = store.parentrevs(rev) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1028 base = self._deltaparent(store, rev, p1, p2, prev) |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1029 |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1030 prefix = '' |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1031 if store.iscensored(base) or store.iscensored(rev): |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
1032 try: |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1033 delta = store.revision(node, raw=True) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25624
diff
changeset
|
1034 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
|
1035 delta = e.tombstone |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
1036 if base == nullrev: |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
1037 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
|
1038 else: |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1039 baselen = store.rawsize(base) |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24180
diff
changeset
|
1040 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
|
1041 elif base == nullrev: |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1042 delta = store.revision(node, raw=True) |
14143
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1043 prefix = mdiff.trivialdiffheader(len(delta)) |
da635d3c5620
changegroup: new bundler API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1044 else: |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1045 delta = store.revdiff(base, rev) |
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1046 p1n, p2n = store.parents(node) |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1047 |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1048 return revisiondelta( |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1049 node=node, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1050 p1node=p1n, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1051 p2node=p2n, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1052 basenode=store.node(base), |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1053 linknode=linknode, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1054 flags=store.flags(rev), |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1055 deltachunks=(prefix, delta), |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1056 ) |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1057 |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1058 def _revisiondeltanarrow(self, store, rev, prev, linknode): |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1059 # build up some mapping information that's useful later. See |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1060 # the local() nested function below. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1061 if not self._changelog_done: |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1062 self._clnode_to_rev[linknode] = rev |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1063 linkrev = rev |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1064 self._clrev_to_localrev[linkrev] = rev |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1065 else: |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1066 linkrev = self._clnode_to_rev[linknode] |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1067 self._clrev_to_localrev[linkrev] = rev |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1068 |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1069 # This is a node to send in full, because the changeset it |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1070 # corresponds to was a full changeset. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1071 if linknode in self._full_nodes: |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1072 return self._revisiondeltanormal(store, rev, prev, linknode) |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1073 |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1074 # At this point, a node can either be one we should skip or an |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1075 # ellipsis. If it's not an ellipsis, bail immediately. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1076 if linkrev not in self._precomputed_ellipsis: |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1077 return |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1078 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1079 linkparents = self._precomputed_ellipsis[linkrev] |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1080 def local(clrev): |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1081 """Turn a changelog revnum into a local revnum. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1082 |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1083 The ellipsis dag is stored as revnums on the changelog, |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1084 but when we're producing ellipsis entries for |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1085 non-changelog revlogs, we need to turn those numbers into |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1086 something local. This does that for us, and during the |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1087 changelog sending phase will also expand the stored |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1088 mappings as needed. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1089 """ |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1090 if clrev == nullrev: |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1091 return nullrev |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1092 |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1093 if not self._changelog_done: |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1094 # If we're doing the changelog, it's possible that we |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1095 # have a parent that is already on the client, and we |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1096 # need to store some extra mapping information so that |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1097 # our contained ellipsis nodes will be able to resolve |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1098 # their parents. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1099 if clrev not in self._clrev_to_localrev: |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1100 clnode = store.node(clrev) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1101 self._clnode_to_rev[clnode] = clrev |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1102 return clrev |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1103 |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1104 # Walk the ellipsis-ized changelog breadth-first looking for a |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1105 # change that has been linked from the current revlog. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1106 # |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1107 # For a flat manifest revlog only a single step should be necessary |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1108 # as all relevant changelog entries are relevant to the flat |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1109 # manifest. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1110 # |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1111 # For a filelog or tree manifest dirlog however not every changelog |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1112 # entry will have been relevant, so we need to skip some changelog |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1113 # nodes even after ellipsis-izing. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1114 walk = [clrev] |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1115 while walk: |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1116 p = walk[0] |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1117 walk = walk[1:] |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1118 if p in self._clrev_to_localrev: |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1119 return self._clrev_to_localrev[p] |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1120 elif p in self._full_nodes: |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1121 walk.extend([pp for pp in self._repo.changelog.parentrevs(p) |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1122 if pp != nullrev]) |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1123 elif p in self._precomputed_ellipsis: |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1124 walk.extend([pp for pp in self._precomputed_ellipsis[p] |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1125 if pp != nullrev]) |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1126 else: |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1127 # In this case, we've got an ellipsis with parents |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1128 # outside the current bundle (likely an |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1129 # incremental pull). We "know" that we can use the |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1130 # value of this same revlog at whatever revision |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1131 # is pointed to by linknode. "Know" is in scare |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1132 # quotes because I haven't done enough examination |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1133 # of edge cases to convince myself this is really |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1134 # a fact - it works for all the (admittedly |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1135 # thorough) cases in our testsuite, but I would be |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1136 # somewhat unsurprised to find a case in the wild |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1137 # where this breaks down a bit. That said, I don't |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1138 # know if it would hurt anything. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1139 for i in pycompat.xrange(rev, 0, -1): |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1140 if store.linkrev(i) == clrev: |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1141 return i |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1142 # We failed to resolve a parent for this node, so |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1143 # we crash the changegroup construction. |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1144 raise error.Abort( |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1145 'unable to resolve parent while packing %r %r' |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1146 ' for changeset %r' % (store.indexfile, rev, clrev)) |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1147 |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1148 return nullrev |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1149 |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1150 if not linkparents or ( |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1151 store.parentrevs(rev) == (nullrev, nullrev)): |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1152 p1, p2 = nullrev, nullrev |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1153 elif len(linkparents) == 1: |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1154 p1, = sorted(local(p) for p in linkparents) |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1155 p2 = nullrev |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1156 else: |
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1157 p1, p2 = sorted(local(p) for p in linkparents) |
38931
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1158 |
38930
205c98e2f1ba
changegroup: rename "revlog" variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38929
diff
changeset
|
1159 n = store.node(rev) |
38931
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1160 p1n, p2n = store.node(p1), store.node(p2) |
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1161 flags = store.flags(rev) |
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1162 flags |= revlog.REVIDX_ELLIPSIS |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1163 |
38931
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1164 # TODO: try and actually send deltas for ellipsis data blocks |
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1165 data = store.revision(n) |
eb022ce9e505
changegroup: inline ellipsisdata()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38930
diff
changeset
|
1166 diffheader = mdiff.trivialdiffheader(len(data)) |
38932
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1167 |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1168 return revisiondelta( |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1169 node=n, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1170 p1node=p1n, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1171 p2node=p2n, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1172 basenode=nullid, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1173 linknode=linknode, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1174 flags=flags, |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1175 deltachunks=(diffheader, data), |
23d582caae30
changegroup: capture revision delta in a data structure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38931
diff
changeset
|
1176 ) |
38925
66cf046ef60f
changegroup: move revchunk() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38924
diff
changeset
|
1177 |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1178 def _makecg1packer(repo, filematcher, bundlecaps, shallow=False): |
38936
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1179 builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack( |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1180 d.node, d.p1node, d.p2node, d.linknode) |
27432
77d25b913f80
changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents:
27241
diff
changeset
|
1181 |
38941
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1182 return cgpacker(repo, filematcher, b'01', |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1183 useprevdelta=True, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1184 allowreorder=None, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1185 builddeltaheader=builddeltaheader, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1186 manifestsend=b'', |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1187 sendtreemanifests=False, |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1188 bundlecaps=bundlecaps, |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1189 shallow=shallow) |
38933
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1190 |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1191 def _makecg2packer(repo, filematcher, bundlecaps, shallow=False): |
38936
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1192 builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack( |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1193 d.node, d.p1node, d.p2node, d.basenode, d.linknode) |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1194 |
38939
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
1195 # Since generaldelta is directly supported by cg2, reordering |
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
1196 # generally doesn't help, so we disable it by default (treating |
6e999a2d8fe7
changegroup: control reordering via constructor argument
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38938
diff
changeset
|
1197 # bundle.reorder=auto just like bundle.reorder=False). |
38941
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1198 return cgpacker(repo, filematcher, b'02', |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1199 useprevdelta=False, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1200 allowreorder=False, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1201 builddeltaheader=builddeltaheader, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1202 manifestsend=b'', |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1203 sendtreemanifests=False, |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1204 bundlecaps=bundlecaps, |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1205 shallow=shallow) |
38933
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1206 |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1207 def _makecg3packer(repo, filematcher, bundlecaps, shallow=False): |
38936
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1208 builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack( |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1209 d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags) |
bd64b8b8f0dd
changegroup: pass function to build delta header into constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38935
diff
changeset
|
1210 |
38941
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1211 return cgpacker(repo, filematcher, b'03', |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1212 useprevdelta=False, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1213 allowreorder=False, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1214 builddeltaheader=builddeltaheader, |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1215 manifestsend=closechunk(), |
4c99c6d1ef95
changegroup: rename cg1packer to cgpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38940
diff
changeset
|
1216 sendtreemanifests=True, |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1217 bundlecaps=bundlecaps, |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1218 shallow=shallow) |
38933
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1219 |
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1220 _packermap = {'01': (_makecg1packer, cg1unpacker), |
26709
42733e956887
changegroup: reformat packermap and add comment
Augie Fackler <augie@google.com>
parents:
26708
diff
changeset
|
1221 # cg2 adds support for exchanging generaldelta |
38933
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1222 '02': (_makecg2packer, cg2unpacker), |
27753
d4071cc73f46
changegroup3: add empty chunk separating directories and files
Martin von Zweigbergk <martinvonz@google.com>
parents:
27752
diff
changeset
|
1223 # cg3 adds support for exchanging revlog flags and treemanifests |
38933
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1224 '03': (_makecg3packer, cg3unpacker), |
26709
42733e956887
changegroup: reformat packermap and add comment
Augie Fackler <augie@google.com>
parents:
26708
diff
changeset
|
1225 } |
23168
a92ba36a1a9d
changegroup: add a "packermap" dictionary to track different packer versions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22971
diff
changeset
|
1226 |
30632
7ace5304fec5
changegroup: pass 'repo' to allsupportedversions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30631
diff
changeset
|
1227 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
|
1228 versions = set(_packermap.keys()) |
30632
7ace5304fec5
changegroup: pass 'repo' to allsupportedversions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30631
diff
changeset
|
1229 if not (repo.ui.configbool('experimental', 'changegroup3') or |
30633
a001cd7296a5
changegroup: simplify logic around enabling changegroup 03
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30632
diff
changeset
|
1230 repo.ui.configbool('experimental', 'treemanifest') or |
a001cd7296a5
changegroup: simplify logic around enabling changegroup 03
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30632
diff
changeset
|
1231 'treemanifest' in repo.requirements): |
30631
438532c99b54
changegroup: simplify 'allsupportedversions' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30594
diff
changeset
|
1232 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
|
1233 return versions |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
1234 |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
1235 # 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
|
1236 def supportedincomingversions(repo): |
30633
a001cd7296a5
changegroup: simplify logic around enabling changegroup 03
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30632
diff
changeset
|
1237 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
|
1238 |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
1239 # 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
|
1240 def supportedoutgoingversions(repo): |
30632
7ace5304fec5
changegroup: pass 'repo' to allsupportedversions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30631
diff
changeset
|
1241 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
|
1242 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
|
1243 # 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
|
1244 # 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
|
1245 # 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
|
1246 # 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
|
1247 # 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
|
1248 versions.discard('01') |
c0f11347b107
changegroup: don't support versions 01 and 02 with treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27920
diff
changeset
|
1249 versions.discard('02') |
38874
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38846
diff
changeset
|
1250 if repository.NARROW_REQUIREMENT in repo.requirements: |
36495
94709406f10d
narrow: move changegroup.supportedoutgoingversions() override to core
Martin von Zweigbergk <martinvonz@google.com>
parents:
36494
diff
changeset
|
1251 # Versions 01 and 02 don't support revlog flags, and we need to |
94709406f10d
narrow: move changegroup.supportedoutgoingversions() override to core
Martin von Zweigbergk <martinvonz@google.com>
parents:
36494
diff
changeset
|
1252 # support that for stripping and unbundling to work. |
94709406f10d
narrow: move changegroup.supportedoutgoingversions() override to core
Martin von Zweigbergk <martinvonz@google.com>
parents:
36494
diff
changeset
|
1253 versions.discard('01') |
94709406f10d
narrow: move changegroup.supportedoutgoingversions() override to core
Martin von Zweigbergk <martinvonz@google.com>
parents:
36494
diff
changeset
|
1254 versions.discard('02') |
37135
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
1255 if LFS_REQUIREMENT in repo.requirements: |
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
1256 # Versions 01 and 02 don't support revlog flags, and we need to |
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
1257 # mark LFS entries with REVIDX_EXTSTORED. |
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
1258 versions.discard('01') |
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
1259 versions.discard('02') |
a54113fcc8c9
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
37087
diff
changeset
|
1260 |
27752
29cfc474c5fd
changegroup3: introduce experimental.changegroup3 boolean config
Martin von Zweigbergk <martinvonz@google.com>
parents:
27751
diff
changeset
|
1261 return versions |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
1262 |
33676
91f0677dc920
repair: preserve phase also when not using generaldelta (issue5678)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33461
diff
changeset
|
1263 def localversion(repo): |
91f0677dc920
repair: preserve phase also when not using generaldelta (issue5678)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33461
diff
changeset
|
1264 # Finds the best version to use for bundles that are meant to be used |
91f0677dc920
repair: preserve phase also when not using generaldelta (issue5678)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33461
diff
changeset
|
1265 # locally, such as those from strip and shelve, and temporary bundles. |
91f0677dc920
repair: preserve phase also when not using generaldelta (issue5678)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33461
diff
changeset
|
1266 return max(supportedoutgoingversions(repo)) |
91f0677dc920
repair: preserve phase also when not using generaldelta (issue5678)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33461
diff
changeset
|
1267 |
27929
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1268 def safeversion(repo): |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1269 # 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
|
1270 # 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
|
1271 # 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
|
1272 versions = supportedoutgoingversions(repo) |
27929
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1273 if 'generaldelta' in repo.requirements: |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1274 versions.discard('01') |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1275 assert versions |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1276 return min(versions) |
3b2ac2115464
changegroup: introduce safeversion()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27928
diff
changeset
|
1277 |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1278 def getbundler(version, repo, bundlecaps=None, filematcher=None, |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1279 shallow=False): |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27946
diff
changeset
|
1280 assert version in supportedoutgoingversions(repo) |
38834
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1281 |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1282 if filematcher is None: |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1283 filematcher = matchmod.alwaysmatcher(repo.root, '') |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1284 |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1285 if version == '01' and not filematcher.always(): |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1286 raise error.ProgrammingError('version 01 changegroups do not support ' |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1287 'sparse file matchers') |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1288 |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1289 # Requested files could include files not in the local store. So |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1290 # filter those out. |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1291 filematcher = matchmod.intersectmatchers(repo.narrowmatch(), |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1292 filematcher) |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1293 |
38933
19344024a8e1
changegroup: define functions for creating changegroup packers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38932
diff
changeset
|
1294 fn = _packermap[version][0] |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1295 return fn(repo, filematcher, bundlecaps, shallow=shallow) |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27739
diff
changeset
|
1296 |
29593
953839de96ab
bundle2: store changeset count when creating file bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29371
diff
changeset
|
1297 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
|
1298 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
|
1299 |
20926
7c1ed40e3325
localrepo: move the changegroupinfo method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
1300 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
|
1301 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
|
1302 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
|
1303 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
|
1304 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
|
1305 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
|
1306 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
|
1307 |
34111
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1308 def makechangegroup(repo, outgoing, version, source, fastpath=False, |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1309 bundlecaps=None): |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1310 cgstream = makestream(repo, outgoing, version, source, |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1311 fastpath=fastpath, bundlecaps=bundlecaps) |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1312 return getunbundler(version, util.chunkbuffer(cgstream), None, |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1313 {'clcount': len(outgoing.missing) }) |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
34106
diff
changeset
|
1314 |
34118
92f1e2be8ab6
changegroup: rename getsubsetraw to makestream
Durham Goode <durham@fb.com>
parents:
34116
diff
changeset
|
1315 def makestream(repo, outgoing, version, source, fastpath=False, |
38834
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1316 bundlecaps=None, filematcher=None): |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1317 bundler = getbundler(version, repo, bundlecaps=bundlecaps, |
1d01cf0416a5
changegroup: move file matcher from narrow extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38823
diff
changeset
|
1318 filematcher=filematcher) |
34118
92f1e2be8ab6
changegroup: rename getsubsetraw to makestream
Durham Goode <durham@fb.com>
parents:
34116
diff
changeset
|
1319 |
20925
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1320 repo = repo.unfiltered() |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1321 commonrevs = outgoing.common |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1322 csets = outgoing.missing |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1323 heads = outgoing.missingheads |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1324 # 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
|
1325 # 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
|
1326 # 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
|
1327 heads.sort() |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1328 fastpathlinkrev = fastpath or ( |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1329 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
|
1330 |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20675
diff
changeset
|
1331 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
|
1332 _changegroupinfo(repo, csets, source) |
23177
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
1333 return bundler.generate(commonrevs, csets, fastpathlinkrev, source) |
706547a14b8b
changegroup: introduce "raw" versions of some commands
Sune Foldager <cryo@cyanite.org>
parents:
23168
diff
changeset
|
1334 |
28361
277a22cd8741
changegroup: progress for added files is not measured in "chunks"
Martin von Zweigbergk <martinvonz@google.com>
parents:
28360
diff
changeset
|
1335 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
|
1336 revisions = 0 |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1337 files = 0 |
38388
daa08d45740f
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38379
diff
changeset
|
1338 progress = repo.ui.makeprogress(_('files'), unit=_('files'), |
daa08d45740f
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38379
diff
changeset
|
1339 total=expectedfiles) |
29736
4e7be6e33269
changegroup: use `iter(callable, sentinel)` instead of while True
Augie Fackler <augie@google.com>
parents:
29704
diff
changeset
|
1340 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
|
1341 files += 1 |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1342 f = chunkdata["filename"] |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1343 repo.ui.debug("adding %s revisions\n" % f) |
38388
daa08d45740f
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38379
diff
changeset
|
1344 progress.increment() |
27754
a09f143daaf4
changegroup3: move treemanifest support into _unpackmanifests()
Martin von Zweigbergk <martinvonz@google.com>
parents:
27753
diff
changeset
|
1345 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
|
1346 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
|
1347 try: |
34298
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
1348 deltas = source.deltaiter() |
1db9abf407c5
revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents:
34264
diff
changeset
|
1349 if not fl.addgroup(deltas, revmap, trp): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
1350 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
|
1351 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
|
1352 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
|
1353 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
|
1354 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
|
1355 needs = needfiles[f] |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38557
diff
changeset
|
1356 for new in pycompat.xrange(o, len(fl)): |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1357 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
|
1358 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
|
1359 needs.remove(n) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1360 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26540
diff
changeset
|
1361 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
|
1362 _("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
|
1363 if not needs: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1364 del needfiles[f] |
38388
daa08d45740f
changegroup: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38379
diff
changeset
|
1365 progress.complete() |
20932
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1366 |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1367 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
|
1368 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
|
1369 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
|
1370 try: |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1371 fl.rev(n) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1372 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
|
1373 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
|
1374 _('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
|
1375 (f, hex(n))) |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1376 |
0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20931
diff
changeset
|
1377 return revisions, files |
38923
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1378 |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1379 def _packellipsischangegroup(repo, common, match, relevant_nodes, |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1380 ellipsisroots, visitnodes, depth, source, version): |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1381 if version in ('01', '02'): |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1382 raise error.Abort( |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1383 'ellipsis nodes require at least cg3 on client and server, ' |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1384 'but negotiated version %s' % version) |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1385 # We wrap cg1packer.revchunk, using a side channel to pass |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1386 # relevant_nodes into that area. Then if linknode isn't in the |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1387 # set, we know we have an ellipsis node and we should defer |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1388 # sending that node's data. We override close() to detect |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1389 # pending ellipsis nodes and flush them. |
38943
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1390 packer = getbundler(version, repo, filematcher=match, |
cdb9bc216771
changegroup: declare shallow flag in constructor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38942
diff
changeset
|
1391 shallow=depth is not None) |
38923
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1392 # Give the packer the list of nodes which should not be |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1393 # ellipsis nodes. We store this rather than the set of nodes |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1394 # that should be an ellipsis because for very large histories |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1395 # we expect this to be significantly smaller. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1396 packer._full_nodes = relevant_nodes |
38923
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1397 # Maps ellipsis revs to their roots at the changelog level. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1398 packer._precomputed_ellipsis = ellipsisroots |
38923
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1399 # Maps CL revs to per-revlog revisions. Cleared in close() at |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1400 # the end of each group. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1401 packer._clrev_to_localrev = {} |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1402 packer._next_clrev_to_localrev = {} |
38923
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1403 # Maps changelog nodes to changelog revs. Filled in once |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1404 # during changelog stage and then left unmodified. |
38942
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1405 packer._clnode_to_rev = {} |
68e490ed640e
changegroup: make some packer attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38941
diff
changeset
|
1406 packer._changelog_done = False |
38923
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1407 |
a2f521773761
changegroup: move _packellipsischangegroup() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38922
diff
changeset
|
1408 return packer.generate(common, visitnodes, False, source) |