[PATCH 2 of 2] factotum: convert Plan 9 quoted string to Python string

Jeff Sickel jas at buf.io
Tue Nov 25 07:59:11 UTC 2014


# HG changeset patch
# User David Eckhardt <David.Eckhardt at cs.cmu.edu>
# Date 1416904312 21600
#      Tue Nov 25 02:31:52 2014 -0600
# Branch stable
# Node ID 98812a2981f6277962762f7c6b65b918bc32aaaa
# Parent  54cd545e2ec215cf1271f063cd6dea6835e892ef
factotum: convert Plan 9 quoted string to Python string

diff -r 54cd545e2ec2 -r 98812a2981f6 hgext/factotum.py
--- a/hgext/factotum.py	Tue Nov 25 02:27:31 2014 -0600
+++ b/hgext/factotum.py	Tue Nov 25 02:31:52 2014 -0600
@@ -72,9 +72,14 @@
                 l = os.read(fd, ERRMAX).split()
                 if l[0] == 'ok':
                     os.write(fd, 'read')
-                    l = os.read(fd, ERRMAX).split()
-                    if l[0] == 'ok':
-                        return l[1:]
+                    status, user, passwd = os.read(fd, ERRMAX).split(None, 2)
+                    if status == 'ok':
+                        if passwd.startswith("'"):
+                            if passwd.endswith("'"):
+                                passwd = passwd[1:-1].replace("''", "'")
+                            else:
+                                raise util.Abort(_('malformed password string'))
+                        return (user, passwd)
             except (OSError, IOError):
                 raise util.Abort(_('factotum not responding'))
         finally:


More information about the Mercurial-devel mailing list