[PATCH 1 of 2] lfs: capture the file name when creating a filelog
Yuya Nishihara
yuya at tcha.org
Mon Jan 8 08:35:31 EST 2018
On Sun, 07 Jan 2018 23:28:37 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1515355319 18000
> # Sun Jan 07 15:01:59 2018 -0500
> # Node ID e9185c88cf15324fc5e9b590dbb415f07f6d4f18
> # Parent a774180955300dc73a9cabdc23238813faa61e3e
> lfs: capture the file name when creating a filelog
>
> This will be useful when matching file names, as well as when they need to be
> displayed on error. The code is from Jun Wu's larger series that matches on
> more than just the size[1].
>
> [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-December/109388.html
>
> diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
> --- a/hgext/lfs/__init__.py
> +++ b/hgext/lfs/__init__.py
> @@ -143,6 +143,7 @@
> def wrapfilelog(filelog):
> wrapfunction = extensions.wrapfunction
>
> + wrapfunction(filelog, '__init__', wrapper.fileloginit)
> wrapfunction(filelog, 'addrevision', wrapper.filelogaddrevision)
> wrapfunction(filelog, 'renamed', wrapper.filelogrenamed)
> wrapfunction(filelog, 'size', wrapper.filelogsize)
> diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
> --- a/hgext/lfs/wrapper.py
> +++ b/hgext/lfs/wrapper.py
> @@ -120,6 +120,11 @@
> flags = rlog.flags(rev)
> return bool(flags & revlog.REVIDX_EXTSTORED)
>
> +def fileloginit(orig, self, opener, path, *args, **kwargs):
> + # record filename so it can be displayed or used for matching
> + self.filename = path
> + orig(self, opener, path, *args, **kwargs)
Maybe it's okay to keep the filename in core (or alternatively add a utility
function to get back filename from indexfile path.)
I think we already have cryptic [5:] or [:-2] at several places.
More information about the Mercurial-devel
mailing list