merge with stable
authorMatt Mackall <mpm@selenic.com>
Tue, 28 Dec 2010 13:31:30 -0600
changeset 13205 18f0084a97c8
parent 13201 f05250572467 (current diff)
parent 13204 5b83ab614dab (diff)
child 13207 1775382ff833
merge with stable
mercurial/util.py
--- a/hgext/notify.py	Mon Dec 20 16:56:54 2010 +0800
+++ b/hgext/notify.py	Tue Dec 28 13:31:30 2010 -0600
@@ -215,8 +215,8 @@
                 s = ctx.description().lstrip().split('\n', 1)[0].rstrip()
                 subject = '%s: %s' % (self.root, s)
         maxsubject = int(self.ui.config('notify', 'maxsubject', 67))
-        if maxsubject and len(subject) > maxsubject:
-            subject = subject[:maxsubject - 3] + '...'
+        if maxsubject:
+            subject = util.ellipsis(subject, maxsubject)
         msg['Subject'] = mail.headencode(self.ui, subject,
                                          self.charsets, self.test)
 
--- a/mercurial/help/templates.txt	Mon Dec 20 16:56:54 2010 +0800
+++ b/mercurial/help/templates.txt	Tue Dec 28 13:31:30 2010 -0600
@@ -25,8 +25,9 @@
 
 :author: String. The unmodified author of the changeset.
 
-:branches: String. The name of the branch on which the changeset was
-    committed. Will be empty if the branch name was default.
+:branches: List of strings. The name of the branch on which the
+    changeset was committed. Will be empty if the branch name was
+    default.
 
 :children: List of strings. The children of the changeset.
 
--- a/mercurial/util.py	Mon Dec 20 16:56:54 2010 +0800
+++ b/mercurial/util.py	Tue Dec 28 13:31:30 2010 -0600
@@ -721,21 +721,37 @@
 
 def checknlink(testfile):
     '''check whether hardlink count reporting works properly'''
-    f = testfile + ".hgtmp"
 
+    # testfile may be open, so we need a separate file for checking to
+    # work around issue2543 (or testfile may get lost on Samba shares)
+    f1 = testfile + ".hgtmp1"
+    if os.path.lexists(f1):
+        return False
     try:
-        os_link(testfile, f)
-    except OSError:
+        posixfile(f1, 'w').close()
+    except IOError:
         return False
 
+    f2 = testfile + ".hgtmp2"
+    fd = None
     try:
+        try:
+            os_link(f1, f2)
+        except OSError:
+            return False
+
         # nlinks() may behave differently for files on Windows shares if
         # the file is open.
-        fd = open(f)
-        return nlinks(f) > 1
+        fd = open(f2)
+        return nlinks(f2) > 1
     finally:
-        fd.close()
-        os.unlink(f)
+        if fd is not None:
+            fd.close()
+        for f in (f1, f2):
+            try:
+                os.unlink(f)
+            except OSError:
+                pass
 
     return False