merge with crew-stable

This commit is contained in:
Alexis S. L. Carvalho 2007-02-16 05:27:37 -02:00
commit d4de823a64
16 changed files with 180 additions and 26 deletions

View File

@ -57,7 +57,10 @@ def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
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 @@ def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
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 @@ def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
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 @@ def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
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

View File

@ -1501,7 +1501,6 @@ def clone(ui, source, dest=None, **opts):
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 @@ def clone(ui, source, dest=None, **opts):
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'))

View File

@ -136,11 +136,12 @@ class notifier(object):
'''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):

View File

@ -1134,8 +1134,12 @@ class hgweb(object):
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

View File

@ -222,8 +222,8 @@ def create_server(ui, repo):
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)"))

View File

@ -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 @@ def _smtp(ui):
(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()

View File

@ -412,6 +412,8 @@ def b85diff(fp, to, tn):
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 @@ def diff(repo, node1=None, node2=None, files=None, match=util.always,
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

View File

@ -374,6 +374,9 @@ def canonpath(root, cwd, myname):
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 @@ if os.name == 'nt':
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

View File

@ -60,6 +60,11 @@ rm binfile.bin
hg import -mfoo b.diff
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

View File

@ -66,6 +66,11 @@ fQItJW-{SoTm)8|5##k|m00000NkvXXu0mjf{mKw4
% 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

View File

@ -298,4 +298,42 @@ hg ci -m merge -d '0 0'
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 ..

View File

@ -333,3 +333,26 @@ user: test
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

View File

@ -8,18 +8,14 @@ notify=
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 a >> a/a
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/'

View File

@ -6,7 +6,35 @@ adding a
% 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 @@ Subject: b
From: test@test.com
X-Hg-Notification: changeset 0647d048b600
Message-Id:
To: foo@bar
To: baz@test.com, foo@bar
changeset 0647d048b600
description:

8
tests/test-symlink-root Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
hg init a
ln -s a link
cd a
echo foo > foo
hg status
hg status ../link

View File

@ -0,0 +1,2 @@
? foo
? foo