See the core code for details of why we are doing this.
We don't factor the code in a common function yet, because we will have to adapt
a bit more things in the largefile case at the end of the series.
Alphare |
hg-reviewers |
See the core code for details of why we are doing this.
We don't factor the code in a common function yet, because we will have to adapt
a bit more things in the largefile case at the end of the series.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | hgext/largefiles/lfutil.py (9 lines) | |||
M | hgext/largefiles/reposetup.py (10 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 |
pycompat, | pycompat, | ||||
requirements, | requirements, | ||||
scmutil, | scmutil, | ||||
sparse, | sparse, | ||||
util, | util, | ||||
vfs as vfsmod, | vfs as vfsmod, | ||||
) | ) | ||||
from mercurial.utils import hashutil | from mercurial.utils import hashutil | ||||
from mercurial.dirstateutils import timestamp | |||||
shortname = b'.hglf' | shortname = b'.hglf' | ||||
shortnameslash = shortname + b'/' | shortnameslash = shortname + b'/' | ||||
longname = b'largefiles' | longname = b'largefiles' | ||||
# -- Private worker functions ------------------------------------------ | # -- Private worker functions ------------------------------------------ | ||||
def lfdirstatestatus(lfdirstate, repo): | def lfdirstatestatus(lfdirstate, repo): | ||||
pctx = repo[b'.'] | pctx = repo[b'.'] | ||||
match = matchmod.always() | match = matchmod.always() | ||||
unsure, s = lfdirstate.status( | unsure, s = lfdirstate.status( | ||||
match, subrepos=[], ignored=False, clean=False, unknown=False | match, subrepos=[], ignored=False, clean=False, unknown=False | ||||
) | ) | ||||
modified, clean = s.modified, s.clean | modified, clean = s.modified, s.clean | ||||
wctx = repo[None] | |||||
for lfile in unsure: | for lfile in unsure: | ||||
try: | try: | ||||
fctx = pctx[standin(lfile)] | fctx = pctx[standin(lfile)] | ||||
except LookupError: | except LookupError: | ||||
fctx = None | fctx = None | ||||
if not fctx or readasstandin(fctx) != hashfile(repo.wjoin(lfile)): | if not fctx or readasstandin(fctx) != hashfile(repo.wjoin(lfile)): | ||||
modified.append(lfile) | modified.append(lfile) | ||||
else: | else: | ||||
clean.append(lfile) | clean.append(lfile) | ||||
lfdirstate.set_clean(lfile) | st = wctx[lfile].lstat() | ||||
mode = st.st_mode | |||||
size = st.st_size | |||||
mtime = timestamp.mtime_of(st) | |||||
cache_data = (mode, size, mtime) | |||||
lfdirstate.set_clean(lfile, cache_data) | |||||
return s | return s | ||||
def listlfiles(repo, rev=None, matcher=None): | def listlfiles(repo, rev=None, matcher=None): | ||||
"""return a list of largefiles in the working copy or the | """return a list of largefiles in the working copy or the | ||||
specified changeset""" | specified changeset""" | ||||
if matcher is None: | if matcher is None: |
error, | error, | ||||
extensions, | extensions, | ||||
localrepo, | localrepo, | ||||
match as matchmod, | match as matchmod, | ||||
scmutil, | scmutil, | ||||
util, | util, | ||||
) | ) | ||||
from mercurial.dirstateutils import timestamp | |||||
from . import ( | from . import ( | ||||
lfcommands, | lfcommands, | ||||
lfutil, | lfutil, | ||||
) | ) | ||||
def reposetup(ui, repo): | def reposetup(ui, repo): | ||||
# wire repositories should be given new wireproto functions | # wire repositories should be given new wireproto functions | ||||
(modified, added, removed, deleted, clean) = ( | (modified, added, removed, deleted, clean) = ( | ||||
s.modified, | s.modified, | ||||
s.added, | s.added, | ||||
s.removed, | s.removed, | ||||
s.deleted, | s.deleted, | ||||
s.clean, | s.clean, | ||||
) | ) | ||||
if parentworking: | if parentworking: | ||||
wctx = repo[None] | |||||
for lfile in unsure: | for lfile in unsure: | ||||
standin = lfutil.standin(lfile) | standin = lfutil.standin(lfile) | ||||
if standin not in ctx1: | if standin not in ctx1: | ||||
# from second parent | # from second parent | ||||
modified.append(lfile) | modified.append(lfile) | ||||
elif lfutil.readasstandin( | elif lfutil.readasstandin( | ||||
ctx1[standin] | ctx1[standin] | ||||
) != lfutil.hashfile(self.wjoin(lfile)): | ) != lfutil.hashfile(self.wjoin(lfile)): | ||||
modified.append(lfile) | modified.append(lfile) | ||||
else: | else: | ||||
if listclean: | if listclean: | ||||
clean.append(lfile) | clean.append(lfile) | ||||
lfdirstate.set_clean(lfile) | s = wctx[lfile].lstat() | ||||
mode = s.st_mode | |||||
size = s.st_size | |||||
mtime = timestamp.mtime_of(s) | |||||
cache_data = (mode, size, mtime) | |||||
lfdirstate.set_clean(lfile, cache_data) | |||||
else: | else: | ||||
tocheck = unsure + modified + added + clean | tocheck = unsure + modified + added + clean | ||||
modified, added, clean = [], [], [] | modified, added, clean = [], [], [] | ||||
checkexec = self.dirstate._checkexec | checkexec = self.dirstate._checkexec | ||||
for lfile in tocheck: | for lfile in tocheck: | ||||
standin = lfutil.standin(lfile) | standin = lfutil.standin(lfile) | ||||
if standin in ctx1: | if standin in ctx1: |