mercurial/util.py
changeset 8938 9b8c9266c59d
parent 8785 7a9151bc5b37
child 9029 0001e49f1c11
child 9084 9f191931c859
--- a/mercurial/util.py	Wed Jun 24 18:40:13 2009 +0200
+++ b/mercurial/util.py	Wed Jun 24 19:15:58 2009 +0200
@@ -16,7 +16,7 @@
 from i18n import _
 import error, osutil
 import cStringIO, errno, re, shutil, sys, tempfile, traceback
-import os, stat, time, calendar, random
+import os, stat, time, calendar, random, textwrap
 import imp
 
 # Python compatibility
@@ -1242,6 +1242,10 @@
         pass
     return 80
 
+def wrap(line, hangindent, width=78):
+    padding = '\n' + ' ' * hangindent
+    return padding.join(textwrap.wrap(line, width=width - hangindent))
+
 def iterlines(iterator):
     for chunk in iterator:
         for line in chunk.splitlines():