With the new side data storage, this is trivial.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
With the new side data storage, this is trivial.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/metadata.py (8 lines) | |||
M | tests/test-copies-chain-merge.t (20 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
668172834395 | 52090aa4f456 | Pierre-Yves David | Sep 15 2020, 4:55 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute |
# see mercurial/helptext/internals/revlogs.txt for details about the format | # see mercurial/helptext/internals/revlogs.txt for details about the format | ||||
ACTION_MASK = int("111" "00", 2) | ACTION_MASK = int("111" "00", 2) | ||||
# note: untouched file used as copy source will as `000` for this mask. | # note: untouched file used as copy source will as `000` for this mask. | ||||
ADDED_FLAG = int("001" "00", 2) | ADDED_FLAG = int("001" "00", 2) | ||||
MERGED_FLAG = int("010" "00", 2) | MERGED_FLAG = int("010" "00", 2) | ||||
REMOVED_FLAG = int("011" "00", 2) | REMOVED_FLAG = int("011" "00", 2) | ||||
# `100` is reserved for future use | SALVAGED_FLAG = int("100" "00", 2) | ||||
TOUCHED_FLAG = int("101" "00", 2) | TOUCHED_FLAG = int("101" "00", 2) | ||||
COPIED_MASK = int("11", 2) | COPIED_MASK = int("11", 2) | ||||
COPIED_FROM_P1_FLAG = int("10", 2) | COPIED_FROM_P1_FLAG = int("10", 2) | ||||
COPIED_FROM_P2_FLAG = int("11", 2) | COPIED_FROM_P2_FLAG = int("11", 2) | ||||
# structure is <flag><filename-end><copy-source> | # structure is <flag><filename-end><copy-source> | ||||
INDEX_HEADER = struct.Struct(">L") | INDEX_HEADER = struct.Struct(">L") | ||||
INDEX_ENTRY = struct.Struct(">bLL") | INDEX_ENTRY = struct.Struct(">bLL") | ||||
def encode_files_sidedata(files): | def encode_files_sidedata(files): | ||||
touched = files.touched | touched = files.touched | ||||
added = files.added | added = files.added | ||||
removed = files.removed | removed = files.removed | ||||
merged = files.merged | merged = files.merged | ||||
salvaged = files.salvaged | salvaged = files.salvaged | ||||
copied_from_p1 = files.copied_from_p1 | copied_from_p1 = files.copied_from_p1 | ||||
copied_from_p2 = files.copied_from_p2 | copied_from_p2 = files.copied_from_p2 | ||||
all_files = set(touched - salvaged) | all_files = set(touched) | ||||
all_files.update(copied_from_p1.values()) | all_files.update(copied_from_p1.values()) | ||||
all_files.update(copied_from_p2.values()) | all_files.update(copied_from_p2.values()) | ||||
all_files = sorted(all_files) | all_files = sorted(all_files) | ||||
file_idx = {f: i for (i, f) in enumerate(all_files)} | file_idx = {f: i for (i, f) in enumerate(all_files)} | ||||
file_idx[None] = 0 | file_idx[None] = 0 | ||||
chunks = [INDEX_HEADER.pack(len(all_files))] | chunks = [INDEX_HEADER.pack(len(all_files))] | ||||
filename_length = 0 | filename_length = 0 | ||||
for f in all_files: | for f in all_files: | ||||
filename_size = len(f) | filename_size = len(f) | ||||
filename_length += filename_size | filename_length += filename_size | ||||
flag = 0 | flag = 0 | ||||
if f in added: | if f in added: | ||||
flag |= ADDED_FLAG | flag |= ADDED_FLAG | ||||
elif f in merged: | elif f in merged: | ||||
flag |= MERGED_FLAG | flag |= MERGED_FLAG | ||||
elif f in removed: | elif f in removed: | ||||
flag |= REMOVED_FLAG | flag |= REMOVED_FLAG | ||||
elif f in salvaged: | |||||
flag |= SALVAGED_FLAG | |||||
elif f in touched: | elif f in touched: | ||||
flag |= TOUCHED_FLAG | flag |= TOUCHED_FLAG | ||||
copy = None | copy = None | ||||
if f in copied_from_p1: | if f in copied_from_p1: | ||||
flag |= COPIED_FROM_P1_FLAG | flag |= COPIED_FROM_P1_FLAG | ||||
copy = copied_from_p1.get(f) | copy = copied_from_p1.get(f) | ||||
elif f in copied_from_p2: | elif f in copied_from_p2: | ||||
file_offset_last = file_end | file_offset_last = file_end | ||||
all_files.append(filename) | all_files.append(filename) | ||||
if flag & ACTION_MASK == ADDED_FLAG: | if flag & ACTION_MASK == ADDED_FLAG: | ||||
md.mark_added(filename) | md.mark_added(filename) | ||||
elif flag & ACTION_MASK == MERGED_FLAG: | elif flag & ACTION_MASK == MERGED_FLAG: | ||||
md.mark_merged(filename) | md.mark_merged(filename) | ||||
elif flag & ACTION_MASK == REMOVED_FLAG: | elif flag & ACTION_MASK == REMOVED_FLAG: | ||||
md.mark_removed(filename) | md.mark_removed(filename) | ||||
elif flag & ACTION_MASK == SALVAGED_FLAG: | |||||
md.mark_salvaged(filename) | |||||
elif flag & ACTION_MASK == TOUCHED_FLAG: | elif flag & ACTION_MASK == TOUCHED_FLAG: | ||||
md.mark_touched(filename) | md.mark_touched(filename) | ||||
copied = None | copied = None | ||||
if flag & COPIED_MASK == COPIED_FROM_P1_FLAG: | if flag & COPIED_MASK == COPIED_FROM_P1_FLAG: | ||||
copied = md.mark_copied_from_p1 | copied = md.mark_copied_from_p1 | ||||
elif flag & COPIED_MASK == COPIED_FROM_P2_FLAG: | elif flag & COPIED_MASK == COPIED_FROM_P2_FLAG: | ||||
copied = md.mark_copied_from_p2 | copied = md.mark_copied_from_p2 |
merged : d, ; | merged : d, ; | ||||
##### revision 29 ##### | ##### revision 29 ##### | ||||
1 sidedata entries | 1 sidedata entries | ||||
entry-0014 size 14 | entry-0014 size 14 | ||||
'\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' | ||||
merged : d, ; | merged : d, ; | ||||
##### revision 30 ##### | ##### revision 30 ##### | ||||
1 sidedata entries | 1 sidedata entries | ||||
entry-0014 size 4 | entry-0014 size 14 | ||||
'\x00\x00\x00\x00' | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | ||||
salvaged : d, ; | |||||
##### revision 31 ##### | ##### revision 31 ##### | ||||
1 sidedata entries | 1 sidedata entries | ||||
entry-0014 size 4 | entry-0014 size 14 | ||||
'\x00\x00\x00\x00' | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | ||||
salvaged : d, ; | |||||
##### revision 32 ##### | ##### revision 32 ##### | ||||
1 sidedata entries | 1 sidedata entries | ||||
entry-0014 size 4 | entry-0014 size 14 | ||||
'\x00\x00\x00\x00' | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | ||||
salvaged : d, ; | |||||
##### revision 33 ##### | ##### revision 33 ##### | ||||
1 sidedata entries | 1 sidedata entries | ||||
entry-0014 size 4 | entry-0014 size 14 | ||||
'\x00\x00\x00\x00' | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | ||||
salvaged : d, ; | |||||
#endif | #endif |