[Pkg-bazaar-commits] ./bzr/unstable r319: - remove trivial chomp() function

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:51:50 UTC 2009


------------------------------------------------------------
revno: 319
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-05-02 14:37:13 +1000
message:
  - remove trivial chomp() function
modified:
  bzrlib/branch.py
  bzrlib/osutils.py
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2005-04-28 09:57:52 +0000
+++ b/bzrlib/branch.py	2005-05-02 04:37:13 +0000
@@ -26,7 +26,7 @@
 from trace import mutter, note
 from tree import Tree, EmptyTree, RevisionTree, WorkingTree
 from inventory import InventoryEntry, Inventory
-from osutils import isdir, quotefn, isfile, uuid, sha_file, username, chomp, \
+from osutils import isdir, quotefn, isfile, uuid, sha_file, username, \
      format_date, compact_date, pumpfile, user_email, rand_bytes, splitpath, \
      joinpath, sha_string, file_kind, local_time_offset, appendpath
 from store import ImmutableStore
@@ -635,7 +635,7 @@
         >>> ScratchBranch().revision_history()
         []
         """
-        return [chomp(l) for l in self.controlfile('revision-history', 'r').readlines()]
+        return [l.rstrip('\r\n') for l in self.controlfile('revision-history', 'r').readlines()]
 
 
     def revno(self):

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2005-04-15 07:53:59 +0000
+++ b/bzrlib/osutils.py	2005-05-02 04:37:13 +0000
@@ -84,23 +84,12 @@
 
 def uuid():
     """Return a new UUID"""
-    
-    ## XXX: Could alternatively read /proc/sys/kernel/random/uuid on
-    ## Linux, but we need something portable for other systems;
-    ## preferably an implementation in Python.
     try:
-        return chomp(file('/proc/sys/kernel/random/uuid').readline())
+        return file('/proc/sys/kernel/random/uuid').readline().rstrip('\n')
     except IOError:
         return chomp(os.popen('uuidgen').readline())
 
 
-def chomp(s):
-    if s and (s[-1] == '\n'):
-        return s[:-1]
-    else:
-        return s
-
-
 def sha_file(f):
     import sha
     ## TODO: Maybe read in chunks to handle big files



More information about the Pkg-bazaar-commits mailing list