changeset 4096:49237d6ae97d

merge with crew-stable
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 16 Feb 2007 05:27:37 -0200
parents 719488a98ebe (current diff) 6fa7a2d0fc2e (diff)
children 403c4ddd74bb
files hgext/extdiff.py hgext/mq.py hgext/notify.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/server.py mercurial/mail.py mercurial/patch.py mercurial/util.py tests/test-git-export tests/test-mq tests/test-mq.out
diffstat 16 files changed, 180 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/extdiff.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/hgext/extdiff.py	Fri Feb 16 05:27:37 2007 -0200
@@ -57,7 +57,10 @@
     def snapshot_node(files, node):
         '''snapshot files as of some revision'''
         mf = repo.changectx(node).manifest()
-        dirname = '%s.%s' % (os.path.basename(repo.root), short(node))
+        dirname = os.path.basename(repo.root)
+        if dirname == "":
+            dirname = "root"
+        dirname = '%s.%s' % (dirname, short(node))
         base = os.path.join(tmproot, dirname)
         os.mkdir(base)
         if not ui.quiet:
@@ -74,7 +77,7 @@
             if not os.path.isdir(destdir):
                 os.makedirs(destdir)
             data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
-            open(dest, 'w').write(data)
+            open(dest, 'wb').write(data)
         return dirname
 
     def snapshot_wdir(files):
@@ -82,6 +85,8 @@
         if not using snapshot, -I/-X does not work and recursive diff
         in tools like kdiff3 and meld displays too many files.'''
         dirname = os.path.basename(repo.root)
+        if dirname == "":
+            dirname = "root"
         base = os.path.join(tmproot, dirname)
         os.mkdir(base)
         if not ui.quiet:
@@ -94,7 +99,7 @@
             destdir = os.path.dirname(dest)
             if not os.path.isdir(destdir):
                 os.makedirs(destdir)
-            fp = open(dest, 'w')
+            fp = open(dest, 'wb')
             for chunk in util.filechunkiter(repo.wopener(wfn)):
                 fp.write(chunk)
         return dirname
--- a/hgext/mq.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/hgext/mq.py	Fri Feb 16 05:27:37 2007 -0200
@@ -1501,7 +1501,6 @@
     sr = hg.repository(ui, ui.expandpath(source))
     qbase, destrev = None, None
     if sr.local():
-        reposetup(ui, sr)
         if sr.mq.applied:
             qbase = revlog.bin(sr.mq.applied[0].rev)
             if not hg.islocal(dest):
@@ -1521,7 +1520,6 @@
     if dr.local():
         if qbase:
             ui.note(_('stripping applied patches from destination repo\n'))
-            reposetup(ui, dr)
             dr.mq.strip(dr, qbase, update=False, backup=None)
         if not opts['noupdate']:
             ui.note(_('updating destination repo\n'))
--- a/hgext/notify.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/hgext/notify.py	Fri Feb 16 05:27:37 2007 -0200
@@ -136,11 +136,12 @@
         '''try to clean up email addresses.'''
 
         addr = templater.email(addr.strip())
-        a = addr.find('@localhost')
-        if a != -1:
-            addr = addr[:a]
-        if '@' not in addr:
-            return addr + '@' + self.domain
+        if self.domain:
+            a = addr.find('@localhost')
+            if a != -1:
+                addr = addr[:a]
+            if '@' not in addr:
+                return addr + '@' + self.domain
         return addr
 
     def subscribers(self):
--- a/mercurial/hgweb/hgweb_mod.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/mercurial/hgweb/hgweb_mod.py	Fri Feb 16 05:27:37 2007 -0200
@@ -1134,8 +1134,12 @@
                 try:
                     url = 'remote:%s:%s' % (proto,
                                             req.env.get('REMOTE_HOST', ''))
-                    ret = self.repo.addchangegroup(util.chunkbuffer(gen),
-                                                   'serve', url)
+                    try:
+                        ret = self.repo.addchangegroup(util.chunkbuffer(gen),
+                                                       'serve', url)
+                    except util.Abort, inst:
+                        sys.stdout.write("abort: %s\n" % inst)
+                        ret = 0
                 finally:
                     val = sys.stdout.getvalue()
                     sys.stdout = old_stdout
--- a/mercurial/hgweb/server.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/mercurial/hgweb/server.py	Fri Feb 16 05:27:37 2007 -0200
@@ -222,8 +222,8 @@
             if self.webdir_conf:
                 hgwebobj = self.webdirmaker(self.webdir_conf, ui)
             elif self.repo is not None:
-                hgwebobj = self.repoviewmaker(repo.__class__(repo.ui,
-                                                             repo.origroot))
+                hgwebobj = self.repoviewmaker(hg.repository(repo.ui,
+                                                            repo.root))
             else:
                 raise hg.RepoError(_("There is no Mercurial repository here"
                                      " (.hg not found)"))
--- a/mercurial/mail.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/mercurial/mail.py	Fri Feb 16 05:27:37 2007 -0200
@@ -6,7 +6,7 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 from i18n import _
-import os, smtplib, templater, util
+import os, smtplib, templater, util, socket
 
 def _smtp(ui):
     '''send mail using smtp.'''
@@ -21,6 +21,9 @@
             (mailhost, mailport))
     s.connect(host=mailhost, port=mailport)
     if ui.configbool('smtp', 'tls'):
+        if not hasattr(socket, 'ssl'):
+            raise util.Abort(_("can't use TLS: Python SSL support "
+                               "not installed"))
         ui.note(_('(using tls)\n'))
         s.ehlo()
         s.starttls()
--- a/mercurial/patch.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/mercurial/patch.py	Fri Feb 16 05:27:37 2007 -0200
@@ -412,6 +412,8 @@
             yield text[i:i+csize]
             i += csize
 
+    if to == tn:
+        return
     # TODO: deltas
     l = len(tn)
     fp.write('index %s..%s\nGIT binary patch\nliteral %s\n' %
@@ -560,8 +562,8 @@
                     to = getfilectx(a, ctx1).data()
                 else:
                     header.append('new file mode %s\n' % mode)
-                    if util.binary(tn):
-                        dodiff = 'binary'
+                if util.binary(tn):
+                    dodiff = 'binary'
             elif f in removed:
                 if f in srcs:
                     dodiff = False
--- a/mercurial/util.py	Thu Feb 15 10:15:08 2007 -0200
+++ b/mercurial/util.py	Fri Feb 16 05:27:37 2007 -0200
@@ -374,6 +374,9 @@
             except OSError:
                 break
             if samestat(name_st, root_st):
+                if not rel:
+                    # name was actually the same as root (maybe a symlink)
+                    return ''
                 rel.reverse()
                 name = os.path.join(*rel)
                 audit_path(name)
@@ -846,8 +849,23 @@
     def samestat(s1, s2):
         return False
 
+    # A sequence of backslashes is special iff it precedes a double quote:
+    # - if there's an even number of backslashes, the double quote is not
+    #   quoted (i.e. it ends the quoted region)
+    # - if there's an odd number of backslashes, the double quote is quoted
+    # - in both cases, every pair of backslashes is unquoted into a single
+    #   backslash
+    # (See http://msdn2.microsoft.com/en-us/library/a1y7w461.aspx )
+    # So, to quote a string, we must surround it in double quotes, double
+    # the number of backslashes that preceed double quotes and add another
+    # backslash before every double quote (being careful with the double
+    # quote we've appended to the end)
+    _quotere = None
     def shellquote(s):
-        return '"%s"' % s.replace('"', '\\"')
+        global _quotere
+        if _quotere is None:
+            _quotere = re.compile(r'(\\*)("|\\$)')
+        return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
 
     def explain_exit(code):
         return _("exited with status %d") % code, code
--- a/tests/test-git-export	Thu Feb 15 10:15:08 2007 -0200
+++ b/tests/test-git-export	Fri Feb 16 05:27:37 2007 -0200
@@ -61,6 +61,11 @@
 cmp binfile.bin $TESTDIR/binfile.bin
 
 echo
+echo '% rename binary file'
+hg mv binfile.bin renamed.bin
+hg diff --git
+
+echo
 echo '% diff across many revisions'
 hg mv dst dst2
 hg ci -m 'mv dst dst2' -d '0 0'
--- a/tests/test-git-export.out	Thu Feb 15 10:15:08 2007 -0200
+++ b/tests/test-git-export.out	Fri Feb 16 05:27:37 2007 -0200
@@ -66,6 +66,11 @@
 % import binary diff
 applying b.diff
 
+% rename binary file
+diff --git a/binfile.bin b/renamed.bin
+rename from binfile.bin
+rename to renamed.bin
+
 % diff across many revisions
 diff --git a/dst2 b/dst3
 rename from dst2
--- a/tests/test-mq	Thu Feb 15 10:15:08 2007 -0200
+++ b/tests/test-mq	Fri Feb 16 05:27:37 2007 -0200
@@ -298,4 +298,42 @@
 hg log
 hg strip 1 2>&1 | sed 's/\(saving bundle to \).*/\1/'
 hg log
+cd ..
 
+echo '% qclone'
+qlog()
+{
+    echo 'main repo:'
+    hg log --template '    rev {rev}: {desc}\n'
+    echo 'patch repo:'
+    hg -R .hg/patches log --template '    rev {rev}: {desc}\n'
+}
+hg init qclonesource
+cd qclonesource
+echo foo > foo
+hg add foo
+hg ci -m 'add foo'
+hg qinit -c
+hg qnew patch1
+echo bar >> foo
+hg qrefresh -m 'change foo'
+hg qci -m checkpoint
+qlog
+cd ..
+
+# repo with patches applied
+hg qclone qclonesource qclonedest
+cd qclonedest
+qlog
+cd ..
+
+# repo with patches unapplied
+cd qclonesource
+hg qpop -a
+qlog
+cd ..
+hg qclone qclonesource qclonedest2
+cd qclonedest2
+qlog
+cd ..
+
--- a/tests/test-mq.out	Thu Feb 15 10:15:08 2007 -0200
+++ b/tests/test-mq.out	Fri Feb 16 05:27:37 2007 -0200
@@ -333,3 +333,26 @@
 date:        Thu Jan 01 00:00:00 1970 +0000
 summary:     add foo
 
+% qclone
+main repo:
+    rev 1: change foo
+    rev 0: add foo
+patch repo:
+    rev 0: checkpoint
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+main repo:
+    rev 0: add foo
+patch repo:
+    rev 0: checkpoint
+Patch queue now empty
+main repo:
+    rev 0: add foo
+patch repo:
+    rev 0: checkpoint
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+main repo:
+    rev 0: add foo
+patch repo:
+    rev 0: checkpoint
--- a/tests/test-notify	Thu Feb 15 10:15:08 2007 -0200
+++ b/tests/test-notify	Fri Feb 16 05:27:37 2007 -0200
@@ -8,18 +8,14 @@
 incoming.notify = python:hgext.notify.hook
 
 [notify]
-config = $HGTMP/.notify.conf
 sources = pull
-domain = test.com
-strip = 3
-template = Subject: {desc|firstline|strip}\nFrom: {author}\n\nchangeset {node|short} in {webroot}\ndescription:\n\t{desc|tabindent|strip}
 diffstat = False
 
-[web]
-baseurl = http://test/
-
 [usersubs]
 foo@bar = *
+
+[reposubs]
+* = baz
 EOF
 
 hg help notify
@@ -35,6 +31,24 @@
 echo % commit
 hg --traceback --cwd a commit -Amb -d '1 0'
 
+echo '% pull (minimal config)'
+hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \
+  -e 's/changeset \([0-9a-f]* \)\?in .*test-notif/changeset \1in test-notif/' \
+  -e 's/^details: .*test-notify/details: test-notify/'
+
+cat <<EOF >> $HGRCPATH
+[notify]
+config = $HGTMP/.notify.conf
+domain = test.com
+strip = 3
+template = Subject: {desc|firstline|strip}\nFrom: {author}\n\nchangeset {node|short} in {webroot}\ndescription:\n\t{desc|tabindent|strip}
+
+[web]
+baseurl = http://test/
+EOF
+
 echo % pull
+hg --cwd b rollback
 hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \
   -e 's/changeset \([0-9a-f]*\) in .*/changeset \1/'
+
--- a/tests/test-notify.out	Thu Feb 15 10:15:08 2007 -0200
+++ b/tests/test-notify.out	Fri Feb 16 05:27:37 2007 -0200
@@ -6,7 +6,35 @@
 % clone
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % commit
+% pull (minimal config)
+pulling from ../a
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+Subject: changeset in test-notify/b: b
+From: test
+X-Hg-Notification: changeset 0647d048b600
+Message-Id:
+To: baz, foo@bar
+
+changeset 0647d048b600 in test-notify/b
+details: test-notify/b?cmd=changeset;node=0647d048b600
+description:
+	b
+
+diffs (6 lines):
+
+diff -r cb9a9f314b8b -r 0647d048b600 a
+--- a/a	Thu Jan 01 00:00:00 1970 +0000
++++ b/a	Thu Jan 01 00:00:01 1970 +0000
+@@ -1,1 +1,2 @@ a
+ a
++a
+(run 'hg update' to get a working copy)
 % pull
+rolling back last transaction
 pulling from ../a
 searching for changes
 adding changesets
@@ -17,7 +45,7 @@
 From: test@test.com
 X-Hg-Notification: changeset 0647d048b600
 Message-Id:
-To: foo@bar
+To: baz@test.com, foo@bar
 
 changeset 0647d048b600
 description:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-symlink-root	Fri Feb 16 05:27:37 2007 -0200
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+hg init a
+ln -s a link
+cd a
+echo foo > foo
+hg status
+hg status ../link
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-symlink-root.out	Fri Feb 16 05:27:37 2007 -0200
@@ -0,0 +1,2 @@
+? foo
+? foo