changeset 31:642058291e74

diffdir tidy in preparation for arg handling
author mpm@selenic.com
date Thu, 05 May 2005 15:22:11 -0800
parents 12f598340423
children 6a4d8718bee0
files hg
diffstat 1 files changed, 23 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hg	Thu May 05 15:20:56 2005 -0800
+++ b/hg	Thu May 05 15:22:11 2005 -0800
@@ -38,6 +38,24 @@
  diff [files...]       diff working directory (or selected files)
 """
 
+def diffdir(node, files = None):
+    (c, a, d) = repo.diffdir(repo.root, node)
+
+    if args:
+        nc = [ x for x in c if x in args ]
+        na = [ x for x in a if x in args ]
+        nd = [ x for x in d if x in args ]
+        for arg in args:
+            if not os.path.isdir(arg): continue
+            if arg[-1] != os.sep: arg += os.sep
+            nc += [ x for x in c if x.startswith(arg) ]
+            na += [ x for x in a if x.startswith(arg) ]
+            nd += [ x for x in d if x.startswith(arg) ]
+        (c, a, d) = (nc, na, nd)
+
+    return (c, a, d)
+    
+
 options = {}
 opts = [('v', 'verbose', None, 'verbose'),
         ('d', 'debug', None, 'debug')]
@@ -88,9 +106,9 @@
 elif cmd == "commit" or cmd == "checkin" or cmd == "ci":
     if 1:
         if len(args) > 0:
-            repo.commit(args)
+            repo.commit(repo.current, args)
         else:
-            repo.commit()
+            repo.commit(repo.current)
 
 elif cmd == "import" or cmd == "patch":
     ioptions = {}
@@ -112,31 +130,19 @@
         repo.commit(files)
 
 elif cmd == "status":
-    (c, a, d) = repo.diffdir(repo.root, repo.current)
+    (c, a, d) = diffdir(repo.current)
     for f in c: print "C", f
     for f in a: print "?", f
     for f in d: print "R", f
 
 elif cmd == "diff":
+    (c, a, d) = diffdir(repo.current, args)
+
     mmap = {}
     if repo.current:
         change = repo.changelog.read(repo.current)
         mmap = repo.manifest.read(change[0])
 
-    (c, a, d) = repo.diffdir(repo.root, repo.current)
-
-    if args:
-        nc = [ x for x in c if x in args ]
-        na = [ x for x in a if x in args ]
-        nd = [ x for x in d if x in args ]
-        for arg in args:
-            if not os.path.isdir(arg): continue
-            if arg[-1] != os.sep: arg += os.sep
-            nc += [ x for x in c if x.startswith(arg) ]
-            na += [ x for x in a if x.startswith(arg) ]
-            nd += [ x for x in d if x.startswith(arg) ]
-        (c, a, d) = (nc, na, nd)
-
     for f in c:
         to = repo.file(f).read(mmap[f])
         tn = file(f).read()