Submitter | Sean Farley |
---|---|
Date | March 25, 2015, 5:46 a.m. |
Message ID | <1fc4b58112600db90c71.1427262417@1.0.0.127.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/8257/ |
State | Changes Requested |
Headers | show |
Comments
Sean Farley <sean@farley.io> writes: > # HG changeset patch > # User Sean Farley <sean@farley.io> > # Date 1427261050 25200 > # Tue Mar 24 22:24:10 2015 -0700 > # Node ID 1fc4b58112600db90c710f32a3ec6f5c4438d5df > # Parent f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd > status: add terse option flag (issue4119) > > Based on work by Martin Geisler, this patch adds the option to list only > directories of untracked files. A test has been added. > > diff --git a/mercurial/commands.py b/mercurial/commands.py > --- a/mercurial/commands.py > +++ b/mercurial/commands.py > @@ -5688,10 +5688,11 @@ class httpservice(object): > ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), > ('', 'rev', [], _('show difference from revision'), _('REV')), > ('', 'change', '', _('list the changed files of a revision'), _('REV')), > ('', 'relative', None, > ('list the changed files relative to working directory')), > + ('t', 'terse', None, _('show only directory of unknown files')), > ] + walkopts + subrepoopts + formatteropts, > _('[OPTION]... [FILE]...'), > inferrepo=True) > def status(ui, repo, *pats, **opts): > """show changed files in the working directory > @@ -5788,10 +5789,40 @@ def status(ui, repo, *pats, **opts): > show = states[:5] > > stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), > 'ignored' in show, 'clean' in show, 'unknown' in show, > opts.get('subrepos')) > + > + if 'unknown' in show and opts.get('terse'): > + knowndirs = set(['']) # root is always known > + results = set() > + > + # gather known directories > + for path in repo[node1]: Whoops, this should be repo[None] so we can avoid reading obs markers.
On Tue, Mar 24, 2015 at 10:58:00PM -0700, Sean Farley wrote: > > Sean Farley <sean@farley.io> writes: > > > # HG changeset patch > > # User Sean Farley <sean@farley.io> > > # Date 1427261050 25200 > > # Tue Mar 24 22:24:10 2015 -0700 > > # Node ID 1fc4b58112600db90c710f32a3ec6f5c4438d5df > > # Parent f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd > > status: add terse option flag (issue4119) > > > > Based on work by Martin Geisler, this patch adds the option to list only > > directories of untracked files. A test has been added. > > > > diff --git a/mercurial/commands.py b/mercurial/commands.py > > --- a/mercurial/commands.py > > +++ b/mercurial/commands.py > > @@ -5688,10 +5688,11 @@ class httpservice(object): > > ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), > > ('', 'rev', [], _('show difference from revision'), _('REV')), > > ('', 'change', '', _('list the changed files of a revision'), _('REV')), > > ('', 'relative', None, > > ('list the changed files relative to working directory')), > > + ('t', 'terse', None, _('show only directory of unknown files')), > > ] + walkopts + subrepoopts + formatteropts, > > _('[OPTION]... [FILE]...'), > > inferrepo=True) > > def status(ui, repo, *pats, **opts): > > """show changed files in the working directory > > @@ -5788,10 +5789,40 @@ def status(ui, repo, *pats, **opts): > > show = states[:5] > > > > stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), > > 'ignored' in show, 'clean' in show, 'unknown' in show, > > opts.get('subrepos')) > > + > > + if 'unknown' in show and opts.get('terse'): > > + knowndirs = set(['']) # root is always known > > + results = set() > > + > > + # gather known directories > > + for path in repo[node1]: > > Whoops, this should be repo[None] so we can avoid reading obs markers. I assume we expect a v2 of this patch? I don't know if I missed any IRC discussion surrounding it. > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler <raf@durin42.com> writes: > On Tue, Mar 24, 2015 at 10:58:00PM -0700, Sean Farley wrote: >> >> Sean Farley <sean@farley.io> writes: >> >> > # HG changeset patch >> > # User Sean Farley <sean@farley.io> >> > # Date 1427261050 25200 >> > # Tue Mar 24 22:24:10 2015 -0700 >> > # Node ID 1fc4b58112600db90c710f32a3ec6f5c4438d5df >> > # Parent f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd >> > status: add terse option flag (issue4119) >> > >> > Based on work by Martin Geisler, this patch adds the option to list only >> > directories of untracked files. A test has been added. >> > >> > diff --git a/mercurial/commands.py b/mercurial/commands.py >> > --- a/mercurial/commands.py >> > +++ b/mercurial/commands.py >> > @@ -5688,10 +5688,11 @@ class httpservice(object): >> > ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), >> > ('', 'rev', [], _('show difference from revision'), _('REV')), >> > ('', 'change', '', _('list the changed files of a revision'), _('REV')), >> > ('', 'relative', None, >> > ('list the changed files relative to working directory')), >> > + ('t', 'terse', None, _('show only directory of unknown files')), >> > ] + walkopts + subrepoopts + formatteropts, >> > _('[OPTION]... [FILE]...'), >> > inferrepo=True) >> > def status(ui, repo, *pats, **opts): >> > """show changed files in the working directory >> > @@ -5788,10 +5789,40 @@ def status(ui, repo, *pats, **opts): >> > show = states[:5] >> > >> > stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), >> > 'ignored' in show, 'clean' in show, 'unknown' in show, >> > opts.get('subrepos')) >> > + >> > + if 'unknown' in show and opts.get('terse'): >> > + knowndirs = set(['']) # root is always known >> > + results = set() >> > + >> > + # gather known directories >> > + for path in repo[node1]: >> >> Whoops, this should be repo[None] so we can avoid reading obs markers. > > I assume we expect a v2 of this patch? I don't know if I missed any > IRC discussion surrounding it. Yep, working on it now. There was some IRC discussion with bikeshedding and I'll send out a RFC soon.
Patch
diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5688,10 +5688,11 @@ class httpservice(object): ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), ('', 'rev', [], _('show difference from revision'), _('REV')), ('', 'change', '', _('list the changed files of a revision'), _('REV')), ('', 'relative', None, ('list the changed files relative to working directory')), + ('t', 'terse', None, _('show only directory of unknown files')), ] + walkopts + subrepoopts + formatteropts, _('[OPTION]... [FILE]...'), inferrepo=True) def status(ui, repo, *pats, **opts): """show changed files in the working directory @@ -5788,10 +5789,40 @@ def status(ui, repo, *pats, **opts): show = states[:5] stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), 'ignored' in show, 'clean' in show, 'unknown' in show, opts.get('subrepos')) + + if 'unknown' in show and opts.get('terse'): + knowndirs = set(['']) # root is always known + results = set() + + # gather known directories + for path in repo[node1]: + d = os.path.dirname(path) + while d not in knowndirs: + knowndirs.add(d) + d = os.path.dirname(d) + + # now loop over to prune them out + for path in stat.unknown: + prev = path + d = os.path.dirname(prev) + while d not in knowndirs: + prev = d + d = os.path.dirname(prev) + + if prev != path: + results.add(prev + '/') + else: + results.add(path) + + # replace the previous unknown list + stat = list(stat) + stat[4] = list(sorted(results)) + stat = scmutil.status(*stat) + changestates = zip(states, 'MAR!?IC', stat) if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): copy = copies.pathcopies(repo[node1], repo[node2]) diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -211,11 +211,11 @@ Show all commands + options merge: force, rev, preview, tool pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure remove: after, force, subrepos, include, exclude serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate - status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, relative, include, exclude, subrepos, template + status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, relative, terse, include, exclude, subrepos, template summary: remote update: clean, check, date, rev, tool addremove: similarity, subrepos, include, exclude, dry-run archive: no-decode, prefix, rev, type, subrepos, include, exclude backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -570,10 +570,11 @@ Test command without options -C --copies show source of copied files -0 --print0 end filenames with NUL, for use with xargs --rev REV [+] show difference from revision --change REV list the changed files of a revision --relative list the changed files relative to working directory + -t --terse show only directory of unknown files -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns -S --subrepos recurse into subrepositories (some details hidden, use --verbose to show complete help) diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -109,10 +109,17 @@ test status relative flag ? ../../a/in_a ? ../1/in_b_1 ? in_b_2 ? ../in_b ? ../../in_root + +test status with terse + + $ hg status --terse + ? a/ + ? b/ + ? in_root $ cd ../.. combining patterns with root and patterns without a root works $ hg st a/in_a re:.*b$