author | Martin von Zweigbergk <martinvonz@google.com> |
Tue, 23 Feb 2021 10:28:42 -0800 | |
changeset 47020 | ba6881c6a178 |
parent 47012 | d55b71393907 |
child 47073 | 64cd1496bb70 |
permissions | -rw-r--r-- |
45764
18c17d63fdab
i18n: fix coding tag unsupported by xgettext
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
45735
diff
changeset
|
1 |
# coding: utf-8 |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 |
# metadata.py -- code related to various metadata computation and access. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 |
# |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 |
# Copyright 2019 Google, Inc <martinvonz@google.com> |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 |
# Copyright 2020 Pierre-Yves David <pierre-yves.david@octobus.net> |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 |
# |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 |
# This software may be used and distributed according to the terms of the |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 |
# GNU General Public License version 2 or any later version. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 |
from __future__ import absolute_import, print_function |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
11 |
import multiprocessing |
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
12 |
import struct |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
13 |
|
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46815
diff
changeset
|
14 |
from .node import nullrev |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 |
from . import ( |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 |
error, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
pycompat, |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
18 |
requirements as requirementsmod, |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 |
util, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 |
) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 |
from .revlogutils import ( |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 |
flagutil as sidedataflag, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
24 |
sidedata as sidedatamod, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
25 |
) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 |
|
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
28 |
class ChangingFiles(object): |
45621
646a676f5365
changing-files: fix docstring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45613
diff
changeset
|
29 |
"""A class recording the changes made to files by a changeset |
45506
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
30 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
31 |
Actions performed on files are gathered into 3 sets: |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
32 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
33 |
- added: files actively added in the changeset. |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
34 |
- merged: files whose history got merged |
45506
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
35 |
- removed: files removed in the revision |
45659
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
36 |
- salvaged: files that might have been deleted by a merge but were not |
45506
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
37 |
- touched: files affected by the merge |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
38 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
39 |
and copies information is held by 2 mappings |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
40 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
41 |
- copied_from_p1: {"<new-name>": "<source-name-in-p1>"} mapping for copies |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
42 |
- copied_from_p2: {"<new-name>": "<source-name-in-p2>"} mapping for copies |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
43 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
44 |
See their inline help for details. |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
45 |
""" |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
46 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
47 |
def __init__( |
45589
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
48 |
self, |
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
49 |
touched=None, |
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
50 |
added=None, |
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
51 |
removed=None, |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
52 |
merged=None, |
45659
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
53 |
salvaged=None, |
45589
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
54 |
p1_copies=None, |
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
55 |
p2_copies=None, |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
56 |
): |
45589
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
57 |
self._added = set(() if added is None else added) |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
58 |
self._merged = set(() if merged is None else merged) |
45589
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
59 |
self._removed = set(() if removed is None else removed) |
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
60 |
self._touched = set(() if touched is None else touched) |
45659
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
61 |
self._salvaged = set(() if salvaged is None else salvaged) |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
62 |
self._touched.update(self._added) |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
63 |
self._touched.update(self._merged) |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
64 |
self._touched.update(self._removed) |
45589
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
65 |
self._p1_copies = dict(() if p1_copies is None else p1_copies) |
3d5b2b8e93fd
changing-files: move default constructor value to None
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45571
diff
changeset
|
66 |
self._p2_copies = dict(() if p2_copies is None else p2_copies) |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
67 |
|
45507
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
68 |
def __eq__(self, other): |
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
69 |
return ( |
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
70 |
self.added == other.added |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
71 |
and self.merged == other.merged |
45507
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
72 |
and self.removed == other.removed |
45659
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
73 |
and self.salvaged == other.salvaged |
45507
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
74 |
and self.touched == other.touched |
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
75 |
and self.copied_from_p1 == other.copied_from_p1 |
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
76 |
and self.copied_from_p2 == other.copied_from_p2 |
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
77 |
) |
df87821081ee
changing-files: implement equality checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45506
diff
changeset
|
78 |
|
45728
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
79 |
@property |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
80 |
def has_copies_info(self): |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
81 |
return bool( |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
82 |
self.removed |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
83 |
or self.merged |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
84 |
or self.salvaged |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
85 |
or self.copied_from_p1 |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
86 |
or self.copied_from_p2 |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
87 |
) |
232c88dd89e3
changing-files: add a shorthand property to check for copy relevant info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45669
diff
changeset
|
88 |
|
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
89 |
@util.propertycache |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
90 |
def added(self): |
45506
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
91 |
"""files actively added in the changeset |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
92 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
93 |
Any file present in that revision that was absent in all the changeset's |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
94 |
parents. |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
95 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
96 |
In case of merge, this means a file absent in one of the parents but |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
97 |
existing in the other will *not* be contained in this set. (They were |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
98 |
added by an ancestor) |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
99 |
""" |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
100 |
return frozenset(self._added) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
101 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
102 |
def mark_added(self, filename): |
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
103 |
if 'added' in vars(self): |
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
104 |
del self.added |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
105 |
self._added.add(filename) |
45622
42bb6c4f8106
changing-files: always use `mark_touched` to update the touched set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45621
diff
changeset
|
106 |
self.mark_touched(filename) |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
107 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
108 |
def update_added(self, filenames): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
109 |
for f in filenames: |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
110 |
self.mark_added(f) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
111 |
|
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
112 |
@util.propertycache |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
113 |
def merged(self): |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
114 |
"""files actively merged during a merge |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
115 |
|
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
116 |
Any modified files which had modification on both size that needed merging. |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
117 |
|
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
118 |
In this case a new filenode was created and it has two parents. |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
119 |
""" |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
120 |
return frozenset(self._merged) |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
121 |
|
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
122 |
def mark_merged(self, filename): |
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
123 |
if 'merged' in vars(self): |
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
124 |
del self.merged |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
125 |
self._merged.add(filename) |
45622
42bb6c4f8106
changing-files: always use `mark_touched` to update the touched set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45621
diff
changeset
|
126 |
self.mark_touched(filename) |
45611
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
127 |
|
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
128 |
def update_merged(self, filenames): |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
129 |
for f in filenames: |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
130 |
self.mark_merged(f) |
e5578dbe36cb
changing-files: add the ability to track merged files too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45589
diff
changeset
|
131 |
|
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
132 |
@util.propertycache |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
133 |
def removed(self): |
45506
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
134 |
"""files actively removed by the changeset |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
135 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
136 |
In case of merge this will only contain the set of files removing "new" |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
137 |
content. For any file absent in the current changeset: |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
138 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
139 |
a) If the file exists in both parents, it is clearly "actively" removed |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
140 |
by this changeset. |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
141 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
142 |
b) If a file exists in only one parent and in none of the common |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
143 |
ancestors, then the file was newly added in one of the merged branches |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
144 |
and then got "actively" removed. |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
145 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
146 |
c) If a file exists in only one parent and at least one of the common |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
147 |
ancestors using the same filenode, then the file was unchanged on one |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
148 |
side and deleted on the other side. The merge "passively" propagated |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
149 |
that deletion, but didn't "actively" remove the file. In this case the |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
150 |
file is *not* included in the `removed` set. |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
151 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
152 |
d) If a file exists in only one parent and at least one of the common |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
153 |
ancestors using a different filenode, then the file was changed on one |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
154 |
side and removed on the other side. The merge process "actively" |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
155 |
decided to drop the new change and delete the file. Unlike in the |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
156 |
previous case, (c), the file included in the `removed` set. |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
157 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
158 |
Summary table for merge: |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
159 |
|
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
160 |
case | exists in parents | exists in gca || removed |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
161 |
(a) | both | * || yes |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
162 |
(b) | one | none || yes |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
163 |
(c) | one | same filenode || no |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
164 |
(d) | one | new filenode || yes |
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
165 |
""" |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
166 |
return frozenset(self._removed) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
167 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
168 |
def mark_removed(self, filename): |
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
169 |
if 'removed' in vars(self): |
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
170 |
del self.removed |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
171 |
self._removed.add(filename) |
45622
42bb6c4f8106
changing-files: always use `mark_touched` to update the touched set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45621
diff
changeset
|
172 |
self.mark_touched(filename) |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
173 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
174 |
def update_removed(self, filenames): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
175 |
for f in filenames: |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
176 |
self.mark_removed(f) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
177 |
|
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
178 |
@util.propertycache |
45659
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
179 |
def salvaged(self): |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
180 |
"""files that might have been deleted by a merge, but still exists. |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
181 |
|
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
182 |
During a merge, the manifest merging might select some files for |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
183 |
removal, or for a removed/changed conflict. If at commit time the file |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
184 |
still exists, its removal was "reverted" and the file is "salvaged" |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
185 |
""" |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
186 |
return frozenset(self._salvaged) |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
187 |
|
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
188 |
def mark_salvaged(self, filename): |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
189 |
if "salvaged" in vars(self): |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
190 |
del self.salvaged |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
191 |
self._salvaged.add(filename) |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
192 |
self.mark_touched(filename) |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
193 |
|
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
194 |
def update_salvaged(self, filenames): |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
195 |
for f in filenames: |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
196 |
self.mark_salvaged(f) |
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
197 |
|
a475db79d84d
changing-files: add a "salvaged" set to track file that were not removed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45635
diff
changeset
|
198 |
@util.propertycache |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
199 |
def touched(self): |
45506
1f50bcc96595
changing-files: document the various sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45325
diff
changeset
|
200 |
"""files either actively modified, added or removed""" |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
201 |
return frozenset(self._touched) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
202 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
203 |
def mark_touched(self, filename): |
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
204 |
if 'touched' in vars(self): |
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
205 |
del self.touched |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
206 |
self._touched.add(filename) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
207 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
208 |
def update_touched(self, filenames): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
209 |
for f in filenames: |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
210 |
self.mark_touched(f) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
211 |
|
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
212 |
@util.propertycache |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
213 |
def copied_from_p1(self): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
214 |
return self._p1_copies.copy() |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
215 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
216 |
def mark_copied_from_p1(self, source, dest): |
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
217 |
if 'copied_from_p1' in vars(self): |
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
218 |
del self.copied_from_p1 |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
219 |
self._p1_copies[dest] = source |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
220 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
221 |
def update_copies_from_p1(self, copies): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
222 |
for dest, source in copies.items(): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
223 |
self.mark_copied_from_p1(source, dest) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
224 |
|
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
225 |
@util.propertycache |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
226 |
def copied_from_p2(self): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
227 |
return self._p2_copies.copy() |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
228 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
229 |
def mark_copied_from_p2(self, source, dest): |
45623
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
230 |
if 'copied_from_p2' in vars(self): |
d31483377673
changing-files: cache the various property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45622
diff
changeset
|
231 |
del self.copied_from_p2 |
45323
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
232 |
self._p2_copies[dest] = source |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
233 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
234 |
def update_copies_from_p2(self, copies): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
235 |
for dest, source in copies.items(): |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
236 |
self.mark_copied_from_p2(source, dest) |
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
237 |
|
aea6a812f7cb
commitctx: return a richer object from _prepare_files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44942
diff
changeset
|
238 |
|
45663
cf474af69766
changing-files: split the changing files computation from encoding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45660
diff
changeset
|
239 |
def compute_all_files_changes(ctx): |
cf474af69766
changing-files: split the changing files computation from encoding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45660
diff
changeset
|
240 |
"""compute the files changed by a revision""" |
45666
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
241 |
p1 = ctx.p1() |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
242 |
p2 = ctx.p2() |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
243 |
if p1.rev() == nullrev and p2.rev() == nullrev: |
45666
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
244 |
return _process_root(ctx) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
245 |
elif p1.rev() != nullrev and p2.rev() == nullrev: |
45667
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
246 |
return _process_linear(p1, ctx) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
247 |
elif p1.rev() == nullrev and p2.rev() != nullrev: |
45667
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
248 |
# In the wild, one can encounter changeset where p1 is null but p2 is not |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
249 |
return _process_linear(p1, ctx, parent=2) |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
250 |
elif p1.rev() == p2.rev(): |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
251 |
# In the wild, one can encounter such "non-merge" |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
252 |
return _process_linear(p1, ctx) |
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
253 |
else: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
254 |
return _process_merge(p1, p2, ctx) |
45663
cf474af69766
changing-files: split the changing files computation from encoding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45660
diff
changeset
|
255 |
|
cf474af69766
changing-files: split the changing files computation from encoding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45660
diff
changeset
|
256 |
|
45666
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
257 |
def _process_root(ctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45764
diff
changeset
|
258 |
"""compute the appropriate changed files for a changeset with no parents""" |
45666
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
259 |
# Simple, there was nothing before it, so everything is added. |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
260 |
md = ChangingFiles() |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
261 |
manifest = ctx.manifest() |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
262 |
for filename in manifest: |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
263 |
md.mark_added(filename) |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
264 |
return md |
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
265 |
|
f6811e5bd994
changing-files: add clean computation of changed files for roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45663
diff
changeset
|
266 |
|
45667
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
267 |
def _process_linear(parent_ctx, children_ctx, parent=1): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45764
diff
changeset
|
268 |
"""compute the appropriate changed files for a changeset with a single parent""" |
45667
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
269 |
md = ChangingFiles() |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
270 |
parent_manifest = parent_ctx.manifest() |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
271 |
children_manifest = children_ctx.manifest() |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
272 |
|
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
273 |
copies_candidate = [] |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
274 |
|
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
275 |
for filename, d in parent_manifest.diff(children_manifest).items(): |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
276 |
if d[1][0] is None: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
277 |
# no filenode for the "new" value, file is absent |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
278 |
md.mark_removed(filename) |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
279 |
else: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
280 |
copies_candidate.append(filename) |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
281 |
if d[0][0] is None: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
282 |
# not filenode for the "old" value file was absent |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
283 |
md.mark_added(filename) |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
284 |
else: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
285 |
# filenode for both "old" and "new" |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
286 |
md.mark_touched(filename) |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
287 |
|
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
288 |
if parent == 1: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
289 |
copied = md.mark_copied_from_p1 |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
290 |
elif parent == 2: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
291 |
copied = md.mark_copied_from_p2 |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
292 |
else: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
293 |
assert False, "bad parent value %d" % parent |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
294 |
|
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
295 |
for filename in copies_candidate: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
296 |
copy_info = children_ctx[filename].renamed() |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
297 |
if copy_info: |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
298 |
source, srcnode = copy_info |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
299 |
copied(source, filename) |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
300 |
|
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
301 |
return md |
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
302 |
|
0303fc1f43f8
changing-files: add clean computation of changed files for linear changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45666
diff
changeset
|
303 |
|
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
304 |
def _process_merge(p1_ctx, p2_ctx, ctx): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
305 |
"""compute the appropriate changed files for a changeset with two parents |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
306 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
307 |
This is a more advance case. The information we need to record is summarise |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
308 |
in the following table: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
309 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
310 |
┌──────────────┬──────────────┬──────────────┬──────────────┬──────────────┐ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
311 |
│ diff ╲ diff │ ø │ (Some, None) │ (None, Some) │ (Some, Some) │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
312 |
│ p2 ╲ p1 │ │ │ │ │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
313 |
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
314 |
│ │ │🄱 No Changes │🄳 No Changes │ │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
315 |
│ ø │🄰 No Changes │ OR │ OR │🄵 No Changes │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
316 |
│ │ │🄲 Deleted[1] │🄴 Salvaged[2]│ [3] │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
317 |
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
318 |
│ │🄶 No Changes │ │ │ │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
319 |
│ (Some, None) │ OR │🄻 Deleted │ ø │ ø │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
320 |
│ │🄷 Deleted[1] │ │ │ │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
321 |
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤ |
46814
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
322 |
│ │🄸 No Changes │ │ │ 🄽 Touched │ |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
323 |
│ (None, Some) │ OR │ ø │🄼 Added │OR 🅀 Salvaged │ |
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
324 |
│ │🄹 Salvaged[2]│ │ (copied?) │ (copied?) │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
325 |
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤ |
46815
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
326 |
│ │ │ │ 🄾 Touched │ 🄿 Merged │ |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
327 |
│ (Some, Some) │🄺 No Changes │ ø │OR 🅁 Salvaged │OR 🅂 Touched │ |
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
328 |
│ │ [3] │ │ (copied?) │ (copied?) │ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
329 |
└──────────────┴──────────────┴──────────────┴──────────────┴──────────────┘ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
330 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
331 |
Special case [1]: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
332 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
333 |
The situation is: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
334 |
- parent-A: file exists, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
335 |
- parent-B: no file, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
336 |
- working-copy: no file. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
337 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
338 |
Detecting a "deletion" will depend on the presence of actual change on |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
339 |
the "parent-A" branch: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
340 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
341 |
Subcase 🄱 or 🄶 : if the state of the file in "parent-A" is unchanged |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
342 |
compared to the merge ancestors, then parent-A branch left the file |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
343 |
untouched while parent-B deleted it. We simply apply the change from |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
344 |
"parent-B" branch the file was automatically dropped. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
345 |
The result is: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
346 |
- file is not recorded as touched by the merge. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
347 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
348 |
Subcase 🄲 or 🄷 : otherwise, the change from parent-A branch were explicitly dropped and |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
349 |
the file was "deleted again". From a user perspective, the message |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
350 |
about "locally changed" while "remotely deleted" (or the other way |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
351 |
around) was issued and the user chose to deleted the file. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
352 |
The result: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
353 |
- file is recorded as touched by the merge. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
354 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
355 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
356 |
Special case [2]: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
357 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
358 |
The situation is: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
359 |
- parent-A: no file, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
360 |
- parent-B: file, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
361 |
- working-copy: file (same content as parent-B). |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
362 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
363 |
There are three subcases depending on the ancestors contents: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
364 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
365 |
- A) the file is missing in all ancestors, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
366 |
- B) at least one ancestor has the file with filenode ≠ from parent-B, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
367 |
- C) all ancestors use the same filenode as parent-B, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
368 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
369 |
Subcase (A) is the simpler, nothing happend on parent-A side while |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
370 |
parent-B added it. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
371 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
372 |
The result: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
373 |
- the file is not marked as touched by the merge. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
374 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
375 |
Subcase (B) is the counter part of "Special case [1]", the file was |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
376 |
modified on parent-B side, while parent-A side deleted it. However this |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
377 |
time, the conflict was solved by keeping the file (and its |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
378 |
modification). We consider the file as "salvaged". |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
379 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
380 |
The result: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
381 |
- the file is marked as "salvaged" by the merge. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
382 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
383 |
Subcase (C) is subtle variation of the case above. In this case, the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
384 |
file in unchanged on the parent-B side and actively removed on the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
385 |
parent-A side. So the merge machinery correctly decide it should be |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
386 |
removed. However, the file was explicitly restored to its parent-B |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
387 |
content before the merge was commited. The file is be marked |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
388 |
as salvaged too. From the merge result perspective, this is similar to |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
389 |
Subcase (B), however from the merge resolution perspective they differ |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
390 |
since in (C), there was some conflict not obvious solution to the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
391 |
merge (That got reversed) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
392 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
393 |
Special case [3]: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
394 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
395 |
The situation is: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
396 |
- parent-A: file, |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
397 |
- parent-B: file (different filenode as parent-A), |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
398 |
- working-copy: file (same filenode as parent-B). |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
399 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
400 |
This case is in theory much simple, for this to happens, this mean the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
401 |
filenode in parent-A is purely replacing the one in parent-B (either a |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
402 |
descendant, or a full new file history, see changeset). So the merge |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
403 |
introduce no changes, and the file is not affected by the merge... |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
404 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
405 |
However, in the wild it is possible to find commit with the above is not |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
406 |
True. For example repository have some commit where the *new* node is an |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
407 |
ancestor of the node in parent-A, or where parent-A and parent-B are two |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
408 |
branches of the same file history, yet not merge-filenode were created |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
409 |
(while the "merge" should have led to a "modification"). |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
410 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
411 |
Detecting such cases (and not recording the file as modified) would be a |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
412 |
nice bonus. However do not any of this yet. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
413 |
""" |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
414 |
|
46815
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
415 |
repo = ctx.repo() |
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
416 |
md = ChangingFiles() |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
417 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
418 |
m = ctx.manifest() |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
419 |
p1m = p1_ctx.manifest() |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
420 |
p2m = p2_ctx.manifest() |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
421 |
diff_p1 = p1m.diff(m) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
422 |
diff_p2 = p2m.diff(m) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
423 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
424 |
cahs = ctx.repo().changelog.commonancestorsheads( |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
425 |
p1_ctx.node(), p2_ctx.node() |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
426 |
) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
427 |
if not cahs: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
428 |
cahs = [nullrev] |
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
429 |
mas = [ctx.repo()[r].manifest() for r in cahs] |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
430 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
431 |
copy_candidates = [] |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
432 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
433 |
# Dealing with case 🄰 happens automatically. Since there are no entry in |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
434 |
# d1 nor d2, we won't iterate on it ever. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
435 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
436 |
# Iteration over d1 content will deal with all cases, but the one in the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
437 |
# first column of the table. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
438 |
for filename, d1 in diff_p1.items(): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
439 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
440 |
d2 = diff_p2.pop(filename, None) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
441 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
442 |
if d2 is None: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
443 |
# this deal with the first line of the table. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
444 |
_process_other_unchanged(md, mas, filename, d1) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
445 |
else: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
446 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
447 |
if d1[0][0] is None and d2[0][0] is None: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
448 |
# case 🄼 — both deleted the file. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
449 |
md.mark_added(filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
450 |
copy_candidates.append(filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
451 |
elif d1[1][0] is None and d2[1][0] is None: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
452 |
# case 🄻 — both deleted the file. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
453 |
md.mark_removed(filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
454 |
elif d1[1][0] is not None and d2[1][0] is not None: |
46814
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
455 |
if d1[0][0] is None or d2[0][0] is None: |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
456 |
if any(_find(ma, filename) is not None for ma in mas): |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
457 |
# case 🅀 or 🅁 |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
458 |
md.mark_salvaged(filename) |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
459 |
else: |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
460 |
# case 🄽 🄾 : touched |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
461 |
md.mark_touched(filename) |
c52c3c4cbd3f
copies: detect files as `touched/salvaged` if they only existed on one side
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46713
diff
changeset
|
462 |
else: |
46815
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
463 |
fctx = repo.filectx(filename, fileid=d1[1][0]) |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
464 |
if fctx.p2().rev() == nullrev: |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
465 |
# case 🅂 |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
466 |
# lets assume we can trust the file history. If the |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
467 |
# filenode is not a merge, the file was not merged. |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
468 |
md.mark_touched(filename) |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
469 |
else: |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
470 |
# case 🄿 |
433cef8f3104
copies: distinguish between merged and touched files during upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46814
diff
changeset
|
471 |
md.mark_merged(filename) |
45668
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
472 |
copy_candidates.append(filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
473 |
else: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
474 |
# Impossible case, the post-merge file status cannot be None on |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
475 |
# one side and Something on the other side. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
476 |
assert False, "unreachable" |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
477 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
478 |
# Iteration over remaining d2 content deal with the first column of the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
479 |
# table. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
480 |
for filename, d2 in diff_p2.items(): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
481 |
_process_other_unchanged(md, mas, filename, d2) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
482 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
483 |
for filename in copy_candidates: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
484 |
copy_info = ctx[filename].renamed() |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
485 |
if copy_info: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
486 |
source, srcnode = copy_info |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
487 |
if source in p1_ctx and p1_ctx[source].filenode() == srcnode: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
488 |
md.mark_copied_from_p1(source, filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
489 |
elif source in p2_ctx and p2_ctx[source].filenode() == srcnode: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
490 |
md.mark_copied_from_p2(source, filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
491 |
return md |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
492 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
493 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
494 |
def _find(manifest, filename): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
495 |
"""return the associate filenode or None""" |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
496 |
if filename not in manifest: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
497 |
return None |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
498 |
return manifest.find(filename)[0] |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
499 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
500 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
501 |
def _process_other_unchanged(md, mas, filename, diff): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
502 |
source_node = diff[0][0] |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
503 |
target_node = diff[1][0] |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
504 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
505 |
if source_node is not None and target_node is None: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
506 |
if any(not _find(ma, filename) == source_node for ma in mas): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
507 |
# case 🄲 of 🄷 |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
508 |
md.mark_removed(filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
509 |
# else, we have case 🄱 or 🄶 : no change need to be recorded |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
510 |
elif source_node is None and target_node is not None: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
511 |
if any(_find(ma, filename) is not None for ma in mas): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
512 |
# case 🄴 or 🄹 |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
513 |
md.mark_salvaged(filename) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
514 |
# else, we have case 🄳 or 🄸 : simple merge without intervention |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
515 |
elif source_node is not None and target_node is not None: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
516 |
# case 🄵 or 🄺 : simple merge without intervention |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
517 |
# |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
518 |
# In buggy case where source_node is not an ancestors of target_node. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
519 |
# There should have a been a new filenode created, recording this as |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
520 |
# "modified". We do not deal with them yet. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
521 |
pass |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
522 |
else: |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
523 |
# An impossible case, the diff algorithm should not return entry if the |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
524 |
# file is missing on both side. |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
525 |
assert False, "unreachable" |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
526 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
527 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
528 |
def _missing_from_all_ancestors(mas, filename): |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
529 |
return all(_find(ma, filename) is None for ma in mas) |
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
530 |
|
47ad23549b81
changing-files: add clean computation of changed file for merges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45667
diff
changeset
|
531 |
|
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
532 |
def computechangesetfilesadded(ctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45764
diff
changeset
|
533 |
"""return the list of files added in a changeset""" |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
534 |
added = [] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
535 |
for f in ctx.files(): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
536 |
if not any(f in p for p in ctx.parents()): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
537 |
added.append(f) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
538 |
return added |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
539 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
540 |
|
44941
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
541 |
def get_removal_filter(ctx, x=None): |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
542 |
"""return a function to detect files "wrongly" detected as `removed` |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
543 |
|
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
544 |
When a file is removed relative to p1 in a merge, this |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
545 |
function determines whether the absence is due to a |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
546 |
deletion from a parent, or whether the merge commit |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
547 |
itself deletes the file. We decide this by doing a |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
548 |
simplified three way merge of the manifest entry for |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
549 |
the file. There are two ways we decide the merge |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
550 |
itself didn't delete a file: |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
551 |
- neither parent (nor the merge) contain the file |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
552 |
- exactly one parent contains the file, and that |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
553 |
parent has the same filelog entry as the merge |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
554 |
ancestor (or all of them if there two). In other |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
555 |
words, that parent left the file unchanged while the |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
556 |
other one deleted it. |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
557 |
One way to think about this is that deleting a file is |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
558 |
similar to emptying it, so the list of changed files |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
559 |
should be similar either way. The computation |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
560 |
described above is not done directly in _filecommit |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
561 |
when creating the list of changed files, however |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
562 |
it does something very similar by comparing filelog |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
563 |
nodes. |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
564 |
""" |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
565 |
|
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
566 |
if x is not None: |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
567 |
p1, p2, m1, m2 = x |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
568 |
else: |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
569 |
p1 = ctx.p1() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
570 |
p2 = ctx.p2() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
571 |
m1 = p1.manifest() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
572 |
m2 = p2.manifest() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
573 |
|
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
574 |
@util.cachefunc |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
575 |
def mas(): |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
576 |
p1n = p1.node() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
577 |
p2n = p2.node() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
578 |
cahs = ctx.repo().changelog.commonancestorsheads(p1n, p2n) |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
579 |
if not cahs: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
580 |
cahs = [nullrev] |
44941
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
581 |
return [ctx.repo()[r].manifest() for r in cahs] |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
582 |
|
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
583 |
def deletionfromparent(f): |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
584 |
if f in m1: |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
585 |
return f not in m2 and all( |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
586 |
f in ma and ma.find(f) == m1.find(f) for ma in mas() |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
587 |
) |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
588 |
elif f in m2: |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
589 |
return all(f in ma and ma.find(f) == m2.find(f) for ma in mas()) |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
590 |
else: |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
591 |
return True |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
592 |
|
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
593 |
return deletionfromparent |
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
594 |
|
edd08aa193fb
files: extract code for extra filtering of the `removed` entry into copies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44940
diff
changeset
|
595 |
|
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
596 |
def computechangesetfilesremoved(ctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45764
diff
changeset
|
597 |
"""return the list of files removed in a changeset""" |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
598 |
removed = [] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
599 |
for f in ctx.files(): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
600 |
if f not in ctx: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
601 |
removed.append(f) |
44942
25512a65cefd
metadata: filter the `removed` set to only contains relevant data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44941
diff
changeset
|
602 |
if removed: |
25512a65cefd
metadata: filter the `removed` set to only contains relevant data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44941
diff
changeset
|
603 |
rf = get_removal_filter(ctx) |
25512a65cefd
metadata: filter the `removed` set to only contains relevant data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44941
diff
changeset
|
604 |
removed = [r for r in removed if not rf(r)] |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
605 |
return removed |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
606 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
607 |
|
45613
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
608 |
def computechangesetfilesmerged(ctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45764
diff
changeset
|
609 |
"""return the list of files merged in a changeset""" |
45613
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
610 |
merged = [] |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
611 |
if len(ctx.parents()) < 2: |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
612 |
return merged |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
613 |
for f in ctx.files(): |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
614 |
if f in ctx: |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
615 |
fctx = ctx[f] |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
616 |
parents = fctx._filelog.parents(fctx._filenode) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46815
diff
changeset
|
617 |
if parents[1] != ctx.repo().nullid: |
45613
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
618 |
merged.append(f) |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
619 |
return merged |
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
620 |
|
ddcee0b0fd67
changing-files: add a utility to compute the merged files post-commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45611
diff
changeset
|
621 |
|
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
622 |
def computechangesetcopies(ctx): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
623 |
"""return the copies data for a changeset |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
624 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
625 |
The copies data are returned as a pair of dictionnary (p1copies, p2copies). |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
626 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
627 |
Each dictionnary are in the form: `{newname: oldname}` |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
628 |
""" |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
629 |
p1copies = {} |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
630 |
p2copies = {} |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
631 |
p1 = ctx.p1() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
632 |
p2 = ctx.p2() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
633 |
narrowmatch = ctx._repo.narrowmatch() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
634 |
for dst in ctx.files(): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
635 |
if not narrowmatch(dst) or dst not in ctx: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
636 |
continue |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
637 |
copied = ctx[dst].renamed() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
638 |
if not copied: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
639 |
continue |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
640 |
src, srcnode = copied |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
641 |
if src in p1 and p1[src].filenode() == srcnode: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
642 |
p1copies[dst] = src |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
643 |
elif src in p2 and p2[src].filenode() == srcnode: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
644 |
p2copies[dst] = src |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
645 |
return p1copies, p2copies |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
646 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
647 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
648 |
def encodecopies(files, copies): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
649 |
items = [] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
650 |
for i, dst in enumerate(files): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
651 |
if dst in copies: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
652 |
items.append(b'%d\0%s' % (i, copies[dst])) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
653 |
if len(items) != len(copies): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
654 |
raise error.ProgrammingError( |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
655 |
b'some copy targets missing from file list' |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
656 |
) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
657 |
return b"\n".join(items) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
658 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
659 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
660 |
def decodecopies(files, data): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
661 |
try: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
662 |
copies = {} |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
663 |
if not data: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
664 |
return copies |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
665 |
for l in data.split(b'\n'): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
666 |
strindex, src = l.split(b'\0') |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
667 |
i = int(strindex) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
668 |
dst = files[i] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
669 |
copies[dst] = src |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
670 |
return copies |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
671 |
except (ValueError, IndexError): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
672 |
# Perhaps someone had chosen the same key name (e.g. "p1copies") and |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
673 |
# used different syntax for the value. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
674 |
return None |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
675 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
676 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
677 |
def encodefileindices(files, subset): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
678 |
subset = set(subset) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
679 |
indices = [] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
680 |
for i, f in enumerate(files): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
681 |
if f in subset: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
682 |
indices.append(b'%d' % i) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
683 |
return b'\n'.join(indices) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
684 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
685 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
686 |
def decodefileindices(files, data): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
687 |
try: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
688 |
subset = [] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
689 |
if not data: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
690 |
return subset |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
691 |
for strindex in data.split(b'\n'): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
692 |
i = int(strindex) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
693 |
if i < 0 or i >= len(files): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
694 |
return None |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
695 |
subset.append(files[i]) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
696 |
return subset |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
697 |
except (ValueError, IndexError): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
698 |
# Perhaps someone had chosen the same key name (e.g. "added") and |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
699 |
# used different syntax for the value. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
700 |
return None |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
701 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
702 |
|
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
703 |
# see mercurial/helptext/internals/revlogs.txt for details about the format |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
704 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
705 |
ACTION_MASK = int("111" "00", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
706 |
# note: untouched file used as copy source will as `000` for this mask. |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
707 |
ADDED_FLAG = int("001" "00", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
708 |
MERGED_FLAG = int("010" "00", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
709 |
REMOVED_FLAG = int("011" "00", 2) |
45669
e53778ad64bf
salvaged: persist the salvaged set on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45668
diff
changeset
|
710 |
SALVAGED_FLAG = int("100" "00", 2) |
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
711 |
TOUCHED_FLAG = int("101" "00", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
712 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
713 |
COPIED_MASK = int("11", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
714 |
COPIED_FROM_P1_FLAG = int("10", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
715 |
COPIED_FROM_P2_FLAG = int("11", 2) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
716 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
717 |
# structure is <flag><filename-end><copy-source> |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
718 |
INDEX_HEADER = struct.Struct(">L") |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
719 |
INDEX_ENTRY = struct.Struct(">bLL") |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
720 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
721 |
|
45569
64d18e9e8508
sidedata: rename `encode_copies_sidedata` to `encode_files_sidedata`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45507
diff
changeset
|
722 |
def encode_files_sidedata(files): |
45669
e53778ad64bf
salvaged: persist the salvaged set on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45668
diff
changeset
|
723 |
all_files = set(files.touched) |
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
724 |
all_files.update(files.copied_from_p1.values()) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
725 |
all_files.update(files.copied_from_p2.values()) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
726 |
all_files = sorted(all_files) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
727 |
file_idx = {f: i for (i, f) in enumerate(all_files)} |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
728 |
file_idx[None] = 0 |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
729 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
730 |
chunks = [INDEX_HEADER.pack(len(all_files))] |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
731 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
732 |
filename_length = 0 |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
733 |
for f in all_files: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
734 |
filename_size = len(f) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
735 |
filename_length += filename_size |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
736 |
flag = 0 |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
737 |
if f in files.added: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
738 |
flag |= ADDED_FLAG |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
739 |
elif f in files.merged: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
740 |
flag |= MERGED_FLAG |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
741 |
elif f in files.removed: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
742 |
flag |= REMOVED_FLAG |
45669
e53778ad64bf
salvaged: persist the salvaged set on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45668
diff
changeset
|
743 |
elif f in files.salvaged: |
e53778ad64bf
salvaged: persist the salvaged set on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45668
diff
changeset
|
744 |
flag |= SALVAGED_FLAG |
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
745 |
elif f in files.touched: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
746 |
flag |= TOUCHED_FLAG |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
747 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
748 |
copy = None |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
749 |
if f in files.copied_from_p1: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
750 |
flag |= COPIED_FROM_P1_FLAG |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
751 |
copy = files.copied_from_p1.get(f) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
752 |
elif f in files.copied_from_p2: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
753 |
copy = files.copied_from_p2.get(f) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
754 |
flag |= COPIED_FROM_P2_FLAG |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
755 |
copy_idx = file_idx[copy] |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
756 |
chunks.append(INDEX_ENTRY.pack(flag, filename_length, copy_idx)) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
757 |
chunks.extend(all_files) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
758 |
return {sidedatamod.SD_FILES: b''.join(chunks)} |
45325
c6eea5804551
commitctx: extract sidedata encoding inside its own function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45323
diff
changeset
|
759 |
|
c6eea5804551
commitctx: extract sidedata encoding inside its own function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45323
diff
changeset
|
760 |
|
45635
9003e6524f78
changing-files: drop the now useless changelogrevision argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45634
diff
changeset
|
761 |
def decode_files_sidedata(sidedata): |
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
762 |
md = ChangingFiles() |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
763 |
raw = sidedata.get(sidedatamod.SD_FILES) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
764 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
765 |
if raw is None: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
766 |
return md |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
767 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
768 |
copies = [] |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
769 |
all_files = [] |
45571
7543b5072e84
sidedata: add a `decode_files_sidedata` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45569
diff
changeset
|
770 |
|
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
771 |
assert len(raw) >= INDEX_HEADER.size |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
772 |
total_files = INDEX_HEADER.unpack_from(raw, 0)[0] |
45571
7543b5072e84
sidedata: add a `decode_files_sidedata` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45569
diff
changeset
|
773 |
|
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
774 |
offset = INDEX_HEADER.size |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
775 |
file_offset_base = offset + (INDEX_ENTRY.size * total_files) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
776 |
file_offset_last = file_offset_base |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
777 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
778 |
assert len(raw) >= file_offset_base |
45571
7543b5072e84
sidedata: add a `decode_files_sidedata` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45569
diff
changeset
|
779 |
|
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
780 |
for idx in range(total_files): |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
781 |
flag, file_end, copy_idx = INDEX_ENTRY.unpack_from(raw, offset) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
782 |
file_end += file_offset_base |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
783 |
filename = raw[file_offset_last:file_end] |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
784 |
filesize = file_end - file_offset_last |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
785 |
assert len(filename) == filesize |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
786 |
offset += INDEX_ENTRY.size |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
787 |
file_offset_last = file_end |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
788 |
all_files.append(filename) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
789 |
if flag & ACTION_MASK == ADDED_FLAG: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
790 |
md.mark_added(filename) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
791 |
elif flag & ACTION_MASK == MERGED_FLAG: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
792 |
md.mark_merged(filename) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
793 |
elif flag & ACTION_MASK == REMOVED_FLAG: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
794 |
md.mark_removed(filename) |
45669
e53778ad64bf
salvaged: persist the salvaged set on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45668
diff
changeset
|
795 |
elif flag & ACTION_MASK == SALVAGED_FLAG: |
e53778ad64bf
salvaged: persist the salvaged set on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45668
diff
changeset
|
796 |
md.mark_salvaged(filename) |
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
797 |
elif flag & ACTION_MASK == TOUCHED_FLAG: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
798 |
md.mark_touched(filename) |
45571
7543b5072e84
sidedata: add a `decode_files_sidedata` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45569
diff
changeset
|
799 |
|
45634
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
800 |
copied = None |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
801 |
if flag & COPIED_MASK == COPIED_FROM_P1_FLAG: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
802 |
copied = md.mark_copied_from_p1 |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
803 |
elif flag & COPIED_MASK == COPIED_FROM_P2_FLAG: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
804 |
copied = md.mark_copied_from_p2 |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
805 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
806 |
if copied is not None: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
807 |
copies.append((copied, filename, copy_idx)) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
808 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
809 |
for copied, filename, copy_idx in copies: |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
810 |
copied(all_files[copy_idx], filename) |
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
811 |
|
9a6b409b8ebc
changing-files: rework the way we store changed files in side-data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45623
diff
changeset
|
812 |
return md |
45571
7543b5072e84
sidedata: add a `decode_files_sidedata` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45569
diff
changeset
|
813 |
|
7543b5072e84
sidedata: add a `decode_files_sidedata` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45569
diff
changeset
|
814 |
|
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
815 |
def _getsidedata(srcrepo, rev): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
816 |
ctx = srcrepo[rev] |
45663
cf474af69766
changing-files: split the changing files computation from encoding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45660
diff
changeset
|
817 |
files = compute_all_files_changes(ctx) |
45734
53c265a6fc83
sidedata: return enough data to set the proper flag in the future
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45728
diff
changeset
|
818 |
return encode_files_sidedata(files), files.has_copies_info |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
819 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
820 |
|
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
821 |
def copies_sidedata_computer(repo, revlog, rev, existing_sidedata): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
822 |
return _getsidedata(repo, rev)[0] |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
823 |
|
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
824 |
|
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
825 |
def set_sidedata_spec_for_repo(repo): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
826 |
if requirementsmod.COPIESSDC_REQUIREMENT in repo.requirements: |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
827 |
repo.register_wanted_sidedata(sidedatamod.SD_FILES) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
828 |
repo.register_sidedata_computer( |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
829 |
b"changelog", |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
830 |
sidedatamod.SD_FILES, |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
831 |
(sidedatamod.SD_FILES,), |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
832 |
copies_sidedata_computer, |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
833 |
) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
834 |
|
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46618
diff
changeset
|
835 |
|
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
836 |
def getsidedataadder(srcrepo, destrepo): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
837 |
use_w = srcrepo.ui.configbool(b'experimental', b'worker.repository-upgrade') |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
838 |
if pycompat.iswindows or not use_w: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
839 |
return _get_simple_sidedata_adder(srcrepo, destrepo) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
840 |
else: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
841 |
return _get_worker_sidedata_adder(srcrepo, destrepo) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
842 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
843 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
844 |
def _sidedata_worker(srcrepo, revs_queue, sidedata_queue, tokens): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
845 |
"""The function used by worker precomputing sidedata |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
846 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
847 |
It read an input queue containing revision numbers |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
848 |
It write in an output queue containing (rev, <sidedata-map>) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
849 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
850 |
The `None` input value is used as a stop signal. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
851 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
852 |
The `tokens` semaphore is user to avoid having too many unprocessed |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
853 |
entries. The workers needs to acquire one token before fetching a task. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
854 |
They will be released by the consumer of the produced data. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
855 |
""" |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
856 |
tokens.acquire() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
857 |
rev = revs_queue.get() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
858 |
while rev is not None: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
859 |
data = _getsidedata(srcrepo, rev) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
860 |
sidedata_queue.put((rev, data)) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
861 |
tokens.acquire() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
862 |
rev = revs_queue.get() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
863 |
# processing of `None` is completed, release the token. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
864 |
tokens.release() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
865 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
866 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
867 |
BUFF_PER_WORKER = 50 |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
868 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
869 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
870 |
def _get_worker_sidedata_adder(srcrepo, destrepo): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
871 |
"""The parallel version of the sidedata computation |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
872 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
873 |
This code spawn a pool of worker that precompute a buffer of sidedata |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
874 |
before we actually need them""" |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
875 |
# avoid circular import copies -> scmutil -> worker -> copies |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
876 |
from . import worker |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
877 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
878 |
nbworkers = worker._numworkers(srcrepo.ui) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
879 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
880 |
tokens = multiprocessing.BoundedSemaphore(nbworkers * BUFF_PER_WORKER) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
881 |
revsq = multiprocessing.Queue() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
882 |
sidedataq = multiprocessing.Queue() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
883 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
884 |
assert srcrepo.filtername is None |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
885 |
# queue all tasks beforehand, revision numbers are small and it make |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
886 |
# synchronisation simpler |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
887 |
# |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
888 |
# Since the computation for each node can be quite expensive, the overhead |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
889 |
# of using a single queue is not revelant. In practice, most computation |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
890 |
# are fast but some are very expensive and dominate all the other smaller |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
891 |
# cost. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
892 |
for r in srcrepo.changelog.revs(): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
893 |
revsq.put(r) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
894 |
# queue the "no more tasks" markers |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
895 |
for i in range(nbworkers): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
896 |
revsq.put(None) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
897 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
898 |
allworkers = [] |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
899 |
for i in range(nbworkers): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
900 |
args = (srcrepo, revsq, sidedataq, tokens) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
901 |
w = multiprocessing.Process(target=_sidedata_worker, args=args) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
902 |
allworkers.append(w) |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
903 |
w.start() |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
904 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
905 |
# dictionnary to store results for revision higher than we one we are |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
906 |
# looking for. For example, if we need the sidedatamap for 42, and 43 is |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
907 |
# received, when shelve 43 for later use. |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
908 |
staging = {} |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
909 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
910 |
def sidedata_companion(revlog, rev): |
45734
53c265a6fc83
sidedata: return enough data to set the proper flag in the future
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45728
diff
changeset
|
911 |
data = {}, False |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
912 |
if util.safehasattr(revlog, b'filteredrevs'): # this is a changelog |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
913 |
# Is the data previously shelved ? |
46618
dde86beca388
copies: tests and fix parallel computation of changed file information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46113
diff
changeset
|
914 |
data = staging.pop(rev, None) |
dde86beca388
copies: tests and fix parallel computation of changed file information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46113
diff
changeset
|
915 |
if data is None: |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
916 |
# look at the queued result until we find the one we are lookig |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
917 |
# for (shelve the other ones) |
45734
53c265a6fc83
sidedata: return enough data to set the proper flag in the future
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45728
diff
changeset
|
918 |
r, data = sidedataq.get() |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
919 |
while r != rev: |
45734
53c265a6fc83
sidedata: return enough data to set the proper flag in the future
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45728
diff
changeset
|
920 |
staging[r] = data |
46618
dde86beca388
copies: tests and fix parallel computation of changed file information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46113
diff
changeset
|
921 |
r, data = sidedataq.get() |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
922 |
tokens.release() |
45735
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
923 |
sidedata, has_copies_info = data |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
924 |
new_flag = 0 |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
925 |
if has_copies_info: |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
926 |
new_flag = sidedataflag.REVIDX_HASCOPIESINFO |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
927 |
return False, (), sidedata, new_flag, 0 |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
928 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
929 |
return sidedata_companion |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
930 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
931 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
932 |
def _get_simple_sidedata_adder(srcrepo, destrepo): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
933 |
"""The simple version of the sidedata computation |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
934 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
935 |
It just compute it in the same thread on request""" |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
936 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
937 |
def sidedatacompanion(revlog, rev): |
45735
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
938 |
sidedata, has_copies_info = {}, False |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
939 |
if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog |
45734
53c265a6fc83
sidedata: return enough data to set the proper flag in the future
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45728
diff
changeset
|
940 |
sidedata, has_copies_info = _getsidedata(srcrepo, rev) |
45735
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
941 |
new_flag = 0 |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
942 |
if has_copies_info: |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
943 |
new_flag = sidedataflag.REVIDX_HASCOPIESINFO |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
944 |
|
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
945 |
return False, (), sidedata, new_flag, 0 |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
946 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
947 |
return sidedatacompanion |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
948 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
949 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
950 |
def getsidedataremover(srcrepo, destrepo): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
951 |
def sidedatacompanion(revlog, rev): |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
952 |
f = () |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
953 |
if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
954 |
if revlog.flags(rev) & sidedataflag.REVIDX_SIDEDATA: |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
955 |
f = ( |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
956 |
sidedatamod.SD_P1COPIES, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
957 |
sidedatamod.SD_P2COPIES, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
958 |
sidedatamod.SD_FILESADDED, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
959 |
sidedatamod.SD_FILESREMOVED, |
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
960 |
) |
45735
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45734
diff
changeset
|
961 |
return False, f, {}, 0, sidedataflag.REVIDX_HASCOPIESINFO |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
962 |
|
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
963 |
return sidedatacompanion |