make manifest friendlier
authorMatt Mackall <mpm@selenic.com>
Thu, 30 Nov 2006 22:38:48 -0600
changeset 3736 ad3d5b4367cb
parent 3735 205f0fd4a4a1
child 3737 9f5c46c50118
make manifest friendlier switch to using context code ..which uses first parent by default show file hashes only with debug switch show permissions with verbose fix up tests
mercurial/commands.py
tests/test-basic
tests/test-empty-file
tests/test-excessive-merge
tests/test-filebranch
tests/test-git-import
tests/test-merge6
tests/test-pull
tests/test-rawcommit1
tests/test-simple-update
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1513,25 +1513,22 @@ def manifest(ui, repo, rev=None):
     Print a list of version controlled files for the given revision.
 
     The manifest is the list of files being version controlled. If no revision
-    is given then the tip is used.
+    is given then the first parent of the working directory is used.
+
+    With -v flag, print file permissions. With --debug flag, print
+    file revision hashes.
     """
-    if rev:
-        try:
-            # assume all revision numbers are for changesets
-            n = repo.lookup(rev)
-            change = repo.changelog.read(n)
-            n = change[0]
-        except hg.RepoError:
-            n = repo.manifest.lookup(rev)
-    else:
-        n = repo.manifest.tip()
-    m = repo.manifest.read(n)
+
+    m = repo.changectx(rev).manifest()
     files = m.keys()
     files.sort()
 
     for f in files:
-        ui.write("%40s %3s %s\n" % (hex(m[f]),
-                                    m.execf(f) and "755" or "644", f))
+        if ui.debugflag:
+            ui.write("%40s " % hex(m[f]))
+        if ui.verbose:
+            ui.write("%3s " % (m.execf(f) and "755" or "644"))
+        ui.write("%s\n" % f)
 
 def merge(ui, repo, node=None, force=None, branch=None):
     """Merge working directory with another revision
--- a/tests/test-basic
+++ b/tests/test-basic
@@ -7,6 +7,6 @@ echo a > a
 hg add a
 hg commit -m test -d "1000000 0"
 hg history
-hg manifest
+hg manifest --debug
 hg cat a
 hg verify
--- a/tests/test-empty-file
+++ b/tests/test-empty-file
@@ -22,4 +22,4 @@ hg merge 1
 # empty file that came from rev 1.
 hg status
 hg commit -m merge -d '1000000 0'
-hg manifest tip
+hg manifest --debug tip
--- a/tests/test-excessive-merge
+++ b/tests/test-excessive-merge
@@ -31,13 +31,13 @@ hg debugindex .hg/00changelog.i
 echo
 
 echo 1
-hg manifest 1
+hg manifest --debug 1
 echo 2
-hg manifest 2
+hg manifest --debug 2
 echo 3
-hg manifest 3
+hg manifest --debug 3
 echo 4
-hg manifest 4
+hg manifest --debug 4
 
 echo
 
--- a/tests/test-filebranch
+++ b/tests/test-filebranch
@@ -71,7 +71,7 @@ echo "quux: we shouldn't have a merge he
 hg debugindex .hg/data/quux.i
 
 echo "manifest entries should match tips of all files"
-hg manifest
+hg manifest --debug
 
 echo "everything should be clean now"
 hg status
--- a/tests/test-git-import
+++ b/tests/test-git-import
@@ -161,7 +161,7 @@ rename from foo
 rename to foo2
 EOF
 cat foo2
-hg manifest | grep binary
+hg manifest --debug | grep binary
 
 echo % many binary files
 hg import -m multibinary - <<EOF
@@ -180,4 +180,4 @@ literal 5
 Mc\${NkU|\`?^000jF3jhEB
 
 EOF
-hg manifest | grep mbinary
+hg manifest --debug | grep mbinary
--- a/tests/test-merge6
+++ b/tests/test-merge6
@@ -36,11 +36,11 @@ hg pull ../B1
 hg merge
 hg commit -m "commit test" -d "1000000 0"
 echo bar should remain deleted.
-hg manifest
+hg manifest --debug
 
 cd ../B2
 hg pull ../A2
 hg merge
 hg commit -m "commit test" -d "1000000 0"
 echo bar should remain deleted.
-hg manifest
+hg manifest --debug
--- a/tests/test-pull
+++ b/tests/test-pull
@@ -16,5 +16,5 @@ cd copy
 hg verify
 hg co
 cat foo
-hg manifest
+hg manifest --debug
 hg pull
--- a/tests/test-rawcommit1
+++ b/tests/test-rawcommit1
@@ -6,28 +6,28 @@ hg commit -m0 -d "1000000 0"
 echo this is b1 > b
 hg add b
 hg commit -m1 -d "1000000 0"
-hg manifest 1
+hg manifest --debug 1
 echo this is c1 > c
 hg rawcommit -p 1 -d "1000000 0" -m2 c
-hg manifest 2
+hg manifest --debug 2
 hg -v parents
 rm b
 hg rawcommit -p 2 -d "1000000 0" -m3 b
-hg manifest 3
+hg manifest --debug 3
 hg -v parents
 echo this is a22 > a
 hg rawcommit -p 3 -d "1000000 0" -m4 a
-hg manifest 4
+hg manifest --debug 4
 hg -v parents
 echo this is c22 > c
 hg rawcommit -p 1 -d "1000000 0" -m5 c
-hg manifest 5
+hg manifest --debug 5
 hg -v parents
 # merge, but no files changed
 hg rawcommit -p 4 -p 5 -d "1000000 0" -m6
-hg manifest 6
+hg manifest --debug 6
 hg -v parents
 # no changes what-so-ever
 hg rawcommit -p 6 -d "1000000 0" -m7
-hg manifest 7
+hg manifest --debug 7
 hg -v parents
--- a/tests/test-simple-update
+++ b/tests/test-simple-update
@@ -21,4 +21,4 @@ hg pull ../branch
 hg verify
 hg co
 cat foo
-hg manifest
+hg manifest --debug