cmdutil: make "files" list all files, add "file_mods" for modified files
authorPatrick Mezard <pmezard@gmail.com>
Sat, 24 Nov 2007 20:16:59 +0100
changeset 5550 db6633f11d59
parent 5545 5a124ce4602a
child 5551 dccc127bfc07
cmdutil: make "files" list all files, add "file_mods" for modified files
mercurial/cmdutil.py
templates/map-cmdline.default
tests/test-command-template
tests/test-command-template.out
--- a/mercurial/cmdutil.py	Sat Nov 24 17:56:15 2007 +0100
+++ b/mercurial/cmdutil.py	Sat Nov 24 20:16:59 2007 +0100
@@ -578,15 +578,10 @@
                 files[:] = self.repo.status(
                     log.parents(changenode)[0], changenode)[:3]
             return files
-        # XXX: "files" means "modified files" in debug, "all changed
-        # files" otherwise. This should be fixed and a "file_mods" be
-        # introduced instead.
-        if self.ui.debugflag:
-            def showfiles(**args):
-                return showlist('file', getfiles()[0], **args)
-        else:
-            def showfiles(**args):
-                return showlist('file', changes[3], **args)
+        def showfiles(**args):
+            return showlist('file', changes[3], **args)
+        def showmods(**args):
+            return showlist('file_mod', getfiles()[0], **args)
         def showadds(**args):
             return showlist('file_add', getfiles()[1], **args)
         def showdels(**args):
@@ -604,6 +599,7 @@
             'desc': changes[4].strip(),
             'file_adds': showadds,
             'file_dels': showdels,
+            'file_mods': showmods,
             'files': showfiles,
             'file_copies': showcopies,
             'manifest': showmanifest,
--- a/templates/map-cmdline.default	Sat Nov 24 17:56:15 2007 +0100
+++ b/templates/map-cmdline.default	Sat Nov 24 20:16:59 2007 +0100
@@ -1,10 +1,13 @@
 changeset = 'changeset:   {rev}:{node|short}\n{branches}{tags}{parents}user:        {author}\ndate:        {date|date}\nsummary:     {desc|firstline}\n\n'
 changeset_quiet = '{rev}:{node|short}\n'
 changeset_verbose = 'changeset:   {rev}:{node|short}\n{branches}{tags}{parents}user:        {author}\ndate:        {date|date}\n{files}{file_copies}description:\n{desc|strip}\n\n\n'
-changeset_debug = 'changeset:   {rev}:{node}\n{branches}{tags}{parents}{manifest}user:        {author}\ndate:        {date|date}\n{files}{file_adds}{file_dels}{file_copies}{extras}description:\n{desc|strip}\n\n\n'
+changeset_debug = 'changeset:   {rev}:{node}\n{branches}{tags}{parents}{manifest}user:        {author}\ndate:        {date|date}\n{file_mods}{file_adds}{file_dels}{file_copies}{extras}description:\n{desc|strip}\n\n\n'
 start_files = 'files:      '
 file = ' {file}'
 end_files = '\n'
+start_file_mods = 'files:      '
+file_mod = ' {file_mod}'
+end_file_mods = '\n'
 start_file_adds = 'files+:     '
 file_add = ' {file_add}'
 end_file_adds = '\n'
--- a/tests/test-command-template	Sat Nov 24 17:56:15 2007 +0100
+++ b/tests/test-command-template	Sat Nov 24 20:16:59 2007 +0100
@@ -89,8 +89,8 @@
 cat changelog
 
 echo "# keys work"
-for key in author branches date desc file_adds file_dels files \
-        manifest node parents rev tags; do
+for key in author branches date desc file_adds file_dels file_mods \
+        files manifest node parents rev tags; do
     for mode in '' --verbose --debug; do
         hg log $mode --template "$key$mode: {$key}\n"
     done
--- a/tests/test-command-template.out	Sat Nov 24 17:56:15 2007 +0100
+++ b/tests/test-command-template.out	Sat Nov 24 20:16:59 2007 +0100
@@ -308,6 +308,30 @@
 file_dels--debug: 
 file_dels--debug: 
 file_dels--debug: 
+file_mods: 
+file_mods: 
+file_mods: 
+file_mods: 
+file_mods: c
+file_mods: 
+file_mods: 
+file_mods: 
+file_mods--verbose: 
+file_mods--verbose: 
+file_mods--verbose: 
+file_mods--verbose: 
+file_mods--verbose: c
+file_mods--verbose: 
+file_mods--verbose: 
+file_mods--verbose: 
+file_mods--debug: 
+file_mods--debug: 
+file_mods--debug: 
+file_mods--debug: 
+file_mods--debug: c
+file_mods--debug: 
+file_mods--debug: 
+file_mods--debug: 
 files: second
 files: 
 files: d
@@ -324,14 +348,14 @@
 files--verbose: c
 files--verbose: b
 files--verbose: a
-files--debug: 
+files--debug: second
 files--debug: 
-files--debug: 
+files--debug: d
 files--debug: 
 files--debug: c
-files--debug: 
-files--debug: 
-files--debug: 
+files--debug: c
+files--debug: b
+files--debug: a
 manifest: 7:f2dbc354b94e
 manifest: 6:91015e9dbdd7
 manifest: 5:4dc3def4f9b4