Merge with crew.
--- a/contrib/churn.py Tue Oct 30 16:56:01 2007 -0700
+++ b/contrib/churn.py Thu Nov 01 15:22:22 2007 -0700
@@ -43,7 +43,7 @@
to = mmap1 and repo.file(f).read(mmap1[f]) or None
tn = mmap2 and repo.file(f).read(mmap2[f]) or None
- diff = mdiff.unidiff(to, "", tn, "", f).split("\n")
+ diff = mdiff.unidiff(to, "", tn, "", f, f).split("\n")
for line in diff:
if not line:
--- a/hgext/convert/common.py Tue Oct 30 16:56:01 2007 -0700
+++ b/hgext/convert/common.py Thu Nov 01 15:22:22 2007 -0700
@@ -1,6 +1,7 @@
# common code for the convert extension
import base64
import cPickle as pickle
+from mercurial import util
def encodeargs(args):
def encodearg(s):
@@ -15,6 +16,11 @@
s = base64.decodestring(s)
return pickle.loads(s)
+def checktool(exe, name=None):
+ name = name or exe
+ if not util.find_exe(exe):
+ raise util.Abort('cannot find required "%s" tool' % name)
+
class NoRepo(Exception): pass
SKIPREV = 'SKIP'
--- a/hgext/convert/cvs.py Tue Oct 30 16:56:01 2007 -0700
+++ b/hgext/convert/cvs.py Thu Nov 01 15:22:22 2007 -0700
@@ -3,7 +3,7 @@
import os, locale, re, socket
from mercurial import util
-from common import NoRepo, commit, converter_source
+from common import NoRepo, commit, converter_source, checktool
class convert_cvs(converter_source):
def __init__(self, ui, path, rev=None):
@@ -13,6 +13,9 @@
if not os.path.exists(cvs):
raise NoRepo("couldn't open CVS repo %s" % path)
+ for tool in ('cvsps', 'cvs'):
+ checktool(tool)
+
self.changeset = {}
self.files = {}
self.tags = {}
@@ -43,14 +46,13 @@
cmd = '%s -d "1970/01/01 00:00:01" -d "%s"' % (cmd, self.rev)
except util.Abort:
raise util.Abort('revision %s is not a patchset number or date' % self.rev)
- cmd += " 2>&1"
d = os.getcwd()
try:
os.chdir(self.path)
id = None
state = 0
- for l in os.popen(cmd):
+ for l in util.popen(cmd):
if state == 0: # header
if l.startswith("PatchSet"):
id = l[9:-2]
--- a/hgext/convert/darcs.py Tue Oct 30 16:56:01 2007 -0700
+++ b/hgext/convert/darcs.py Thu Nov 01 15:22:22 2007 -0700
@@ -1,6 +1,6 @@
# darcs support for the convert extension
-from common import NoRepo, commit, converter_source
+from common import NoRepo, commit, converter_source, checktool
from mercurial.i18n import _
from mercurial import util
import os, shutil, tempfile
@@ -24,6 +24,8 @@
if not os.path.exists(os.path.join(path, '_darcs', 'inventory')):
raise NoRepo("couldn't open darcs repo %s" % path)
+ checktool('darcs')
+
if ElementTree is None:
raise util.Abort(_("Python ElementTree module is not available"))
@@ -65,9 +67,9 @@
cmdline += args
cmdline = [util.shellquote(arg) for arg in cmdline]
cmdline += ['<', util.nulldev]
- cmdline = util.quotecommand(' '.join(cmdline))
+ cmdline = ' '.join(cmdline)
self.ui.debug(cmdline, '\n')
- return os.popen(cmdline, 'r')
+ return util.popen(cmdline)
def run(self, cmd, *args, **kwargs):
fp = self._run(cmd, *args, **kwargs)
--- a/hgext/convert/git.py Tue Oct 30 16:56:01 2007 -0700
+++ b/hgext/convert/git.py Thu Nov 01 15:22:22 2007 -0700
@@ -3,7 +3,7 @@
import os
from mercurial import util
-from common import NoRepo, commit, converter_source
+from common import NoRepo, commit, converter_source, checktool
class convert_git(converter_source):
# Windows does not support GIT_DIR= construct while other systems
@@ -14,7 +14,7 @@
prevgitdir = os.environ.get('GIT_DIR')
os.environ['GIT_DIR'] = self.path
try:
- return os.popen(s)
+ return util.popen(s)
finally:
if prevgitdir is None:
del os.environ['GIT_DIR']
@@ -22,7 +22,7 @@
os.environ['GIT_DIR'] = prevgitdir
else:
def gitcmd(self, s):
- return os.popen('GIT_DIR=%s %s' % (self.path, s))
+ return util.popen('GIT_DIR=%s %s' % (self.path, s))
def __init__(self, ui, path, rev=None):
super(convert_git, self).__init__(ui, path, rev=rev)
@@ -31,6 +31,9 @@
path += "/.git"
if not os.path.exists(path + "/objects"):
raise NoRepo("couldn't open GIT repo %s" % path)
+
+ checktool('git-rev-parse', 'git')
+
self.path = path
def getheads(self):
@@ -42,8 +45,7 @@
def catfile(self, rev, type):
if rev == "0" * 40: raise IOError()
- fh = self.gitcmd("git-cat-file %s %s 2>%s" % (type, rev,
- util.nulldev))
+ fh = self.gitcmd("git-cat-file %s %s" % (type, rev))
return fh.read()
def getfile(self, name, rev):
@@ -108,8 +110,7 @@
def gettags(self):
tags = {}
- fh = self.gitcmd('git-ls-remote --tags "%s" 2>%s' % (self.path,
- util.nulldev))
+ fh = self.gitcmd('git-ls-remote --tags "%s"' % self.path)
prefix = 'refs/tags/'
for line in fh:
line = line.strip()
--- a/mercurial/commands.py Tue Oct 30 16:56:01 2007 -0700
+++ b/mercurial/commands.py Thu Nov 01 15:22:22 2007 -0700
@@ -873,7 +873,8 @@
a = "1\n2\n3\n4\n"
b = "1\n2\n3\ninsert\n4\n"
fa = writetemp(a)
- d = mdiff.unidiff(a, None, b, None, os.path.basename(fa))
+ d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
+ os.path.basename(fa))
fd = writetemp(d)
files = {}
--- a/mercurial/mdiff.py Tue Oct 30 16:56:01 2007 -0700
+++ b/mercurial/mdiff.py Thu Nov 01 15:22:22 2007 -0700
@@ -59,11 +59,11 @@
text = re.sub('\n+', '', text)
return text
-def unidiff(a, ad, b, bd, fn, r=None, opts=defaultopts):
+def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts):
def datetag(date, addtab=True):
if not opts.git and not opts.nodates:
return '\t%s\n' % date
- if addtab and ' ' in fn:
+ if addtab and ' ' in fn1:
return '\t\n'
return '\n'
@@ -76,29 +76,29 @@
return md5.new(v).digest()
if a and b and len(a) == len(b) and h(a) == h(b):
return ""
- l = ['Binary file %s has changed\n' % fn]
+ l = ['Binary file %s has changed\n' % fn1]
elif not a:
b = splitnewlines(b)
if a is None:
l1 = '--- /dev/null%s' % datetag(epoch, False)
else:
- l1 = "--- %s%s" % ("a/" + fn, datetag(ad))
- l2 = "+++ %s%s" % ("b/" + fn, datetag(bd))
+ l1 = "--- %s%s" % ("a/" + fn1, datetag(ad))
+ l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd))
l3 = "@@ -0,0 +1,%d @@\n" % len(b)
l = [l1, l2, l3] + ["+" + e for e in b]
elif not b:
a = splitnewlines(a)
- l1 = "--- %s%s" % ("a/" + fn, datetag(ad))
+ l1 = "--- %s%s" % ("a/" + fn1, datetag(ad))
if b is None:
l2 = '+++ /dev/null%s' % datetag(epoch, False)
else:
- l2 = "+++ %s%s" % ("b/" + fn, datetag(bd))
+ l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd))
l3 = "@@ -1,%d +0,0 @@\n" % len(a)
l = [l1, l2, l3] + ["-" + e for e in a]
else:
al = splitnewlines(a)
bl = splitnewlines(b)
- l = list(bunidiff(a, b, al, bl, "a/" + fn, "b/" + fn, opts=opts))
+ l = list(bunidiff(a, b, al, bl, "a/" + fn1, "b/" + fn2, opts=opts))
if not l: return ""
# difflib uses a space, rather than a tab
l[0] = "%s%s" % (l[0][:-2], datetag(ad))
@@ -110,7 +110,7 @@
if r:
l.insert(0, "diff %s %s\n" %
- (' '.join(["-r %s" % rev for rev in r]), fn))
+ (' '.join(["-r %s" % rev for rev in r]), fn1))
return "".join(l)
--- a/mercurial/patch.py Tue Oct 30 16:56:01 2007 -0700
+++ b/mercurial/patch.py Thu Nov 01 15:22:22 2007 -0700
@@ -249,7 +249,7 @@
fuzz = False
if cwd:
args.append('-d %s' % util.shellquote(cwd))
- fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
+ fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
util.shellquote(patchname)))
for line in fp:
@@ -1230,6 +1230,7 @@
to = getfilectx(f, ctx1).data()
if f not in removed:
tn = getfilectx(f, ctx2).data()
+ a, b = f, f
if opts.git:
def gitmode(x, l):
return l and '120000' or (x and '100755' or '100644')
@@ -1238,7 +1239,6 @@
header.append('old mode %s\n' % omode)
header.append('new mode %s\n' % nmode)
- a, b = f, f
if f in added:
mode = gitmode(execf2(f), linkf2(f))
if f in copied:
@@ -1278,7 +1278,7 @@
text = mdiff.unidiff(to, date1,
# ctx2 date may be dynamic
tn, util.datestr(ctx2.date()),
- f, r, opts=opts)
+ a, b, r, opts=opts)
if text or len(header) > 1:
fp.write(''.join(header))
fp.write(text)
--- a/mercurial/util.py Tue Oct 30 16:56:01 2007 -0700
+++ b/mercurial/util.py Thu Nov 01 15:22:22 2007 -0700
@@ -1011,6 +1011,13 @@
# through the current COMSPEC. cmd.exe suppress enclosing quotes.
return '"' + cmd + '"'
+ def popen(command):
+ # Work around "popen spawned process may not write to stdout
+ # under windows"
+ # http://bugs.python.org/issue1366
+ command += " 2> %s" % nulldev
+ return os.popen(quotecommand(command))
+
def explain_exit(code):
return _("exited with status %d") % code, code
@@ -1168,6 +1175,9 @@
def quotecommand(cmd):
return cmd
+ def popen(command):
+ return os.popen(command)
+
def testpid(pid):
'''return False if pid dead, True if running or not sure'''
if os.sys.platform == 'OpenVMS':
--- a/mercurial/version.py Tue Oct 30 16:56:01 2007 -0700
+++ b/mercurial/version.py Thu Nov 01 15:22:22 2007 -0700
@@ -50,7 +50,7 @@
"""Store version information."""
global remembered_version
if not version and os.path.isdir(".hg"):
- f = os.popen("hg identify 2> %s" % util.nulldev) # use real hg installation
+ f = util.popen("hg identify") # use real hg installation
ident = f.read()[:-1]
if not f.close() and ident:
ids = ident.split(' ', 1)
--- a/tests/test-git-export.out Tue Oct 30 16:56:01 2007 -0700
+++ b/tests/test-git-export.out Thu Nov 01 15:22:22 2007 -0700
@@ -33,7 +33,7 @@
new mode 100644
rename from src
rename to dst
---- a/dst
+--- a/src
+++ b/dst
@@ -3,3 +3,4 @@ 3
3
@@ -84,7 +84,7 @@
diff --git a/foo b/bar
rename from foo
rename to bar
---- a/bar
+--- a/foo
+++ b/bar
@@ -1,2 +1,3 @@ a
a
@@ -94,7 +94,7 @@
diff --git a/bar b/foo
rename from bar
rename to foo
---- a/foo
+--- a/bar
+++ b/foo
@@ -1,3 +1,2 @@ a
a
@@ -105,7 +105,7 @@
diff --git a/foo b/bar
rename from foo
rename to bar
---- a/bar
+--- a/foo
+++ b/bar
@@ -1,1 +1,3 @@ a
a
@@ -115,7 +115,7 @@
diff --git a/bar b/foo
rename from bar
rename to foo
---- a/foo
+--- a/bar
+++ b/foo
@@ -1,3 +1,1 @@ a
a