[PATCH] commands: eliminate the 'manifest' command and merge it into 'locate'

Dan Villiom Podlaski Christiansen danchr at gmail.com
Mon Aug 10 12:08:13 CDT 2009


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1249918039 -7200
# Node ID 1ff4dfc35a7e5ddb34057d66133cf6f39356f2cc
# Parent  3a4bee915c3109df3110df8e65136f72374c1c1c
commands: eliminate the 'manifest' command and merge it into 'locate'.

The functionality of the previous manifest command is merged into the
locate command. Now, 'manifest' is simply another way to refer to the
'locate' command.

Please note that I inserted a small compatibility hack to allow 'hg
manifest <rev>' to continue to work. A side-effect of this is that 'hg
locate <whatever>' will not work if the first words of '<whatever>'
are known revisions.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1935,22 +1935,60 @@ def locate(ui, repo, *pats, **opts):
     command, use the -0 option to both this command and "xargs". This
     will avoid the problem of "xargs" treating single filenames that
     contain whitespace as multiple filenames.
+
+    Under normal usage, a simple list of files is printed. However,
+    when the -v/--verbose switch is used, output includes the octal
+    permissions, executable bit and symbolic link status of the
+    file. With --debug, hashes of the individual file revisions is
+    included.
+
+    For compatibility reasons, the revision to list may also be
+    specified as the first argument, instead of a pattern. However,
+    such usage is deprecated and discouraged.
     """
     end = opts.get('print0') and '\0' or '\n'
     rev = opts.get('rev') or None
 
+    # This is a hack to remain compatible with the old 'manifest' command.
+    if pats:
+        try:
+            pat = repo.lookup(pats[0])
+            if rev is None:
+                rev = pats[0]
+                pats = pats[1:]
+            else:
+                raise util.Abort(_("please specify just one revision"))
+        except error.RepoError:
+            pass
+
+    ctx = repo[rev]
+
+    if ui.debugflag:
+        manifest = ctx.manifest()
+    if ui.verbose:
+        decor = {'l':'644 @', 'x':'755 *', '':'644  '}
+
     ret = 1
     m = cmdutil.match(repo, pats, opts, default='relglob')
     m.bad = lambda x,y: False
-    for abs in repo[rev].walk(m):
-        if not rev and abs not in repo.dirstate:
+    for path in ctx.walk(m):
+        if not rev and path not in repo.dirstate:
             continue
+
+        start = []
+        if ui.debugflag:
+            start.append(hex(manifest[path]))
+        if ui.verbose:
+            start.append(decor[ctx.flags(path)])
+
         if opts.get('fullpath'):
-            ui.write(repo.wjoin(abs), end)
+            path = repo.wjoin(path)
         else:
-            ui.write(((pats and m.rel(abs)) or abs), end)
+            path = (pats and m.rel(path)) or path
         ret = 0
 
+        ui.write(' '.join(start + [path]), end)
+
     return ret
 
 def log(ui, repo, *pats, **opts):
@@ -2079,32 +2117,6 @@ def log(ui, repo, *pats, **opts):
             if displayer.flush(rev):
                 count += 1
 
-def manifest(ui, repo, node=None, rev=None):
-    """output the current or given revision of the project manifest
-
-    Print a list of version controlled files for the given revision.
-    If no revision is given, the first parent of the working directory
-    is used, or the null revision if no revision is checked out.
-
-    With -v, print file permissions, symlink and executable bits.
-    With --debug, print file revision hashes.
-    """
-
-    if rev and node:
-        raise util.Abort(_("please specify just one revision"))
-
-    if not node:
-        node = rev
-
-    decor = {'l':'644 @ ', 'x':'755 * ', '':'644   '}
-    ctx = repo[node]
-    for f in ctx:
-        if ui.debugflag:
-            ui.write("%40s " % hex(ctx.manifest()[f]))
-        if ui.verbose:
-            ui.write(decor[ctx.flags(f)])
-        ui.write("%s\n" % f)
-
 def merge(ui, repo, node=None, **opts):
     """merge working directory with another revision
 
@@ -3383,7 +3395,7 @@ table = {
         (init,
          remoteopts,
          _('[-e CMD] [--remotecmd CMD] [DEST]')),
-    "locate":
+    "locate|manifest":
         (locate,
          [('r', 'rev', '', _('search the repository as it stood at REV')),
           ('0', 'print0', None,
@@ -3410,10 +3422,6 @@ table = {
           ('P', 'prune', [], _('do not display revision or any of its ancestors')),
          ] + logopts + walkopts,
          _('[OPTION]... [FILE]')),
-    "manifest":
-        (manifest,
-         [('r', 'rev', '', _('revision to display'))],
-         _('[-r REV]')),
     "^merge":
         (merge,
          [('f', 'force', None, _('force a merge with outstanding changes')),
diff --git a/tests/test-debugcomplete.out b/tests/test-debugcomplete.out
--- a/tests/test-debugcomplete.out
+++ b/tests/test-debugcomplete.out
@@ -24,7 +24,6 @@ incoming
 init
 locate
 log
-manifest
 merge
 outgoing
 parents
@@ -211,7 +210,6 @@ identify: rev, num, id, branch, tags
 import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
 incoming: force, newest-first, bundle, rev, patch, git, limit, no-merges, style, template, ssh, remotecmd
 locate: rev, print0, fullpath, include, exclude
-manifest: rev
 outgoing: force, rev, newest-first, patch, git, limit, no-merges, style, template, ssh, remotecmd
 paths: 
 recover: 
diff --git a/tests/test-globalopts.out b/tests/test-globalopts.out
--- a/tests/test-globalopts.out
+++ b/tests/test-globalopts.out
@@ -174,7 +174,6 @@ list of commands:
  init         create a new repository in the given directory
  locate       locate files matching specific patterns
  log          show revision history of entire repository or files
- manifest     output the current or given revision of the project manifest
  merge        merge working directory with another revision
  outgoing     show changesets not found in destination
  parents      show the parents of the working directory or revision
@@ -241,7 +240,6 @@ list of commands:
  init         create a new repository in the given directory
  locate       locate files matching specific patterns
  log          show revision history of entire repository or files
- manifest     output the current or given revision of the project manifest
  merge        merge working directory with another revision
  outgoing     show changesets not found in destination
  parents      show the parents of the working directory or revision
diff --git a/tests/test-help.out b/tests/test-help.out
--- a/tests/test-help.out
+++ b/tests/test-help.out
@@ -67,7 +67,6 @@ list of commands:
  init         create a new repository in the given directory
  locate       locate files matching specific patterns
  log          show revision history of entire repository or files
- manifest     output the current or given revision of the project manifest
  merge        merge working directory with another revision
  outgoing     show changesets not found in destination
  parents      show the parents of the working directory or revision
@@ -130,7 +129,6 @@ use "hg -v help" to show aliases and glo
  init         create a new repository in the given directory
  locate       locate files matching specific patterns
  log          show revision history of entire repository or files
- manifest     output the current or given revision of the project manifest
  merge        merge working directory with another revision
  outgoing     show changesets not found in destination
  parents      show the parents of the working directory or revision


More information about the Mercurial-devel mailing list