[PATCH] help: move topic "files" from /doc/hg.1.txt to /mercurial/help/ (issue2760)

Adrian Buehlmann adrian at cadifra.com
Thu Apr 28 14:11:06 CDT 2011


On 2011-04-28 20:57, Adrian Buehlmann wrote:
> On 2011-04-28 20:43, Kevin Bullock wrote:
>> On Apr 28, 2011, at 11:32 AM, Adrian Buehlmann wrote:
>>
>>> This might be a bit far-fetched: but - if possible - I would prefer if
>>> we could reserve the name "files" for something else and not consume the
>>> name "files" for this specific help topic here.
>>>
>>> Imagine there would be a new 'files' command in the future: "hg files"
>>> (we already have 'hg branches', 'hg tags', etc. and mercurial is about
>>> tracking files...).
>>
>> Umm, `hg manifest`?
> 
> Yeah. That's using the manifest :-)
> 
>>> Getting help about that hypothetical files command would be "hg help
>>> files". If we take that for a help topic *now*, we would have to rename
>>> it later, invalidating URLs to that help topic.
>>>
>>> (for a hypothetical files command candidate see [1])
>>>
>>> [1] https://bitbucket.org/abuehl/hgext-cifiles
>>
>>
>> What does cifiles do in contradistinction to `manifest`?
> 
> As explained in
> 
> https://bitbucket.org/abuehl/hgext-cifiles/src/default/cifiles.py
> 
>     Prints the names of all files that have been checked-in in any revision
>     of the repository (including files that are deleted or renamed in tip).
> 
> A pretty costly operation, if you try to do that by using the manifests.
> 
> cifiles doesn't access the manifests at all.

More specifically, I'm thinking of proposing:

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1748,6 +1748,29 @@
                  switch_parent=opts.get('switch_parent'),
                  opts=patch.diffopts(ui, opts))

+def files(ui, repo, *pats, **opts):
+    """list all known files
+
+    Prints the names of all files that have been checked-in in any revision
+    of the repository. Includes files that were deleted or renamed.
+
+    Returns 0.
+    """
+    res = []
+    prefix = "data/"
+    suffix = ".i"
+    plen = len(prefix)
+    slen = len(suffix)
+    lock = repo.lock()
+    try:
+        for fn, b, size in repo.store.datafiles():
+            if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
+                res.append(fn[plen:-slen])
+    finally:
+        lock.release()
+    for f in sorted(res):
+        ui.write("%s\n" % f)
+
 def forget(ui, repo, *pats, **opts):
     """forget the specified files on the next commit

@@ -4581,6 +4604,7 @@
         (forget,
          [] + walkopts,
          _('[OPTION]... FILE...')),
+    "files": (files, [], ''),
     "grep":
         (grep,
          [('0', 'print0', None, _('end fields with NUL')),


More information about the Mercurial-devel mailing list