Commits

Sebastian Sdorra committed aec9cbc

implement transport format

Comments (0)

Files changed (1)

     
   return subrepos
   
-def printSubRepository(ui, path, subrepository):
-  ui.write('%s %s %s\n' % (appendTrailingSlash(path), subrepository.revision, subrepository.url))
+def printSubRepository(ui, path, subrepository, transport):
+  format = '%s %s %s\n'
+  if transport:
+    format = 'd%s\n%s %s\0'
+  ui.write( format % (appendTrailingSlash(path), subrepository.revision, subrepository.url))
   
-def printDirectory(ui, path):
-  ui.write('%s\n' % path)
+def printDirectory(ui, path, transport):
+  format = '%s\n'
+  if transport:
+    format = 'd%s\0'
+  ui.write( format % path)
   
-def printFile(ui, repo, file):
+def printFile(ui, repo, file, transport):
   linkrev = repo[file.linkrev()]
   date = "%d %d" % util.parsedate(linkrev.date())
-  ui.write('%s %i %s %s\n' % (file.path(), file.size(), date, linkrev.description()))
+  format = '%s %i %s %s\n'
+  if transport:
+    format = 'f%s\n%i %s %s\0'
+  ui.write( format % (file.path(), file.size(), date, linkrev.description()))
 
 def fileview(ui, repo, **opts):
   files = []
     revision = 'tip'
   revCtx = repo[revision]
   path = opts['path']
+  transport = opts['transport']
   collectFiles(revCtx, path, files, directories)
   subRepositories = createSubRepositoryMap(revCtx)
   for k, v in subRepositories.iteritems():
     if k.startswith(path):
-      printSubRepository(ui, k, v)
+      printSubRepository(ui, k, v, transport)
   for d in directories:
-    printDirectory(ui, d)
+    printDirectory(ui, d, transport)
   for f in files:
-    printFile(ui, repo, f)
+    printFile(ui, repo, f, transport)
   
 cmdtable = {
   # cmd name        function call
     ('r', 'revision', 'tip', 'revision to print'),
     ('p', 'path', '', 'path to print'),
     ('t', 'transport', False, 'format the output for command server'),
-  ], '[options] PATH')
+  ])
 }