If they are not relevant data, they are no need to fetch them.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
If they are not relevant data, they are no need to fetch them.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/changelog.py (2 lines) | |||
M | mercurial/copies.py (48 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
99c981c36464 | 9119e748a300 | Pierre-Yves David | Oct 1 2020, 3:42 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 |
sidedata = metadata.encode_files_sidedata(files) | sidedata = metadata.encode_files_sidedata(files) | ||||
if extra: | if extra: | ||||
extra = encodeextra(extra) | extra = encodeextra(extra) | ||||
parseddate = b"%s %s" % (parseddate, extra) | parseddate = b"%s %s" % (parseddate, extra) | ||||
l = [hex(manifest), user, parseddate] + sortedfiles + [b"", desc] | l = [hex(manifest), user, parseddate] + sortedfiles + [b"", desc] | ||||
text = b"\n".join(l) | text = b"\n".join(l) | ||||
return self.addrevision( | return self.addrevision( | ||||
text, transaction, len(self), p1, p2, sidedata=sidedata | text, transaction, len(self), p1, p2, sidedata=sidedata, flags=flags | ||||
) | ) | ||||
def branchinfo(self, rev): | def branchinfo(self, rev): | ||||
"""return the branch name and open/close state of a revision | """return the branch name and open/close state of a revision | ||||
This function exists because creating a changectx object | This function exists because creating a changectx object | ||||
just to access this is costly.""" | just to access this is costly.""" | ||||
extra = self.read(rev)[5] | extra = self.read(rev)[5] | ||||
return encoding.tolocal(extra.get(b"branch")), b'close' in extra | return encoding.tolocal(extra.get(b"branch")), b'close' in extra | ||||
def _nodeduplicatecallback(self, transaction, node): | def _nodeduplicatecallback(self, transaction, node): | ||||
# keep track of revisions that got "re-added", eg: unbunde of know rev. | # keep track of revisions that got "re-added", eg: unbunde of know rev. | ||||
# | # | ||||
# We track them in a list to preserve their order from the source bundle | # We track them in a list to preserve their order from the source bundle | ||||
duplicates = transaction.changes.setdefault(b'revduplicates', []) | duplicates = transaction.changes.setdefault(b'revduplicates', []) | ||||
duplicates.append(self.rev(node)) | duplicates.append(self.rev(node)) |
pathutil, | pathutil, | ||||
pycompat, | pycompat, | ||||
util, | util, | ||||
) | ) | ||||
from .utils import stringutil | from .utils import stringutil | ||||
from .revlogutils import flagutil | |||||
def _filter(src, dst, t): | def _filter(src, dst, t): | ||||
"""filters out invalid copies after chaining""" | """filters out invalid copies after chaining""" | ||||
# When _chain()'ing copies in 'a' (from 'src' via some other commit 'mid') | # When _chain()'ing copies in 'a' (from 'src' via some other commit 'mid') | ||||
# with copies in 'b' (from 'mid' to 'dst'), we can get the different cases | # with copies in 'b' (from 'mid' to 'dst'), we can get the different cases | ||||
# in the following table (not including trivial cases). For example, case 2 | # in the following table (not including trivial cases). For example, case 2 | ||||
# is where a file existed in 'src' and remained under that name in 'mid' and | # is where a file existed in 'src' and remained under that name in 'mid' and | ||||
"""return a function that return multiple data given a <rev>" | """return a function that return multiple data given a <rev>" | ||||
* p1: revision number of first parent | * p1: revision number of first parent | ||||
* p2: revision number of first parent | * p2: revision number of first parent | ||||
* changes: a ChangingGiles object | * changes: a ChangingGiles object | ||||
""" | """ | ||||
cl = repo.changelog | cl = repo.changelog | ||||
parents = cl.parentrevs | parents = cl.parentrevs | ||||
flags = cl.flags | |||||
HASCOPIESINFO = flagutil.REVIDX_HASCOPIESINFO | |||||
changelogrevision = cl.changelogrevision | changelogrevision = cl.changelogrevision | ||||
# A small cache to avoid doing the work twice for merges | # A small cache to avoid doing the work twice for merges | ||||
# | # | ||||
# In the vast majority of cases, if we ask information for a revision | # In the vast majority of cases, if we ask information for a revision | ||||
# about 1 parent, we'll later ask it for the other. So it make sense to | # about 1 parent, we'll later ask it for the other. So it make sense to | ||||
# keep the information around when reaching the first parent of a merge | # keep the information around when reaching the first parent of a merge | ||||
merge_caches = {} | merge_caches = {} | ||||
def revinfo(rev): | def revinfo(rev): | ||||
p1, p2 = parents(rev) | p1, p2 = parents(rev) | ||||
value = None | value = None | ||||
e = merge_caches.pop(rev, None) | e = merge_caches.pop(rev, None) | ||||
if e is not None: | if e is not None: | ||||
return e | return e | ||||
value = (p1, p2, changelogrevision(rev).changes) | changes = None | ||||
if flags(rev) & HASCOPIESINFO: | |||||
changes = changelogrevision(rev).changes | |||||
value = (p1, p2, changes) | |||||
if p1 != node.nullrev and p2 != node.nullrev: | if p1 != node.nullrev and p2 != node.nullrev: | ||||
# XXX some case we over cache, IGNORE | # XXX some case we over cache, IGNORE | ||||
merge_caches[rev] = value | merge_caches[rev] = value | ||||
return value | return value | ||||
return revinfo | return revinfo | ||||
alwaysmatch = match.always() | alwaysmatch = match.always() | ||||
for r in revs: | for r in revs: | ||||
copies = all_copies.pop(r, None) | copies = all_copies.pop(r, None) | ||||
if copies is None: | if copies is None: | ||||
# this is a root | # this is a root | ||||
copies = {} | copies = {} | ||||
for i, c in enumerate(children[r]): | for i, c in enumerate(children[r]): | ||||
p1, p2, changes = revinfo(c) | p1, p2, changes = revinfo(c) | ||||
childcopies = {} | |||||
if r == p1: | if r == p1: | ||||
parent = 1 | parent = 1 | ||||
if changes is not None: | |||||
childcopies = changes.copied_from_p1 | childcopies = changes.copied_from_p1 | ||||
else: | else: | ||||
assert r == p2 | assert r == p2 | ||||
parent = 2 | parent = 2 | ||||
if changes is not None: | |||||
childcopies = changes.copied_from_p2 | childcopies = changes.copied_from_p2 | ||||
if not alwaysmatch: | if not alwaysmatch: | ||||
childcopies = { | childcopies = { | ||||
dst: src for dst, src in childcopies.items() if match(dst) | dst: src for dst, src in childcopies.items() if match(dst) | ||||
} | } | ||||
newcopies = copies | newcopies = copies | ||||
if childcopies: | if childcopies: | ||||
newcopies = copies.copy() | newcopies = copies.copy() | ||||
for dest, source in pycompat.iteritems(childcopies): | for dest, source in pycompat.iteritems(childcopies): | ||||
prev = copies.get(source) | prev = copies.get(source) | ||||
if prev is not None and prev[1] is not None: | if prev is not None and prev[1] is not None: | ||||
source = prev[1] | source = prev[1] | ||||
newcopies[dest] = (c, source) | newcopies[dest] = (c, source) | ||||
assert newcopies is not copies | assert newcopies is not copies | ||||
if changes is not None: | |||||
for f in changes.removed: | for f in changes.removed: | ||||
if f in newcopies: | if f in newcopies: | ||||
if newcopies is copies: | if newcopies is copies: | ||||
# copy on write to avoid affecting potential other | # copy on write to avoid affecting potential other | ||||
# branches. when there are no other branches, this | # branches. when there are no other branches, this | ||||
# could be avoided. | # could be avoided. | ||||
newcopies = copies.copy() | newcopies = copies.copy() | ||||
newcopies[f] = (c, None) | newcopies[f] = (c, None) | ||||
othercopies = all_copies.get(c) | othercopies = all_copies.get(c) | ||||
if othercopies is None: | if othercopies is None: | ||||
all_copies[c] = newcopies | all_copies[c] = newcopies | ||||
else: | else: | ||||
# we are the second parent to work on c, we need to merge our | # we are the second parent to work on c, we need to merge our | ||||
# work with the other. | # work with the other. | ||||
# | # | ||||
# In case of conflict, parent 1 take precedence over parent 2. | # In case of conflict, parent 1 take precedence over parent 2. | ||||
new_tt = value[0] | new_tt = value[0] | ||||
other_tt = other[0] | other_tt = other[0] | ||||
if value[1] == other[1]: | if value[1] == other[1]: | ||||
continue | continue | ||||
# content from "major" wins, unless it is older | # content from "major" wins, unless it is older | ||||
# than the branch point or there is a merge | # than the branch point or there is a merge | ||||
if new_tt == other_tt: | if new_tt == other_tt: | ||||
minor[dest] = value | minor[dest] = value | ||||
elif value[1] is None and dest in changes.salvaged: | elif ( | ||||
changes is not None | |||||
and value[1] is None | |||||
and dest in changes.salvaged | |||||
): | |||||
pass | pass | ||||
elif other[1] is None and dest in changes.salvaged: | elif ( | ||||
changes is not None | |||||
and other[1] is None | |||||
and dest in changes.salvaged | |||||
): | |||||
minor[dest] = value | minor[dest] = value | ||||
elif not isancestor(new_tt, other_tt): | elif not isancestor(new_tt, other_tt): | ||||
minor[dest] = value | minor[dest] = value | ||||
elif dest in changes.merged: | elif changes is not None and dest in changes.merged: | ||||
minor[dest] = value | minor[dest] = value | ||||
def _revinfo_getter_extra(repo): | def _revinfo_getter_extra(repo): | ||||
"""return a function that return multiple data given a <rev>"i | """return a function that return multiple data given a <rev>"i | ||||
* p1: revision number of first parent | * p1: revision number of first parent | ||||
* p2: revision number of first parent | * p2: revision number of first parent |