Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGa86e22007b54: largefiles: migrate to new method for getting copy info
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/largefiles/lfcommands.py (16 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Dec 28 2017, 1:32 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| dstfiles = [] | dstfiles = [] | ||||
| for f in files: | for f in files: | ||||
| if f not in lfiles and f not in normalfiles: | if f not in lfiles and f not in normalfiles: | ||||
| islfile = _islfile(f, ctx, matcher, size) | islfile = _islfile(f, ctx, matcher, size) | ||||
| # If this file was renamed or copied then copy | # If this file was renamed or copied then copy | ||||
| # the largefile-ness of its predecessor | # the largefile-ness of its predecessor | ||||
| if f in ctx.manifest(): | if f in ctx.manifest(): | ||||
| fctx = ctx.filectx(f) | fctx = ctx.filectx(f) | ||||
| renamed = fctx.renamed() | renamed = fctx.copysource() | ||||
| if renamed is None: | if renamed is None: | ||||
| # the code below assumes renamed to be a boolean or a list | # the code below assumes renamed to be a boolean or a list | ||||
| # and won't quite work with the value None | # and won't quite work with the value None | ||||
| renamed = False | renamed = False | ||||
| renamedlfile = renamed and renamed[0] in lfiles | renamedlfile = renamed and renamed in lfiles | ||||
| islfile |= renamedlfile | islfile |= renamedlfile | ||||
| if 'l' in fctx.flags(): | if 'l' in fctx.flags(): | ||||
| if renamedlfile: | if renamedlfile: | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _('renamed/copied largefile %s becomes symlink') | _('renamed/copied largefile %s becomes symlink') | ||||
| % f) | % f) | ||||
| islfile = False | islfile = False | ||||
| if islfile: | if islfile: | ||||
| lfiles.add(f) | lfiles.add(f) | ||||
| else: | else: | ||||
| normalfiles.add(f) | normalfiles.add(f) | ||||
| if f in lfiles: | if f in lfiles: | ||||
| fstandin = lfutil.standin(f) | fstandin = lfutil.standin(f) | ||||
| dstfiles.append(fstandin) | dstfiles.append(fstandin) | ||||
| # largefile in manifest if it has not been removed/renamed | # largefile in manifest if it has not been removed/renamed | ||||
| if f in ctx.manifest(): | if f in ctx.manifest(): | ||||
| fctx = ctx.filectx(f) | fctx = ctx.filectx(f) | ||||
| if 'l' in fctx.flags(): | if 'l' in fctx.flags(): | ||||
| renamed = fctx.renamed() | renamed = fctx.copysource() | ||||
| if renamed and renamed[0] in lfiles: | if renamed and renamed in lfiles: | ||||
| raise error.Abort(_('largefile %s becomes symlink') % f) | raise error.Abort(_('largefile %s becomes symlink') % f) | ||||
| # largefile was modified, update standins | # largefile was modified, update standins | ||||
| m = hashlib.sha1('') | m = hashlib.sha1('') | ||||
| m.update(ctx[f].data()) | m.update(ctx[f].data()) | ||||
| hash = node.hex(m.digest()) | hash = node.hex(m.digest()) | ||||
| if f not in lfiletohash or lfiletohash[f] != hash: | if f not in lfiletohash or lfiletohash[f] != hash: | ||||
| rdst.wwrite(f, ctx[f].data(), ctx[f].flags()) | rdst.wwrite(f, ctx[f].data(), ctx[f].flags()) | ||||
| srcfname = lfutil.splitstandin(f) | srcfname = lfutil.splitstandin(f) | ||||
| if srcfname is not None: | if srcfname is not None: | ||||
| # if the file isn't in the manifest then it was removed | # if the file isn't in the manifest then it was removed | ||||
| # or renamed, return None to indicate this | # or renamed, return None to indicate this | ||||
| try: | try: | ||||
| fctx = ctx.filectx(srcfname) | fctx = ctx.filectx(srcfname) | ||||
| except error.LookupError: | except error.LookupError: | ||||
| return None | return None | ||||
| renamed = fctx.renamed() | renamed = fctx.copysource() | ||||
| if renamed: | if renamed: | ||||
| # standin is always a largefile because largefile-ness | # standin is always a largefile because largefile-ness | ||||
| # doesn't change after rename or copy | # doesn't change after rename or copy | ||||
| renamed = lfutil.standin(renamed[0]) | renamed = lfutil.standin(renamed) | ||||
| return context.memfilectx(repo, memctx, f, | return context.memfilectx(repo, memctx, f, | ||||
| lfiletohash[srcfname] + '\n', | lfiletohash[srcfname] + '\n', | ||||
| 'l' in fctx.flags(), 'x' in fctx.flags(), | 'l' in fctx.flags(), 'x' in fctx.flags(), | ||||
| renamed) | renamed) | ||||
| else: | else: | ||||
| return _getnormalcontext(repo, ctx, f, revmap) | return _getnormalcontext(repo, ctx, f, revmap) | ||||
| return parents | return parents | ||||
| # Get memfilectx for a normal file | # Get memfilectx for a normal file | ||||
| def _getnormalcontext(repo, ctx, f, revmap): | def _getnormalcontext(repo, ctx, f, revmap): | ||||
| try: | try: | ||||
| fctx = ctx.filectx(f) | fctx = ctx.filectx(f) | ||||
| except error.LookupError: | except error.LookupError: | ||||
| return None | return None | ||||
| renamed = fctx.renamed() | renamed = fctx.copysource() | ||||
| if renamed: | |||||
| renamed = renamed[0] | |||||
| data = fctx.data() | data = fctx.data() | ||||
| if f == '.hgtags': | if f == '.hgtags': | ||||
| data = _converttags (repo.ui, revmap, data) | data = _converttags (repo.ui, revmap, data) | ||||
| return context.memfilectx(repo, ctx, f, data, 'l' in fctx.flags(), | return context.memfilectx(repo, ctx, f, data, 'l' in fctx.flags(), | ||||
| 'x' in fctx.flags(), renamed) | 'x' in fctx.flags(), renamed) | ||||
| # Remap tag data using a revision map | # Remap tag data using a revision map | ||||