author | Pulkit Goyal <7895pulkit@gmail.com> |
Mon, 10 Aug 2020 15:34:27 +0530 | |
changeset 45383 | f970cca30989 |
parent 45382 | 0652a533fe3c |
child 45385 | 05d19ca33b33 |
permissions | -rw-r--r-- |
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
1 |
from __future__ import absolute_import |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
2 |
|
45381
ede4c121239e
mergestate: use collections.defaultdict(dict) for _stateextras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45302
diff
changeset
|
3 |
import collections |
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
4 |
import errno |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
5 |
import shutil |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
6 |
import struct |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
7 |
|
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
8 |
from .i18n import _ |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
9 |
from .node import ( |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
10 |
bin, |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
11 |
hex, |
27031
8be0af32e513
mergestate: allow storing and retrieving change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27027
diff
changeset
|
12 |
nullhex, |
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
13 |
nullid, |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
14 |
) |
43090
1f339b503a40
py3: manually import pycompat.delattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43077
diff
changeset
|
15 |
from .pycompat import delattr |
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
16 |
from . import ( |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26570
diff
changeset
|
17 |
error, |
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
18 |
filemerge, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30486
diff
changeset
|
19 |
pycompat, |
25959
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
20 |
util, |
892d601f0d44
merge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25844
diff
changeset
|
21 |
) |
44060
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43798
diff
changeset
|
22 |
from .utils import hashutil |
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
23 |
|
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
24 |
_pack = struct.pack |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
25 |
_unpack = struct.unpack |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
26 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
27 |
|
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
28 |
def _droponode(data): |
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
29 |
# used for compatibility for v1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
30 |
bits = data.split(b'\0') |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
31 |
bits = bits[:-2] + bits[-1:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
32 |
return b'\0'.join(bits) |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
33 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
34 |
|
44871
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
35 |
def _filectxorabsent(hexnode, ctx, f): |
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
36 |
if hexnode == nullhex: |
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
37 |
return filemerge.absentfilectx(ctx, f) |
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
38 |
else: |
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
39 |
return ctx[f] |
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
40 |
|
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
41 |
|
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
42 |
# Merge state record types. See ``mergestate`` docs for more. |
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
43 |
|
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
44 |
#### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
45 |
# merge records which records metadata about a current merge |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
46 |
# exists only once in a mergestate |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
47 |
##### |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
48 |
RECORD_LOCAL = b'L' |
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
49 |
RECORD_OTHER = b'O' |
45161
9abdc0bd2ab9
mergestate: add comments about couple of record types and minor reorder
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45160
diff
changeset
|
50 |
# record merge labels |
9abdc0bd2ab9
mergestate: add comments about couple of record types and minor reorder
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45160
diff
changeset
|
51 |
RECORD_LABELS = b'l' |
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
52 |
# store info about merge driver used and it's state |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
53 |
RECORD_MERGE_DRIVER_STATE = b'm' |
45161
9abdc0bd2ab9
mergestate: add comments about couple of record types and minor reorder
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45160
diff
changeset
|
54 |
|
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
55 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
56 |
# record extra information about files, with one entry containing info about one |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
57 |
# file. Hence, multiple of them can exists |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
58 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
59 |
RECORD_FILE_VALUES = b'f' |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
60 |
|
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
61 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
62 |
# merge records which represents state of individual merges of files/folders |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
63 |
# These are top level records for each entry containing merge related info. |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
64 |
# Each record of these has info about one file. Hence multiple of them can |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
65 |
# exists |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
66 |
##### |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
67 |
RECORD_MERGED = b'F' |
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
68 |
RECORD_CHANGEDELETE_CONFLICT = b'C' |
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
69 |
RECORD_MERGE_DRIVER_MERGE = b'D' |
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
70 |
# the path was dir on one side of merge and file on another |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
71 |
RECORD_PATH_CONFLICT = b'P' |
45161
9abdc0bd2ab9
mergestate: add comments about couple of record types and minor reorder
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45160
diff
changeset
|
72 |
|
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
73 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
74 |
# possible state which a merge entry can have. These are stored inside top-level |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
75 |
# merge records mentioned just above. |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
76 |
##### |
37111
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
77 |
MERGE_RECORD_UNRESOLVED = b'u' |
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
78 |
MERGE_RECORD_RESOLVED = b'r' |
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
79 |
MERGE_RECORD_UNRESOLVED_PATH = b'pu' |
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
80 |
MERGE_RECORD_RESOLVED_PATH = b'pr' |
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
81 |
MERGE_RECORD_DRIVER_RESOLVED = b'd' |
44687
1b8fd4af3318
mergestate: store about files resolved in favour of other
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
82 |
# represents that the file was automatically merged in favor |
1b8fd4af3318
mergestate: store about files resolved in favour of other
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
83 |
# of other version. This info is used on commit. |
45382
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
84 |
# This is now deprecated and commit related information is now |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
85 |
# stored in RECORD_FILE_VALUES |
44687
1b8fd4af3318
mergestate: store about files resolved in favour of other
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
86 |
MERGE_RECORD_MERGED_OTHER = b'o' |
37111
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
87 |
|
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
88 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
89 |
# top level record which stores other unknown records. Multiple of these can |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
90 |
# exists |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
91 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
92 |
RECORD_OVERRIDE = b't' |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
93 |
|
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
94 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
95 |
# possible states which a merge driver can have. These are stored inside a |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
96 |
# RECORD_MERGE_DRIVER_STATE entry |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
97 |
##### |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
98 |
MERGE_DRIVER_STATE_UNMARKED = b'u' |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
99 |
MERGE_DRIVER_STATE_MARKED = b'm' |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
100 |
MERGE_DRIVER_STATE_SUCCESS = b's' |
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
101 |
|
45271
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
102 |
##### |
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
103 |
# legacy records which are no longer used but kept to prevent breaking BC |
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
104 |
##### |
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
105 |
# This record was release in 5.4 and usage was removed in 5.5 |
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
106 |
LEGACY_RECORD_RESOLVED_OTHER = b'R' |
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
107 |
|
45163
f69253935bf8
mergestate: document mergestate records in an organized way
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45162
diff
changeset
|
108 |
|
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
109 |
ACTION_FORGET = b'f' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
110 |
ACTION_REMOVE = b'r' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
111 |
ACTION_ADD = b'a' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
112 |
ACTION_GET = b'g' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
113 |
ACTION_PATH_CONFLICT = b'p' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
114 |
ACTION_PATH_CONFLICT_RESOLVE = b'pr' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
115 |
ACTION_ADD_MODIFIED = b'am' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
116 |
ACTION_CREATED = b'c' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
117 |
ACTION_DELETED_CHANGED = b'dc' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
118 |
ACTION_CHANGED_DELETED = b'cd' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
119 |
ACTION_MERGE = b'm' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
120 |
ACTION_LOCAL_DIR_RENAME_GET = b'dg' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
121 |
ACTION_DIR_RENAME_MOVE_LOCAL = b'dm' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
122 |
ACTION_KEEP = b'k' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
123 |
ACTION_EXEC = b'e' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
124 |
ACTION_CREATED_MERGE = b'cm' |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
125 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
126 |
|
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
127 |
class mergestate(object): |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
128 |
'''track 3-way merge state of individual files |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
129 |
|
27022
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
130 |
The merge state is stored on disk when needed. Two files are used: one with |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
131 |
an old format (version 1), and one with a new format (version 2). Version 2 |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
132 |
stores a superset of the data in version 1, including new kinds of records |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
133 |
in the future. For more about the new format, see the documentation for |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
134 |
`_readrecordsv2`. |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
135 |
|
27022
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
136 |
Each record can contain arbitrary content, and has an associated type. This |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
137 |
`type` should be a letter. If `type` is uppercase, the record is mandatory: |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
138 |
versions of Mercurial that don't support it should abort. If `type` is |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
139 |
lowercase, the record can be safely ignored. |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
140 |
|
27022
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
141 |
Currently known records: |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
142 |
|
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
143 |
L: the node of the "local" part of the merge (hexified version) |
20591
02c60e380fd0
merge: record the "other" node in merge state
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20590
diff
changeset
|
144 |
O: the node of the "other" part of the merge (hexified version) |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
145 |
F: a file to be merged entry |
27031
8be0af32e513
mergestate: allow storing and retrieving change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27027
diff
changeset
|
146 |
C: a change/delete or delete/change conflict |
26650
6ff5534c8afc
merge.mergestate: add support for persisting driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26649
diff
changeset
|
147 |
D: a file that the external merge driver will merge internally |
6ff5534c8afc
merge.mergestate: add support for persisting driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26649
diff
changeset
|
148 |
(experimental) |
34545
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
149 |
P: a path conflict (file vs directory) |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
150 |
m: the external merge driver defined for this merge plus its run state |
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
151 |
(experimental) |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30200
diff
changeset
|
152 |
f: a (filename, dictionary) tuple of optional values for a given file |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
153 |
l: the labels for the parts of the merge. |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
154 |
|
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
155 |
Merge driver run states (experimental): |
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
156 |
u: driver-resolved files unmarked -- needs to be run next time we're about |
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
157 |
to resolve or commit |
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
158 |
m: driver-resolved files marked -- only needs to be run before commit |
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
159 |
s: success/skipped -- does not need to be run any more |
27022
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
160 |
|
34545
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
161 |
Merge record states (stored in self._state, indexed by filename): |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
162 |
u: unresolved conflict |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
163 |
r: resolved conflict |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
164 |
pu: unresolved path conflict (file conflicts with directory) |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
165 |
pr: resolved path conflict |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
166 |
d: driver-resolved conflict |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
167 |
|
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
168 |
The resolve command transitions between 'u' and 'r' for conflicts and |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
169 |
'pu' and 'pr' for path conflicts. |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
170 |
''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
171 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
172 |
statepathv1 = b'merge/state' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
173 |
statepathv2 = b'merge/state2' |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
174 |
|
26987
416b2b7d3068
mergestate: add a constructor that sets up a clean merge state
Siddharth Agarwal <sid0@fb.com>
parents:
26986
diff
changeset
|
175 |
@staticmethod |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
176 |
def clean(repo, node=None, other=None, labels=None): |
26987
416b2b7d3068
mergestate: add a constructor that sets up a clean merge state
Siddharth Agarwal <sid0@fb.com>
parents:
26986
diff
changeset
|
177 |
"""Initialize a brand new merge state, removing any existing state on |
416b2b7d3068
mergestate: add a constructor that sets up a clean merge state
Siddharth Agarwal <sid0@fb.com>
parents:
26986
diff
changeset
|
178 |
disk.""" |
416b2b7d3068
mergestate: add a constructor that sets up a clean merge state
Siddharth Agarwal <sid0@fb.com>
parents:
26986
diff
changeset
|
179 |
ms = mergestate(repo) |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
180 |
ms.reset(node, other, labels) |
26987
416b2b7d3068
mergestate: add a constructor that sets up a clean merge state
Siddharth Agarwal <sid0@fb.com>
parents:
26986
diff
changeset
|
181 |
return ms |
416b2b7d3068
mergestate: add a constructor that sets up a clean merge state
Siddharth Agarwal <sid0@fb.com>
parents:
26986
diff
changeset
|
182 |
|
26991
2ddc92bae4a7
mergestate: add a constructor that reads state from disk
Siddharth Agarwal <sid0@fb.com>
parents:
26990
diff
changeset
|
183 |
@staticmethod |
2ddc92bae4a7
mergestate: add a constructor that reads state from disk
Siddharth Agarwal <sid0@fb.com>
parents:
26990
diff
changeset
|
184 |
def read(repo): |
2ddc92bae4a7
mergestate: add a constructor that reads state from disk
Siddharth Agarwal <sid0@fb.com>
parents:
26990
diff
changeset
|
185 |
"""Initialize the merge state, reading it from disk.""" |
2ddc92bae4a7
mergestate: add a constructor that reads state from disk
Siddharth Agarwal <sid0@fb.com>
parents:
26990
diff
changeset
|
186 |
ms = mergestate(repo) |
27005
3185c01c551c
mergestate: move _read() call to read constructor
Siddharth Agarwal <sid0@fb.com>
parents:
26991
diff
changeset
|
187 |
ms._read() |
26991
2ddc92bae4a7
mergestate: add a constructor that reads state from disk
Siddharth Agarwal <sid0@fb.com>
parents:
26990
diff
changeset
|
188 |
return ms |
2ddc92bae4a7
mergestate: add a constructor that reads state from disk
Siddharth Agarwal <sid0@fb.com>
parents:
26990
diff
changeset
|
189 |
|
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
190 |
def __init__(self, repo): |
27005
3185c01c551c
mergestate: move _read() call to read constructor
Siddharth Agarwal <sid0@fb.com>
parents:
26991
diff
changeset
|
191 |
"""Initialize the merge state. |
3185c01c551c
mergestate: move _read() call to read constructor
Siddharth Agarwal <sid0@fb.com>
parents:
26991
diff
changeset
|
192 |
|
3185c01c551c
mergestate: move _read() call to read constructor
Siddharth Agarwal <sid0@fb.com>
parents:
26991
diff
changeset
|
193 |
Do not use this directly! Instead call read() or clean().""" |
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
194 |
self._repo = repo |
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
195 |
self._dirty = False |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
196 |
self._labels = None |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
197 |
|
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
198 |
def reset(self, node=None, other=None, labels=None): |
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
199 |
self._state = {} |
45381
ede4c121239e
mergestate: use collections.defaultdict(dict) for _stateextras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45302
diff
changeset
|
200 |
self._stateextras = collections.defaultdict(dict) |
21261
6ca05c46aa95
mergestate: consistently set variables to None
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21203
diff
changeset
|
201 |
self._local = None |
6ca05c46aa95
mergestate: consistently set variables to None
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21203
diff
changeset
|
202 |
self._other = None |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
203 |
self._labels = labels |
43421
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43117
diff
changeset
|
204 |
for var in ('localctx', 'otherctx'): |
27130
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
205 |
if var in vars(self): |
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
206 |
delattr(self, var) |
7848
89e05c02a4af
resolve: move reset to localrepo.commit
Matt Mackall <mpm@selenic.com>
parents:
7768
diff
changeset
|
207 |
if node: |
89e05c02a4af
resolve: move reset to localrepo.commit
Matt Mackall <mpm@selenic.com>
parents:
7768
diff
changeset
|
208 |
self._local = node |
20591
02c60e380fd0
merge: record the "other" node in merge state
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20590
diff
changeset
|
209 |
self._other = other |
26768
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
210 |
self._readmergedriver = None |
26769
5b00ec4c05cb
merge.mergestate: set merge driver state to 's' if there's none present
Siddharth Agarwal <sid0@fb.com>
parents:
26768
diff
changeset
|
211 |
if self.mergedriver: |
37110
1b158ca37ea4
merge: use constants for merge driver state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37109
diff
changeset
|
212 |
self._mdstate = MERGE_DRIVER_STATE_SUCCESS |
26769
5b00ec4c05cb
merge.mergestate: set merge driver state to 's' if there's none present
Siddharth Agarwal <sid0@fb.com>
parents:
26768
diff
changeset
|
213 |
else: |
37110
1b158ca37ea4
merge: use constants for merge driver state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37109
diff
changeset
|
214 |
self._mdstate = MERGE_DRIVER_STATE_UNMARKED |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
215 |
shutil.rmtree(self._repo.vfs.join(b'merge'), True) |
27074
78b0c88ab0db
mergestate._resolve: store return code and action for each file
Siddharth Agarwal <sid0@fb.com>
parents:
27049
diff
changeset
|
216 |
self._results = {} |
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
217 |
self._dirty = False |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
218 |
|
6518 | 219 |
def _read(self): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
220 |
"""Analyse each record content to restore a serialized state from disk |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
221 |
|
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
222 |
This function process "record" entry produced by the de-serialization |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
223 |
of on disk file. |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
224 |
""" |
6518 | 225 |
self._state = {} |
45381
ede4c121239e
mergestate: use collections.defaultdict(dict) for _stateextras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45302
diff
changeset
|
226 |
self._stateextras = collections.defaultdict(dict) |
21261
6ca05c46aa95
mergestate: consistently set variables to None
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21203
diff
changeset
|
227 |
self._local = None |
6ca05c46aa95
mergestate: consistently set variables to None
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21203
diff
changeset
|
228 |
self._other = None |
43421
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43117
diff
changeset
|
229 |
for var in ('localctx', 'otherctx'): |
27130
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
230 |
if var in vars(self): |
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
231 |
delattr(self, var) |
26768
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
232 |
self._readmergedriver = None |
37110
1b158ca37ea4
merge: use constants for merge driver state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37109
diff
changeset
|
233 |
self._mdstate = MERGE_DRIVER_STATE_SUCCESS |
26986
1ee5e48f09d4
mergestate: raise structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26975
diff
changeset
|
234 |
unsupported = set() |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
235 |
records = self._readrecords() |
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
236 |
for rtype, record in records: |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
237 |
if rtype == RECORD_LOCAL: |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
238 |
self._local = bin(record) |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
239 |
elif rtype == RECORD_OTHER: |
20591
02c60e380fd0
merge: record the "other" node in merge state
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20590
diff
changeset
|
240 |
self._other = bin(record) |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
241 |
elif rtype == RECORD_MERGE_DRIVER_STATE: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
242 |
bits = record.split(b'\0', 1) |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
243 |
mdstate = bits[1] |
37110
1b158ca37ea4
merge: use constants for merge driver state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37109
diff
changeset
|
244 |
if len(mdstate) != 1 or mdstate not in ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
245 |
MERGE_DRIVER_STATE_UNMARKED, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
246 |
MERGE_DRIVER_STATE_MARKED, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
247 |
MERGE_DRIVER_STATE_SUCCESS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
248 |
): |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
249 |
# the merge driver should be idempotent, so just rerun it |
37110
1b158ca37ea4
merge: use constants for merge driver state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37109
diff
changeset
|
250 |
mdstate = MERGE_DRIVER_STATE_UNMARKED |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
251 |
|
26768
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
252 |
self._readmergedriver = bits[0] |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
253 |
self._mdstate = mdstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
254 |
elif rtype in ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
255 |
RECORD_MERGED, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
256 |
RECORD_CHANGEDELETE_CONFLICT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
257 |
RECORD_PATH_CONFLICT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
258 |
RECORD_MERGE_DRIVER_MERGE, |
45271
7fc3c5fbc65f
mergestate: fix BC breakage introduced because of removal of a merge record
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45166
diff
changeset
|
259 |
LEGACY_RECORD_RESOLVED_OTHER, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
260 |
): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
261 |
bits = record.split(b'\0') |
45382
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
262 |
# merge entry type MERGE_RECORD_MERGED_OTHER is deprecated |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
263 |
# and we now store related information in _stateextras, so |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
264 |
# lets write to _stateextras directly |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
265 |
if bits[1] == MERGE_RECORD_MERGED_OTHER: |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
266 |
self._stateextras[bits[0]][b'filenode-source'] = b'other' |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
267 |
else: |
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
268 |
self._state[bits[0]] = bits[1:] |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
269 |
elif rtype == RECORD_FILE_VALUES: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
270 |
filename, rawextras = record.split(b'\0', 1) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
271 |
extraparts = rawextras.split(b'\0') |
28009
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
272 |
extras = {} |
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
273 |
i = 0 |
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
274 |
while i < len(extraparts): |
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
275 |
extras[extraparts[i]] = extraparts[i + 1] |
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
276 |
i += 2 |
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
277 |
|
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
278 |
self._stateextras[filename] = extras |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
279 |
elif rtype == RECORD_LABELS: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
280 |
labels = record.split(b'\0', 2) |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
281 |
self._labels = [l for l in labels if len(l) > 0] |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
282 |
elif not rtype.islower(): |
26986
1ee5e48f09d4
mergestate: raise structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26975
diff
changeset
|
283 |
unsupported.add(rtype) |
45166
a5be403dd7a0
mergestate: document what mergestate._results is for
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45165
diff
changeset
|
284 |
# contains a mapping of form: |
a5be403dd7a0
mergestate: document what mergestate._results is for
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45165
diff
changeset
|
285 |
# {filename : (merge_return_value, action_to_be_performed} |
a5be403dd7a0
mergestate: document what mergestate._results is for
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45165
diff
changeset
|
286 |
# these are results of re-running merge process |
a5be403dd7a0
mergestate: document what mergestate._results is for
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45165
diff
changeset
|
287 |
# this dict is used to perform actions on dirstate caused by re-running |
a5be403dd7a0
mergestate: document what mergestate._results is for
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45165
diff
changeset
|
288 |
# the merge |
27074
78b0c88ab0db
mergestate._resolve: store return code and action for each file
Siddharth Agarwal <sid0@fb.com>
parents:
27049
diff
changeset
|
289 |
self._results = {} |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
290 |
self._dirty = False |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
291 |
|
26986
1ee5e48f09d4
mergestate: raise structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26975
diff
changeset
|
292 |
if unsupported: |
1ee5e48f09d4
mergestate: raise structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26975
diff
changeset
|
293 |
raise error.UnsupportedMergeRecords(unsupported) |
1ee5e48f09d4
mergestate: raise structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26975
diff
changeset
|
294 |
|
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
295 |
def _readrecords(self): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
296 |
"""Read merge state from disk and return a list of record (TYPE, data) |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
297 |
|
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
20945
diff
changeset
|
298 |
We read data from both v1 and v2 files and decide which one to use. |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
299 |
|
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
20945
diff
changeset
|
300 |
V1 has been used by version prior to 2.9.1 and contains less data than |
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
20945
diff
changeset
|
301 |
v2. We read both versions and check if no data in v2 contradicts |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
302 |
v1. If there is not contradiction we can safely assume that both v1 |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
303 |
and v2 were written at the same time and use the extract data in v2. If |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
304 |
there is contradiction we ignore v2 content as we assume an old version |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
20945
diff
changeset
|
305 |
of Mercurial has overwritten the mergestate file and left an old v2 |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
306 |
file around. |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
307 |
|
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
308 |
returns list of record [(TYPE, data), ...]""" |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
309 |
v1records = self._readrecordsv1() |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
310 |
v2records = self._readrecordsv2() |
26500
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
311 |
if self._v1v2match(v1records, v2records): |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
312 |
return v2records |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
313 |
else: |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
314 |
# v1 file is newer than v2 file, use it |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
315 |
# we have to infer the "other" changeset of the merge |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
316 |
# we cannot do better than that with v1 of the format |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
317 |
mctx = self._repo[None].parents()[-1] |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
318 |
v1records.append((RECORD_OTHER, mctx.hex())) |
26500
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
319 |
# add place holder "other" file node information |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
320 |
# nobody is using it yet so we do no need to fetch the data |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
321 |
# if mctx was wrong `mctx[bits[-2]]` may fails. |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
322 |
for idx, r in enumerate(v1records): |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
323 |
if r[0] == RECORD_MERGED: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
324 |
bits = r[1].split(b'\0') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
325 |
bits.insert(-2, b'') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
326 |
v1records[idx] = (r[0], b'\0'.join(bits)) |
26500
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
327 |
return v1records |
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
328 |
|
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
329 |
def _v1v2match(self, v1records, v2records): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
330 |
oldv2 = set() # old format version of v2 record |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
331 |
for rec in v2records: |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
332 |
if rec[0] == RECORD_LOCAL: |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
333 |
oldv2.add(rec) |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
334 |
elif rec[0] == RECORD_MERGED: |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
335 |
# drop the onode data (not contained in v1) |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
336 |
oldv2.add((RECORD_MERGED, _droponode(rec[1]))) |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
337 |
for rec in v1records: |
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
338 |
if rec not in oldv2: |
26500
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
339 |
return False |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
340 |
else: |
26500
5bd7c4c07f6d
merge.mergestate: factor out code to validate v1/v2 records
Siddharth Agarwal <sid0@fb.com>
parents:
26361
diff
changeset
|
341 |
return True |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
342 |
|
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
343 |
def _readrecordsv1(self): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
344 |
"""read on disk merge state for version 1 file |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
345 |
|
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
346 |
returns list of record [(TYPE, data), ...] |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
347 |
|
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
348 |
Note: the "F" data from this file are one entry short |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
349 |
(no "other file node" entry) |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
350 |
""" |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
351 |
records = [] |
6518 | 352 |
try: |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23656
diff
changeset
|
353 |
f = self._repo.vfs(self.statepathv1) |
6530
4b92591c69a7
merge: replace readline() call, missing from posixfile_nt
Patrick Mezard <pmezard@gmail.com>
parents:
6518
diff
changeset
|
354 |
for i, l in enumerate(f): |
4b92591c69a7
merge: replace readline() call, missing from posixfile_nt
Patrick Mezard <pmezard@gmail.com>
parents:
6518
diff
changeset
|
355 |
if i == 0: |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
356 |
records.append((RECORD_LOCAL, l[:-1])) |
6530
4b92591c69a7
merge: replace readline() call, missing from posixfile_nt
Patrick Mezard <pmezard@gmail.com>
parents:
6518
diff
changeset
|
357 |
else: |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
358 |
records.append((RECORD_MERGED, l[:-1])) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13323
diff
changeset
|
359 |
f.close() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25151
diff
changeset
|
360 |
except IOError as err: |
6518 | 361 |
if err.errno != errno.ENOENT: |
362 |
raise |
|
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
363 |
return records |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
364 |
|
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
365 |
def _readrecordsv2(self): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
366 |
"""read on disk merge state for version 2 file |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
367 |
|
27022
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
368 |
This format is a list of arbitrary records of the form: |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
369 |
|
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
370 |
[type][length][content] |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
371 |
|
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
372 |
`type` is a single character, `length` is a 4 byte integer, and |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
373 |
`content` is an arbitrary byte sequence of length `length`. |
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
374 |
|
27027
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
375 |
Mercurial versions prior to 3.7 have a bug where if there are |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
376 |
unsupported mandatory merge records, attempting to clear out the merge |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
377 |
state with hg update --clean or similar aborts. The 't' record type |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
378 |
works around that by writing out what those versions treat as an |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
379 |
advisory record, but later versions interpret as special: the first |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
380 |
character is the 'real' record type and everything onwards is the data. |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
381 |
|
27022
35102876d648
mergestate: move binary format documentation into _readrecordsv2
Siddharth Agarwal <sid0@fb.com>
parents:
27006
diff
changeset
|
382 |
Returns list of records [(TYPE, data), ...].""" |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
383 |
records = [] |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
384 |
try: |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23656
diff
changeset
|
385 |
f = self._repo.vfs(self.statepathv2) |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
386 |
data = f.read() |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
387 |
off = 0 |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
388 |
end = len(data) |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
389 |
while off < end: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
390 |
rtype = data[off : off + 1] |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
391 |
off += 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 |
length = _unpack(b'>I', data[off : (off + 4)])[0] |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
393 |
off += 4 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
394 |
record = data[off : (off + length)] |
20607
abd448767465
merge: fix spelling of length
Olle Lundberg <geek@nerd.sh>
parents:
20594
diff
changeset
|
395 |
off += length |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
396 |
if rtype == RECORD_OVERRIDE: |
36537
1d99260c3a81
py3: slice over bytes to prevent getting ascii values
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36477
diff
changeset
|
397 |
rtype, record = record[0:1], record[1:] |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
398 |
records.append((rtype, record)) |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
399 |
f.close() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25151
diff
changeset
|
400 |
except IOError as err: |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
401 |
if err.errno != errno.ENOENT: |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
402 |
raise |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
403 |
return records |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
404 |
|
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
405 |
@util.propertycache |
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
406 |
def mergedriver(self): |
26768
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
407 |
# protect against the following: |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
408 |
# - A configures a malicious merge driver in their hgrc, then |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
409 |
# pauses the merge |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
410 |
# - A edits their hgrc to remove references to the merge driver |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
411 |
# - A gives a copy of their entire repo, including .hg, to B |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
412 |
# - B inspects .hgrc and finds it to be clean |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
413 |
# - B then continues the merge and the malicious merge driver |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
414 |
# gets invoked |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 |
configmergedriver = self._repo.ui.config( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 |
b'experimental', b'mergedriver' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
418 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
419 |
self._readmergedriver is not None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
420 |
and self._readmergedriver != configmergedriver |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
421 |
): |
26768
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
422 |
raise error.ConfigError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
423 |
_(b"merge driver changed since merge started"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
424 |
hint=_(b"revert merge driver change or abort merge"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
425 |
) |
26768
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
426 |
|
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
427 |
return configmergedriver |
ac68769a5985
merge.mergestate: only check for merge driver when property is accessed
Siddharth Agarwal <sid0@fb.com>
parents:
26766
diff
changeset
|
428 |
|
26765
45976219eb80
merge.mergestate: add a way to get the other side of the merge
Siddharth Agarwal <sid0@fb.com>
parents:
26752
diff
changeset
|
429 |
@util.propertycache |
44215
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
430 |
def local(self): |
27130
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
431 |
if self._local is None: |
44215
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
432 |
msg = b"local accessed but self._local isn't set" |
31646 | 433 |
raise error.ProgrammingError(msg) |
44215
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
434 |
return self._local |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
435 |
|
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
436 |
@util.propertycache |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
437 |
def localctx(self): |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
438 |
return self._repo[self.local] |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
439 |
|
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
440 |
@util.propertycache |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
441 |
def other(self): |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
442 |
if self._other is None: |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
443 |
msg = b"other accessed but self._other isn't set" |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
444 |
raise error.ProgrammingError(msg) |
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
445 |
return self._other |
27130
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
446 |
|
6f045b563fa5
mergestate: add a cached property accessor for the local context
Siddharth Agarwal <sid0@fb.com>
parents:
27129
diff
changeset
|
447 |
@util.propertycache |
26765
45976219eb80
merge.mergestate: add a way to get the other side of the merge
Siddharth Agarwal <sid0@fb.com>
parents:
26752
diff
changeset
|
448 |
def otherctx(self): |
44215
b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
Martin von Zweigbergk <martinvonz@google.com>
parents:
44212
diff
changeset
|
449 |
return self._repo[self.other] |
26649
f618b6aa8cdd
merge.mergestate: add support for persisting a custom merge driver
Siddharth Agarwal <sid0@fb.com>
parents:
26641
diff
changeset
|
450 |
|
21264
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
451 |
def active(self): |
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
452 |
"""Whether mergestate is active. |
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
453 |
|
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
454 |
Returns True if there appears to be mergestate. This is a rough proxy |
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
455 |
for "is a merge in progress." |
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
456 |
""" |
44394
5e3402a0b868
mergestate: determine if active without looking for state files on disk
Martin von Zweigbergk <martinvonz@google.com>
parents:
44383
diff
changeset
|
457 |
return bool(self._local) or bool(self._state) |
21264
4e932dc5c113
resolve: abort when not applicable (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21261
diff
changeset
|
458 |
|
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
459 |
def commit(self): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
460 |
"""Write current state on disk (if necessary)""" |
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
461 |
if self._dirty: |
27006
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
462 |
records = self._makerecords() |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
463 |
self._writerecords(records) |
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
464 |
self._dirty = False |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
465 |
|
27006
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
466 |
def _makerecords(self): |
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
467 |
records = [] |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
468 |
records.append((RECORD_LOCAL, hex(self._local))) |
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
469 |
records.append((RECORD_OTHER, hex(self._other))) |
27006
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
470 |
if self.mergedriver: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
471 |
records.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
472 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
473 |
RECORD_MERGE_DRIVER_STATE, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
474 |
b'\0'.join([self.mergedriver, self._mdstate]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
475 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
476 |
) |
34560
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
477 |
# Write out state items. In all cases, the value of the state map entry |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
478 |
# is written as the contents of the record. The record type depends on |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
479 |
# the type of state that is stored, and capital-letter records are used |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
480 |
# to prevent older versions of Mercurial that do not support the feature |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
481 |
# from loading them. |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43104
diff
changeset
|
482 |
for filename, v in pycompat.iteritems(self._state): |
37111
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
483 |
if v[0] == MERGE_RECORD_DRIVER_RESOLVED: |
34560
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
484 |
# Driver-resolved merge. These are stored in 'D' records. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
485 |
records.append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
486 |
(RECORD_MERGE_DRIVER_MERGE, b'\0'.join([filename] + v)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
487 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
488 |
elif v[0] in ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
489 |
MERGE_RECORD_UNRESOLVED_PATH, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
490 |
MERGE_RECORD_RESOLVED_PATH, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
491 |
): |
34560
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
492 |
# Path conflicts. These are stored in 'P' records. The current |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
493 |
# resolution state ('pu' or 'pr') is stored within the record. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
494 |
records.append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
495 |
(RECORD_PATH_CONFLICT, b'\0'.join([filename] + v)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
496 |
) |
27031
8be0af32e513
mergestate: allow storing and retrieving change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27027
diff
changeset
|
497 |
elif v[1] == nullhex or v[6] == nullhex: |
34560
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
498 |
# Change/Delete or Delete/Change conflicts. These are stored in |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
499 |
# 'C' records. v[1] is the local file, and is nullhex when the |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
500 |
# file is deleted locally ('dc'). v[6] is the remote file, and |
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
501 |
# is nullhex when the file is deleted remotely ('cd'). |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
502 |
records.append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
503 |
(RECORD_CHANGEDELETE_CONFLICT, b'\0'.join([filename] + v)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
504 |
) |
27006
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
505 |
else: |
34560
1248aa48cac9
merge: improve comments in mergestate._makerecords
Mark Thomas <mbthomas@fb.com>
parents:
34555
diff
changeset
|
506 |
# Normal files. These are stored in 'F' records. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
507 |
records.append((RECORD_MERGED, b'\0'.join([filename] + v))) |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43104
diff
changeset
|
508 |
for filename, extras in sorted(pycompat.iteritems(self._stateextras)): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
509 |
rawextras = b'\0'.join( |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43104
diff
changeset
|
510 |
b'%s\0%s' % (k, v) for k, v in pycompat.iteritems(extras) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
511 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
512 |
records.append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
513 |
(RECORD_FILE_VALUES, b'%s\0%s' % (filename, rawextras)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
514 |
) |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
515 |
if self._labels is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
516 |
labels = b'\0'.join(self._labels) |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
517 |
records.append((RECORD_LABELS, labels)) |
27006
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
518 |
return records |
9d58dc193c46
mergestate.commit: factor out making the list of records
Siddharth Agarwal <sid0@fb.com>
parents:
27005
diff
changeset
|
519 |
|
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
520 |
def _writerecords(self, records): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
521 |
"""Write current state on disk (both v1 and v2)""" |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
522 |
self._writerecordsv1(records) |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
523 |
self._writerecordsv2(records) |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
524 |
|
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
525 |
def _writerecordsv1(self, records): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
526 |
"""Write current state on disk in a version 1 file""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
527 |
f = self._repo.vfs(self.statepathv1, b'wb') |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
528 |
irecords = iter(records) |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
29148
diff
changeset
|
529 |
lrecords = next(irecords) |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
530 |
assert lrecords[0] == RECORD_LOCAL |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
531 |
f.write(hex(self._local) + b'\n') |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
532 |
for rtype, data in irecords: |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
533 |
if rtype == RECORD_MERGED: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
534 |
f.write(b'%s\n' % _droponode(data)) |
20589
31993cd23b11
merge: change the merge state serialisation to use a record based logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20588
diff
changeset
|
535 |
f.close() |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
536 |
|
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
537 |
def _writerecordsv2(self, records): |
27027
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
538 |
"""Write current state on disk in a version 2 file |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
539 |
|
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
540 |
See the docstring for _readrecordsv2 for why we use 't'.""" |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
27022
diff
changeset
|
541 |
# these are the records that all version 2 clients can read |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
542 |
allowlist = (RECORD_LOCAL, RECORD_OTHER, RECORD_MERGED) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
543 |
f = self._repo.vfs(self.statepathv2, b'wb') |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
544 |
for key, data in records: |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
545 |
assert len(key) == 1 |
37109
a532b2f54f95
merge: use constants for merge state record types
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37107
diff
changeset
|
546 |
if key not in allowlist: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
547 |
key, data = RECORD_OVERRIDE, b'%s%s' % (key, data) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
548 |
format = b'>sI%is' % len(data) |
20590
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
549 |
f.write(_pack(format, key, len(data), data)) |
2b7d54e929b4
merge: introduce new format for the state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20589
diff
changeset
|
550 |
f.close() |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
551 |
|
41155
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
552 |
@staticmethod |
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
553 |
def getlocalkey(path): |
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
554 |
"""hash the path of a local file context for storage in the .hg/merge |
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
555 |
directory.""" |
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
556 |
|
44060
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43798
diff
changeset
|
557 |
return hex(hashutil.sha1(path).digest()) |
41155
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
558 |
|
18338
384df4db6520
merge: merge file flags together with file content
Mads Kiilerich <mads@kiilerich.com>
parents:
18336
diff
changeset
|
559 |
def add(self, fcl, fco, fca, fd): |
20652
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
560 |
"""add a new (potentially?) conflicting file the merge state |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
561 |
fcl: file context for local, |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
562 |
fco: file context for remote, |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
563 |
fca: file context for ancestors, |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
564 |
fd: file path of the resulting merge. |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
565 |
|
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
566 |
note: also write the local version to the `.hg/merge` directory. |
2a4871c2511d
merge: adds documentation to the mergestate class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20651
diff
changeset
|
567 |
""" |
27049
0d61f7ec7f76
mergestate.add: store absentfilectxes as nullhex
Siddharth Agarwal <sid0@fb.com>
parents:
27048
diff
changeset
|
568 |
if fcl.isabsent(): |
41155
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
569 |
localkey = nullhex |
27049
0d61f7ec7f76
mergestate.add: store absentfilectxes as nullhex
Siddharth Agarwal <sid0@fb.com>
parents:
27048
diff
changeset
|
570 |
else: |
41155
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
571 |
localkey = mergestate.getlocalkey(fcl.path()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
572 |
self._repo.vfs.write(b'merge/' + localkey, fcl.data()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
573 |
self._state[fd] = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
574 |
MERGE_RECORD_UNRESOLVED, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
575 |
localkey, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
576 |
fcl.path(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
577 |
fca.path(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
578 |
hex(fca.filenode()), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
579 |
fco.path(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
580 |
hex(fco.filenode()), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
581 |
fcl.flags(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
582 |
] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
583 |
self._stateextras[fd] = {b'ancestorlinknode': hex(fca.node())} |
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
584 |
self._dirty = True |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
585 |
|
45159
e05a488cbed0
mergestate: rename addpath() -> addpathonflict() to prevent confusion
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44939
diff
changeset
|
586 |
def addpathconflict(self, path, frename, forigin): |
34545
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
587 |
"""add a new conflicting path to the merge state |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
588 |
path: the path that conflicts |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
589 |
frename: the filename the conflicting file was renamed to |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
590 |
forigin: origin of the file ('l' or 'r' for local/remote) |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
591 |
""" |
37111
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
592 |
self._state[path] = [MERGE_RECORD_UNRESOLVED_PATH, frename, forigin] |
34545
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
593 |
self._dirty = True |
1913162854f2
merge: add pathconflict merge state
Mark Thomas <mbthomas@fb.com>
parents:
34522
diff
changeset
|
594 |
|
44687
1b8fd4af3318
mergestate: store about files resolved in favour of other
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
595 |
def addmergedother(self, path): |
45382
0652a533fe3c
mergestate: use _stateextras instead of merge records for commit related info
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45381
diff
changeset
|
596 |
self._stateextras[path] = {b'filenode-source': b'other'} |
44687
1b8fd4af3318
mergestate: store about files resolved in favour of other
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
597 |
self._dirty = True |
1b8fd4af3318
mergestate: store about files resolved in favour of other
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
598 |
|
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
599 |
def __contains__(self, dfile): |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
600 |
return dfile in self._state |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
601 |
|
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
602 |
def __getitem__(self, dfile): |
6518 | 603 |
return self._state[dfile][0] |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
604 |
|
6518 | 605 |
def __iter__(self): |
21268
a0b8a912ec81
merge: simplify mergestate iter
Mads Kiilerich <mads@kiilerich.com>
parents:
21266
diff
changeset
|
606 |
return iter(sorted(self._state)) |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
607 |
|
19285
feaf5749d7a4
merge: add a files method to the mergestate class
Bryan O'Sullivan <bryano@fb.com>
parents:
19226
diff
changeset
|
608 |
def files(self): |
feaf5749d7a4
merge: add a files method to the mergestate class
Bryan O'Sullivan <bryano@fb.com>
parents:
19226
diff
changeset
|
609 |
return self._state.keys() |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
610 |
|
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6425
diff
changeset
|
611 |
def mark(self, dfile, state): |
6518 | 612 |
self._state[dfile][0] = state |
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12279
diff
changeset
|
613 |
self._dirty = True |
20651
c1a52dd56eb4
merge: add blank line between mergestate's method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20642
diff
changeset
|
614 |
|
26766
a83110faece1
merge.mergestate: add a way to get the merge driver state
Siddharth Agarwal <sid0@fb.com>
parents:
26765
diff
changeset
|
615 |
def mdstate(self): |
a83110faece1
merge.mergestate: add a way to get the merge driver state
Siddharth Agarwal <sid0@fb.com>
parents:
26765
diff
changeset
|
616 |
return self._mdstate |
a83110faece1
merge.mergestate: add a way to get the merge driver state
Siddharth Agarwal <sid0@fb.com>
parents:
26765
diff
changeset
|
617 |
|
21266
19d6fec60b81
resolve: print message when no unresolved files remain (issue4214)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21264
diff
changeset
|
618 |
def unresolved(self): |
19d6fec60b81
resolve: print message when no unresolved files remain (issue4214)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21264
diff
changeset
|
619 |
"""Obtain the paths of unresolved files.""" |
19d6fec60b81
resolve: print message when no unresolved files remain (issue4214)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21264
diff
changeset
|
620 |
|
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43104
diff
changeset
|
621 |
for f, entry in pycompat.iteritems(self._state): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
622 |
if entry[0] in ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
623 |
MERGE_RECORD_UNRESOLVED, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
624 |
MERGE_RECORD_UNRESOLVED_PATH, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
625 |
): |
21266
19d6fec60b81
resolve: print message when no unresolved files remain (issue4214)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21264
diff
changeset
|
626 |
yield f |
19d6fec60b81
resolve: print message when no unresolved files remain (issue4214)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21264
diff
changeset
|
627 |
|
26740
f4a27c05c43f
merge.mergestate: add a generator for driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26682
diff
changeset
|
628 |
def driverresolved(self): |
f4a27c05c43f
merge.mergestate: add a generator for driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26682
diff
changeset
|
629 |
"""Obtain the paths of driver-resolved files.""" |
f4a27c05c43f
merge.mergestate: add a generator for driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26682
diff
changeset
|
630 |
|
f4a27c05c43f
merge.mergestate: add a generator for driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26682
diff
changeset
|
631 |
for f, entry in self._state.items(): |
37111
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
632 |
if entry[0] == MERGE_RECORD_DRIVER_RESOLVED: |
26740
f4a27c05c43f
merge.mergestate: add a generator for driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26682
diff
changeset
|
633 |
yield f |
f4a27c05c43f
merge.mergestate: add a generator for driver-resolved files
Siddharth Agarwal <sid0@fb.com>
parents:
26682
diff
changeset
|
634 |
|
28009
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
635 |
def extras(self, filename): |
45381
ede4c121239e
mergestate: use collections.defaultdict(dict) for _stateextras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45302
diff
changeset
|
636 |
return self._stateextras[filename] |
28009
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
637 |
|
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
638 |
def _resolve(self, preresolve, dfile, wctx): |
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
639 |
"""rerun merge process for file path `dfile`. |
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
640 |
Returns whether the merge was completed and the return value of merge |
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
641 |
obtained from filemerge._filemerge(). |
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
642 |
""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
643 |
if self[dfile] in (MERGE_RECORD_RESOLVED, MERGE_RECORD_DRIVER_RESOLVED): |
26616
2f1fce0d4e86
merge.mergestate._resolve: also return completed status
Siddharth Agarwal <sid0@fb.com>
parents:
26615
diff
changeset
|
644 |
return True, 0 |
20593
3678707e4017
merge: add "other" file node in the merge state file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20592
diff
changeset
|
645 |
stateentry = self._state[dfile] |
41155
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
646 |
state, localkey, lfile, afile, anode, ofile, onode, flags = stateentry |
20594
ba619c50a355
resolve: use "other" changeset from merge state (issue4163)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20593
diff
changeset
|
647 |
octx = self._repo[self._other] |
28011
8abd9f785030
merge: add file ancestor linknode to mergestate
Durham Goode <durham@fb.com>
parents:
28009
diff
changeset
|
648 |
extras = self.extras(dfile) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
649 |
anccommitnode = extras.get(b'ancestorlinknode') |
28011
8abd9f785030
merge: add file ancestor linknode to mergestate
Durham Goode <durham@fb.com>
parents:
28009
diff
changeset
|
650 |
if anccommitnode: |
8abd9f785030
merge: add file ancestor linknode to mergestate
Durham Goode <durham@fb.com>
parents:
28009
diff
changeset
|
651 |
actx = self._repo[anccommitnode] |
8abd9f785030
merge: add file ancestor linknode to mergestate
Durham Goode <durham@fb.com>
parents:
28009
diff
changeset
|
652 |
else: |
8abd9f785030
merge: add file ancestor linknode to mergestate
Durham Goode <durham@fb.com>
parents:
28009
diff
changeset
|
653 |
actx = None |
44871
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
654 |
fcd = _filectxorabsent(localkey, wctx, dfile) |
17d928f8abaf
mergestate: move staticmethod _filectxorabsent to module level
Augie Fackler <augie@google.com>
parents:
44856
diff
changeset
|
655 |
fco = _filectxorabsent(onode, octx, ofile) |
27048
86290f6f6599
mergestate._resolve: handle change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27035
diff
changeset
|
656 |
# TODO: move this to filectxorabsent |
37172
daef13da66fe
context: avoid using a context object as a changeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37125
diff
changeset
|
657 |
fca = self._repo.filectx(afile, fileid=anode, changectx=actx) |
18338
384df4db6520
merge: merge file flags together with file content
Mads Kiilerich <mads@kiilerich.com>
parents:
18336
diff
changeset
|
658 |
# "premerge" x flags |
384df4db6520
merge: merge file flags together with file content
Mads Kiilerich <mads@kiilerich.com>
parents:
18336
diff
changeset
|
659 |
flo = fco.flags() |
384df4db6520
merge: merge file flags together with file content
Mads Kiilerich <mads@kiilerich.com>
parents:
18336
diff
changeset
|
660 |
fla = fca.flags() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
661 |
if b'x' in flags + flo + fla and b'l' not in flags + flo + fla: |
30161
339f9d93daa6
merge: only show "cannot merge flags for %s" warning if flags are different
Mads Kiilerich <madski@unity3d.com>
parents:
30096
diff
changeset
|
662 |
if fca.node() == nullid and flags != flo: |
26617
dfd9811c5c9b
merge: introduce a preresolve function
Siddharth Agarwal <sid0@fb.com>
parents:
26616
diff
changeset
|
663 |
if preresolve: |
dfd9811c5c9b
merge: introduce a preresolve function
Siddharth Agarwal <sid0@fb.com>
parents:
26616
diff
changeset
|
664 |
self._repo.ui.warn( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
665 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
666 |
b'warning: cannot merge flags for %s ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
667 |
b'without common ancestor - keeping local flags\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
668 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
669 |
% afile |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
670 |
) |
18338
384df4db6520
merge: merge file flags together with file content
Mads Kiilerich <mads@kiilerich.com>
parents:
18336
diff
changeset
|
671 |
elif flags == fla: |
384df4db6520
merge: merge file flags together with file content
Mads Kiilerich <mads@kiilerich.com>
parents:
18336
diff
changeset
|
672 |
flags = flo |
26617
dfd9811c5c9b
merge: introduce a preresolve function
Siddharth Agarwal <sid0@fb.com>
parents:
26616
diff
changeset
|
673 |
if preresolve: |
dfd9811c5c9b
merge: introduce a preresolve function
Siddharth Agarwal <sid0@fb.com>
parents:
26616
diff
changeset
|
674 |
# restore local |
41155
8c222bec97da
merge: make local file storage in the .hg/merge directory extensible
Daniel Ploch <dploch@google.com>
parents:
41050
diff
changeset
|
675 |
if localkey != nullhex: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
676 |
f = self._repo.vfs(b'merge/' + localkey) |
33083
05c680ebf512
merge: convert repo.wwrite() calls to wctx[f].write()
Phil Cohen <phillco@fb.com>
parents:
33082
diff
changeset
|
677 |
wctx[dfile].write(f.read(), flags) |
27048
86290f6f6599
mergestate._resolve: handle change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27035
diff
changeset
|
678 |
f.close() |
86290f6f6599
mergestate._resolve: handle change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27035
diff
changeset
|
679 |
else: |
33082
f9e50ee4c52b
merge: replace repo.wvfs.unlinkpath() with calls to wctx[f].remove()
Phil Cohen <phillco@fb.com>
parents:
33081
diff
changeset
|
680 |
wctx[dfile].remove(ignoremissing=True) |
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
681 |
complete, merge_ret, deleted = filemerge.premerge( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
682 |
self._repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
683 |
wctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
684 |
self._local, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
685 |
lfile, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
686 |
fcd, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
687 |
fco, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
688 |
fca, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
689 |
labels=self._labels, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
690 |
) |
26617
dfd9811c5c9b
merge: introduce a preresolve function
Siddharth Agarwal <sid0@fb.com>
parents:
26616
diff
changeset
|
691 |
else: |
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
692 |
complete, merge_ret, deleted = filemerge.filemerge( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
693 |
self._repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
694 |
wctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
695 |
self._local, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
696 |
lfile, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
697 |
fcd, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
698 |
fco, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
699 |
fca, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
700 |
labels=self._labels, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
701 |
) |
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
702 |
if merge_ret is None: |
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
703 |
# If return value of merge is None, then there are no real conflict |
13536
fac040b7e822
merge: drop resolve state for mergers with identical contents (issue2680)
Matt Mackall <mpm@selenic.com>
parents:
13437
diff
changeset
|
704 |
del self._state[dfile] |
28009
4a25e91fa55d
merge: add state extras merge state data
Durham Goode <durham@fb.com>
parents:
27951
diff
changeset
|
705 |
self._stateextras.pop(dfile, None) |
20792
89059c450c56
merge: mark mergestate as dirty when resolve changes _state
Mads Kiilerich <madski@unity3d.com>
parents:
20652
diff
changeset
|
706 |
self._dirty = True |
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
707 |
elif not merge_ret: |
37111
aa5199c7aa42
merge: use constants for merge record state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37110
diff
changeset
|
708 |
self.mark(dfile, MERGE_RECORD_RESOLVED) |
27035
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
709 |
|
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
710 |
if complete: |
27075
6373330155b2
mergestate._resolve: don't return the action any more
Siddharth Agarwal <sid0@fb.com>
parents:
27074
diff
changeset
|
711 |
action = None |
27035
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
712 |
if deleted: |
27122
77d760ba8dcd
mergestate: explicitly forget 'dc' conflicts where the deleted side is picked
Siddharth Agarwal <sid0@fb.com>
parents:
27121
diff
changeset
|
713 |
if fcd.isabsent(): |
77d760ba8dcd
mergestate: explicitly forget 'dc' conflicts where the deleted side is picked
Siddharth Agarwal <sid0@fb.com>
parents:
27121
diff
changeset
|
714 |
# dc: local picked. Need to drop if present, which may |
77d760ba8dcd
mergestate: explicitly forget 'dc' conflicts where the deleted side is picked
Siddharth Agarwal <sid0@fb.com>
parents:
27121
diff
changeset
|
715 |
# happen on re-resolves. |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
716 |
action = ACTION_FORGET |
27122
77d760ba8dcd
mergestate: explicitly forget 'dc' conflicts where the deleted side is picked
Siddharth Agarwal <sid0@fb.com>
parents:
27121
diff
changeset
|
717 |
else: |
27035
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
718 |
# cd: remote picked (or otherwise deleted) |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
719 |
action = ACTION_REMOVE |
27035
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
720 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
721 |
if fcd.isabsent(): # dc: remote picked |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
722 |
action = ACTION_GET |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
723 |
elif fco.isabsent(): # cd: local picked |
27131
d837da26155e
merge: add a new action type representing files to add/mark as modified
Siddharth Agarwal <sid0@fb.com>
parents:
27130
diff
changeset
|
724 |
if dfile in self.localctx: |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
725 |
action = ACTION_ADD_MODIFIED |
27131
d837da26155e
merge: add a new action type representing files to add/mark as modified
Siddharth Agarwal <sid0@fb.com>
parents:
27130
diff
changeset
|
726 |
else: |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
727 |
action = ACTION_ADD |
27035
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
728 |
# else: regular merges (no action necessary) |
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
729 |
self._results[dfile] = merge_ret, action |
27035
de7bf242644e
merge.mergestate: compute dirstate action
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
730 |
|
45165
01c4dccfd6b5
mergestate: rename a helpless variable name to bit helpful one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45164
diff
changeset
|
731 |
return complete, merge_ret |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
732 |
|
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
733 |
def preresolve(self, dfile, wctx): |
26870
ab798d1a230f
merge.mergestate: update docstrings for preresolve and resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26821
diff
changeset
|
734 |
"""run premerge process for dfile |
ab798d1a230f
merge.mergestate: update docstrings for preresolve and resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26821
diff
changeset
|
735 |
|
ab798d1a230f
merge.mergestate: update docstrings for preresolve and resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26821
diff
changeset
|
736 |
Returns whether the merge is complete, and the exit code.""" |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
737 |
return self._resolve(True, dfile, wctx) |
26617
dfd9811c5c9b
merge: introduce a preresolve function
Siddharth Agarwal <sid0@fb.com>
parents:
26616
diff
changeset
|
738 |
|
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
739 |
def resolve(self, dfile, wctx): |
26870
ab798d1a230f
merge.mergestate: update docstrings for preresolve and resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26821
diff
changeset
|
740 |
"""run merge process (assuming premerge was run) for dfile |
ab798d1a230f
merge.mergestate: update docstrings for preresolve and resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26821
diff
changeset
|
741 |
|
ab798d1a230f
merge.mergestate: update docstrings for preresolve and resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26821
diff
changeset
|
742 |
Returns the exit code of the merge.""" |
28634
3ceac01bc29f
merge: save merge part labels for later reuse
Simon Farnsworth <simonfar@fb.com>
parents:
28267
diff
changeset
|
743 |
return self._resolve(False, dfile, wctx)[1] |
26615
c9223a3979b7
merge.mergestate: add a wrapper around resolve
Siddharth Agarwal <sid0@fb.com>
parents:
26611
diff
changeset
|
744 |
|
27076
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
745 |
def counts(self): |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
746 |
"""return counts for updated, merged and removed files in this |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
747 |
session""" |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
748 |
updated, merged, removed = 0, 0, 0 |
43104
74802979dd9d
py3: define and use pycompat.itervalues()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43090
diff
changeset
|
749 |
for r, action in pycompat.itervalues(self._results): |
27076
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
750 |
if r is None: |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
751 |
updated += 1 |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
752 |
elif r == 0: |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
753 |
if action == ACTION_REMOVE: |
27076
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
754 |
removed += 1 |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
755 |
else: |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
756 |
merged += 1 |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
757 |
return updated, merged, removed |
09139ccf3085
mergestate: add a method to return updated/merged/removed counts
Siddharth Agarwal <sid0@fb.com>
parents:
27075
diff
changeset
|
758 |
|
27077
ca3fbf9dad8c
mergestate: add a function to return the number of unresolved files
Siddharth Agarwal <sid0@fb.com>
parents:
27076
diff
changeset
|
759 |
def unresolvedcount(self): |
ca3fbf9dad8c
mergestate: add a function to return the number of unresolved files
Siddharth Agarwal <sid0@fb.com>
parents:
27076
diff
changeset
|
760 |
"""get unresolved count for this merge (persistent)""" |
33311
f8f716da90fa
mergestate: implement unresolvedcount() in terms of unresolved()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33310
diff
changeset
|
761 |
return len(list(self.unresolved())) |
27077
ca3fbf9dad8c
mergestate: add a function to return the number of unresolved files
Siddharth Agarwal <sid0@fb.com>
parents:
27076
diff
changeset
|
762 |
|
27079
a88a10a933b2
mergestate: add a method to compute actions to perform on dirstate
Siddharth Agarwal <sid0@fb.com>
parents:
27078
diff
changeset
|
763 |
def actions(self): |
a88a10a933b2
mergestate: add a method to compute actions to perform on dirstate
Siddharth Agarwal <sid0@fb.com>
parents:
27078
diff
changeset
|
764 |
"""return lists of actions to perform on the dirstate""" |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
765 |
actions = { |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
766 |
ACTION_REMOVE: [], |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
767 |
ACTION_FORGET: [], |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
768 |
ACTION_ADD: [], |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
769 |
ACTION_ADD_MODIFIED: [], |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
770 |
ACTION_GET: [], |
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
771 |
} |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43104
diff
changeset
|
772 |
for f, (r, action) in pycompat.iteritems(self._results): |
27079
a88a10a933b2
mergestate: add a method to compute actions to perform on dirstate
Siddharth Agarwal <sid0@fb.com>
parents:
27078
diff
changeset
|
773 |
if action is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
774 |
actions[action].append((f, None, b"merge result")) |
27079
a88a10a933b2
mergestate: add a method to compute actions to perform on dirstate
Siddharth Agarwal <sid0@fb.com>
parents:
27078
diff
changeset
|
775 |
return actions |
a88a10a933b2
mergestate: add a method to compute actions to perform on dirstate
Siddharth Agarwal <sid0@fb.com>
parents:
27078
diff
changeset
|
776 |
|
27090
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
777 |
def queueremove(self, f): |
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
778 |
"""queues a file to be removed from the dirstate |
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
779 |
|
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
780 |
Meant for use by custom merge drivers.""" |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
781 |
self._results[f] = 0, ACTION_REMOVE |
27090
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
782 |
|
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
783 |
def queueadd(self, f): |
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
784 |
"""queues a file to be added to the dirstate |
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
785 |
|
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
786 |
Meant for use by custom merge drivers.""" |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
787 |
self._results[f] = 0, ACTION_ADD |
27090
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
788 |
|
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
789 |
def queueget(self, f): |
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
790 |
"""queues a file to be marked modified in the dirstate |
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
791 |
|
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
792 |
Meant for use by custom merge drivers.""" |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
793 |
self._results[f] = 0, ACTION_GET |
27090
ef6f98473a48
mergestate: add methods to queue files to remove, add or get
Siddharth Agarwal <sid0@fb.com>
parents:
27088
diff
changeset
|
794 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
795 |
|
42456
87a34c767384
merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42412
diff
changeset
|
796 |
def recordupdates(repo, actions, branchmerge, getfiledata): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43713
diff
changeset
|
797 |
"""record merge actions to the dirstate""" |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
798 |
# remove (must come first) |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
799 |
for f, args, msg in actions.get(ACTION_REMOVE, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
800 |
if branchmerge: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
801 |
repo.dirstate.remove(f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
802 |
else: |
21389
e741972017d9
merge: change priority / ordering of merge actions
Mads Kiilerich <madski@unity3d.com>
parents:
21269
diff
changeset
|
803 |
repo.dirstate.drop(f) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
804 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
805 |
# forget (must come first) |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
806 |
for f, args, msg in actions.get(ACTION_FORGET, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
807 |
repo.dirstate.drop(f) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
808 |
|
34548
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
809 |
# resolve path conflicts |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
810 |
for f, args, msg in actions.get(ACTION_PATH_CONFLICT_RESOLVE, []): |
44939
818b4f19ef23
merge: move an inspection of the dirstate from record to calculate phase
Martin von Zweigbergk <martinvonz@google.com>
parents:
44871
diff
changeset
|
811 |
(f0, origf0) = args |
34548
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
812 |
repo.dirstate.add(f) |
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
813 |
repo.dirstate.copy(origf0, f) |
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
814 |
if f0 == origf0: |
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
815 |
repo.dirstate.remove(f0) |
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
816 |
else: |
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
817 |
repo.dirstate.drop(f0) |
b4955650eb57
merge: add merge action 'pr' to rename files during update
Mark Thomas <mbthomas@fb.com>
parents:
34547
diff
changeset
|
818 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
819 |
# re-add |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
820 |
for f, args, msg in actions.get(ACTION_ADD, []): |
27132
baa7571f40c5
merge.recordupdates: mark 'a' files as added unconditionally
Siddharth Agarwal <sid0@fb.com>
parents:
27131
diff
changeset
|
821 |
repo.dirstate.add(f) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
822 |
|
27131
d837da26155e
merge: add a new action type representing files to add/mark as modified
Siddharth Agarwal <sid0@fb.com>
parents:
27130
diff
changeset
|
823 |
# re-add/mark as modified |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
824 |
for f, args, msg in actions.get(ACTION_ADD_MODIFIED, []): |
27131
d837da26155e
merge: add a new action type representing files to add/mark as modified
Siddharth Agarwal <sid0@fb.com>
parents:
27130
diff
changeset
|
825 |
if branchmerge: |
d837da26155e
merge: add a new action type representing files to add/mark as modified
Siddharth Agarwal <sid0@fb.com>
parents:
27130
diff
changeset
|
826 |
repo.dirstate.normallookup(f) |
d837da26155e
merge: add a new action type representing files to add/mark as modified
Siddharth Agarwal <sid0@fb.com>
parents:
27130
diff
changeset
|
827 |
else: |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
828 |
repo.dirstate.add(f) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
829 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
830 |
# exec change |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
831 |
for f, args, msg in actions.get(ACTION_EXEC, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
832 |
repo.dirstate.normallookup(f) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
833 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
834 |
# keep |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
835 |
for f, args, msg in actions.get(ACTION_KEEP, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
836 |
pass |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
837 |
|
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
838 |
# get |
42522
d29db0a0c4eb
update: fix spurious unclean status bug shown by previous commit
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42456
diff
changeset
|
839 |
for f, args, msg in actions.get(ACTION_GET, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
840 |
if branchmerge: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
841 |
repo.dirstate.otherparent(f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
842 |
else: |
42522
d29db0a0c4eb
update: fix spurious unclean status bug shown by previous commit
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42456
diff
changeset
|
843 |
parentfiledata = getfiledata[f] if getfiledata else None |
42456
87a34c767384
merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42412
diff
changeset
|
844 |
repo.dirstate.normal(f, parentfiledata=parentfiledata) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
845 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
846 |
# merge |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
847 |
for f, args, msg in actions.get(ACTION_MERGE, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
848 |
f1, f2, fa, move, anc = args |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
849 |
if branchmerge: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
850 |
# We've done a branch merge, mark this file as merged |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
851 |
# so that we properly record the merger later |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
852 |
repo.dirstate.merge(f) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
853 |
if f1 != f2: # copy/rename |
3308
ecc1bf27378c
merge: unify merge and copy actions
Matt Mackall <mpm@selenic.com>
parents:
3307
diff
changeset
|
854 |
if move: |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
855 |
repo.dirstate.remove(f1) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
856 |
if f1 != f: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
857 |
repo.dirstate.copy(f1, f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
858 |
else: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
859 |
repo.dirstate.copy(f2, f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
860 |
else: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
861 |
# We've update-merged a locally modified file, so |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
862 |
# we set the dirstate to emulate a normal checkout |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
863 |
# of that file some time in the past. Thus our |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
864 |
# merge will appear as a normal local file |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
865 |
# modification. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42972
diff
changeset
|
866 |
if f2 == f: # file not locally copied/moved |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
867 |
repo.dirstate.normallookup(f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
868 |
if move: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
869 |
repo.dirstate.drop(f1) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
870 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
871 |
# directory rename, move local |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
872 |
for f, args, msg in actions.get(ACTION_DIR_RENAME_MOVE_LOCAL, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
873 |
f0, flag = args |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
874 |
if branchmerge: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
875 |
repo.dirstate.add(f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
876 |
repo.dirstate.remove(f0) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
877 |
repo.dirstate.copy(f0, f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
878 |
else: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
879 |
repo.dirstate.normal(f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
880 |
repo.dirstate.drop(f0) |
21391
cb15835456cb
merge: change debug logging - test output changes but no real changes
Mads Kiilerich <madski@unity3d.com>
parents:
21390
diff
changeset
|
881 |
|
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
882 |
# directory rename, get |
37112
43ffd9070da1
merge: use constants for actions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
883 |
for f, args, msg in actions.get(ACTION_LOCAL_DIR_RENAME_GET, []): |
21551
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
884 |
f0, flag = args |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
885 |
if branchmerge: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
886 |
repo.dirstate.add(f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
887 |
repo.dirstate.copy(f0, f) |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
888 |
else: |
bde505f47141
merge: fix stupid indentation left over from previous refactorings
Mads Kiilerich <madski@unity3d.com>
parents:
21545
diff
changeset
|
889 |
repo.dirstate.normal(f) |