With the new side data storage, this is trivial.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
With the new side data storage, this is trivial.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/metadata.py (8 lines) | |||
M | tests/test-copies-chain-merge.t (20 lines) |
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): | ||||
all_files = set(files.touched - files.salvaged) | all_files = set(files.touched) | ||||
all_files.update(files.copied_from_p1.values()) | all_files.update(files.copied_from_p1.values()) | ||||
all_files.update(files.copied_from_p2.values()) | all_files.update(files.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 files.added: | if f in files.added: | ||||
flag |= ADDED_FLAG | flag |= ADDED_FLAG | ||||
elif f in files.merged: | elif f in files.merged: | ||||
flag |= MERGED_FLAG | flag |= MERGED_FLAG | ||||
elif f in files.removed: | elif f in files.removed: | ||||
flag |= REMOVED_FLAG | flag |= REMOVED_FLAG | ||||
elif f in files.salvaged: | |||||
flag |= SALVAGED_FLAG | |||||
elif f in files.touched: | elif f in files.touched: | ||||
flag |= TOUCHED_FLAG | flag |= TOUCHED_FLAG | ||||
copy = None | copy = None | ||||
if f in files.copied_from_p1: | if f in files.copied_from_p1: | ||||
flag |= COPIED_FROM_P1_FLAG | flag |= COPIED_FROM_P1_FLAG | ||||
copy = files.copied_from_p1.get(f) | copy = files.copied_from_p1.get(f) | ||||
elif f in files.copied_from_p2: | elif f in files.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 |