Mercurial > hg-stable
changeset 35663:a985834961f7
lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
The only other interface to this data is `hg debugdata`, which requires
knowledge of the filelog revision that corresponds to the changeset. Since the
data is uninterpreted, this is an important debugging capability, and needs to
be simpler to use than that.
For non-LFS files, this displays the regular data.
Alternately, we could forego the messy function extraction in the last patch if
this template keyword can just be added unconditionally.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 16 Jan 2018 20:15:07 -0500 |
parents | 91f0979f16c0 |
children | 3c838bdc57b6 |
files | hgext/lfs/__init__.py hgext/lfs/wrapper.py tests/test-lfs.t |
diffstat | 3 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/lfs/__init__.py Tue Jan 16 19:56:00 2018 -0500 +++ b/hgext/lfs/__init__.py Tue Jan 16 20:15:07 2018 -0500 @@ -52,6 +52,7 @@ from mercurial import ( bundle2, changegroup, + cmdutil, context, exchange, extensions, @@ -169,6 +170,7 @@ wrapfunction = extensions.wrapfunction + wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter) wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink) wrapfunction(upgrade, '_finishdatamigration',
--- a/hgext/lfs/wrapper.py Tue Jan 16 19:56:00 2018 -0500 +++ b/hgext/lfs/wrapper.py Tue Jan 16 20:15:07 2018 -0500 @@ -179,6 +179,10 @@ def filectxislfs(self): return _islfs(self.filelog(), self.filenode()) +def _updatecatformatter(orig, fm, ctx, matcher, path, decode): + orig(fm, ctx, matcher, path, decode) + fm.data(rawdata=ctx[path].rawdata()) + def convertsink(orig, sink): sink = orig(sink) if sink.repotype == 'hg':
--- a/tests/test-lfs.t Tue Jan 16 19:56:00 2018 -0500 +++ b/tests/test-lfs.t Tue Jan 16 20:15:07 2018 -0500 @@ -842,7 +842,7 @@ 0 meta $ grep 'lfs' convert_normal/.hg/requires [1] - $ hg --cwd convert_normal debugdata a1 0 + $ hg --cwd convert_normal cat a1 -r 0 -T '{rawdata}' THIS-IS-LFS-BECAUSE-10-BYTES $ hg --config extensions.convert= --config lfs.threshold=10B \ @@ -854,6 +854,12 @@ 2 a 1 b 0 meta + + $ hg --cwd convert_lfs cat -r 0 a1 -T '{rawdata}' + version https://git-lfs.github.com/spec/v1 + oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024 + size 29 + x-is-binary 0 $ hg --cwd convert_lfs debugdata a1 0 version https://git-lfs.github.com/spec/v1 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024