[omd-commits] OMD Git: omd: omd: Added verbose handling and single file processing to " omd diff"

git version control git at mathias-kettner.de
Mon Jun 13 00:41:51 CEST 2011


Module:   omd
Branch:   master
Commit:   c71d4d3e835f412948134856b6aa6423818c19ce
URL:      http://omdistro.org/projects/omd/repository/revisions/c71d4d3e835f412948134856b6aa6423818c19ce

Author:   Lars Michelsen <lm at mathias-kettner.de>
Date:     Mon Jun 13 00:40:45 2011 +0200
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date:     Mon Jun 13 00:40:45 2011 +0200

omd: Added verbose handling and single file processing to "omd diff"

---

 packages/omd/omd   |   25 +++++++++++++++----------
 packages/omd/omd.8 |   15 ++++++++++-----
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/packages/omd/omd b/packages/omd/omd
index 79f8277..081cbf3 100644
--- a/packages/omd/omd
+++ b/packages/omd/omd
@@ -2120,6 +2120,16 @@ def diff_list(from_skelroot, g_sitedir, from_version, relbase, bare):
             else:
                 sys.stdout.write(color + " %s %s\n" % (long_out, f))
 
+            # Show a little more details in verbose mode
+            if opt_verbose:
+                arrow = tty_magenta + '->' + tty_normal
+                if 'c' in status:
+                    os.system("pwd ; diff -u %s %s" % (source_file, target_file))
+                elif status == 'p':
+                    sys.stdout.write("    %s %s %s\n" % (source_perm, arrow, target_perm))
+                elif 't' in status:
+                    sys.stdout.write("    %s %s %s\n" % (source_type, arrow, target_type))
+
         if not target_type:
             print_status(good, fn, 'd', 'Deleted')
             return
@@ -2134,12 +2144,15 @@ def diff_list(from_skelroot, g_sitedir, from_version, relbase, bare):
             print_status(good, fn, 'c', 'Changed content')
 
         if source_perm != target_perm:
-            print_status(warn, fn, 'c', 'Changed permissions')
+            print_status(warn, fn, 'p', 'Changed permissions')
 
     read_skel_permissions()
     old_perms = load_skel_permissions(from_version)
 
-    walk_skel(from_skelroot, print_diff, (from_skelroot, g_sitedir, from_version, old_perms), relbase = relbase)
+    if not os.path.isdir(relbase):
+        print_diff(relbase, from_skelroot, g_sitedir, from_version, old_perms)
+    else:
+        walk_skel(from_skelroot, print_diff, (from_skelroot, g_sitedir, from_version, old_perms), relbase = relbase)
 
 
 def main_diff(args, options={}):
@@ -2147,14 +2160,6 @@ def main_diff(args, options={}):
     from_skelroot = "/omd/versions/%s/skel" % from_version
 
     relbase = len(args) > 0 and args[0].rstrip('/') or '.'
-
-    path = from_skelroot + '/' + relbase
-    if not os.path.isdir(path):
-        bail_out("The given path %s is no directory" % path)
-
-    # First implementation: Outputs only a list of changed/deleted files compared
-    # to the current version. With dir/file name given the diff could show more details
-    # like te file contents and so on
     diff_list(from_skelroot, g_sitedir, from_version, relbase, "bare" in options)
 
 
diff --git a/packages/omd/omd.8 b/packages/omd/omd.8
index 011fa5c..cbcc6e6 100644
--- a/packages/omd/omd.8
+++ b/packages/omd/omd.8
@@ -206,19 +206,24 @@ Setting and querying variables in batch mode can be done with
 .br
 \fBomd config [SITE] get VARIABLE\fP
 .TP
-.B omd diff [RELBASE] [-b, --bare]
-Shows the differences of files in the current site compared to the files delivered
-with the omd version used by the current site.
+.B omd diff [-v] [RELBASE] [-b, --bare]
+Shows the differences of files in the current site compared to the files
+delivered with the omd version used by the current site.
 
 Without the optional RELBASE argument it lists changes in ALL files of the
-site. The RELBASE argument may contain a relative path to the sites root directory
-to filter the scope of the diff.
+site. The RELBASE argument may contain a relative path to the sites root
+directory to filter the scope of the diff.
+It is also possible to give a file/link as RELBASE path. In this case only the
+information for this file are shown.
 
 The command lists files which meet at least one criteria: modified content, changed
 types, modified permissions, modified owner, deleted files.
 
 If you specify the option \fB-b\fP or \fB--bare\fP, then the output leaves out things
 to make the output more human readable, so it is better parseable by scripts.
+
+This command also handles the global option \fB-v\fP or \fB--verbose\fP. It shows the
+changes in detail.
 .SH SEE ALSO
 .BR http://www.omdistro.org
 .br



More information about the omd-commits mailing list