sapling/tests/ls-l.py
Jun Wu 4240bd017e remotefilelog: let content stores support metadata
Summary:
This diffs add a `getmeta` method to all content stores. The cdatapack code is
modified to pass the tests, it needs further change to support `getmeta`.

The datapack format is bumped to v1 from v0. For v1, we append a `metadata`
dict at the end of each revision. The dict is currently used to store revlog
flags and rawsize of raw revlog fulltext. In the future we can put more data
like a second hash etc, without changing API or format again.

This diff focuses on correctness. A datapack caching layer to speed up
`getmeta` will be added later.

Tests are updated since we write new v1 packfile now and the format change
leads to different content and packfile names.

`Makefile`, `ls-l.py` are added to make tests easier to maintain.

Test Plan: Updated existing tests.

Reviewers: #mercurial, rmcelroy, durham

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4903917

Signature: t1:4903917:1493255844:7ef5d487096cd2f78f2aaae672a68d49f33632ee
2017-04-26 19:50:36 -07:00

37 lines
870 B
Python
Executable File

#!/usr/bin/env python
# like ls -l, but do not print date, user, or non-common mode bit, to avoid
# using globs in tests.
import os
import stat
import sys
def modestr(st):
mode = st.st_mode
result = ''
if mode & stat.S_IFDIR:
result += 'd'
else:
result += '-'
for owner in ['USR', 'GRP', 'OTH']:
for action in ['R', 'W', 'X']:
if mode & getattr(stat, 'S_I%s%s' % (action, owner)):
result += action.lower()
else:
result += '-'
return result
def sizestr(st):
if st.st_mode & stat.S_IFREG:
return '%7d' % st.st_size
else:
# do not show size for non regular files
return ' ' * 7
os.chdir((sys.argv[1:] + ['.'])[0])
for name in sorted(os.listdir('.')):
st = os.stat(name)
print('%s %s %s' % (modestr(st), sizestr(st), name))