Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing only working directory files and dirs in hg manifest?

Tags:

mercurial

I'm trying to get a list of the current files and dirs using the following command:

hg manifest -r tip

However, this brings a list like this:

.hgtags
folder1/blah.c
folder1/blah.h
foo.json
folder2/bleh.c
folder2/bleh.h
test.json

How can I list only the following?

.hgtags
folder1
foo.json
folder2
test.json
like image 781
vinnylinux Avatar asked May 19 '18 01:05

vinnylinux


Video Answer


1 Answers

On Unix machine you could try:

hg manifest -r tip | cut -d "/" -f 1 | sort -u

or

hg manifest -r tip | cut -d "/" -f 1 | uniq
  1. cut -d "/" -f 1: select first portion delimited by '/'
  2. uniq: filter out repeated lines

Or using Python (more cross-platform):

You need to have python-glib installed (via pip)

import hglib
repo = hglib.open("/path/to/repo")
manifest = repo.manifest("tip")
files = set(f[4].split('/')[0] for f in manifest)
like image 145
aflp91 Avatar answered Oct 16 '22 06:10

aflp91