--- a/contrib/check-code.py Sun May 08 21:32:33 2011 +0200
+++ b/contrib/check-code.py Sun May 08 16:41:41 2011 -0500
@@ -139,6 +139,7 @@
(r'[\x80-\xff]', "non-ASCII character literal"),
(r'("\')\.format\(', "str.format() not available in Python 2.4"),
(r'^\s*with\s+', "with not available in Python 2.4"),
+ (r'\.isdisjoint\(', "set.isdisjoint not available in Python 2.4"),
(r'^\s*except.* as .*:', "except as not available in Python 2.4"),
(r'^\s*os\.path\.relpath', "relpath not available in Python 2.4"),
(r'(?<!def)\s+(any|all|format)\(',
--- a/hgext/convert/common.py Sun May 08 21:32:33 2011 +0200
+++ b/hgext/convert/common.py Sun May 08 16:41:41 2011 -0500
@@ -29,7 +29,7 @@
def checktool(exe, name=None, abort=True):
name = name or exe
- if not util.find_exe(exe):
+ if not util.findexe(exe):
exc = abort and util.Abort or MissingTool
raise exc(_('cannot find required "%s" tool') % name)
--- a/hgext/convert/gnuarch.py Sun May 08 21:32:33 2011 +0200
+++ b/hgext/convert/gnuarch.py Sun May 08 16:41:41 2011 -0500
@@ -36,10 +36,10 @@
# Could use checktool, but we want to check for baz or tla.
self.execmd = None
- if util.find_exe('baz'):
+ if util.findexe('baz'):
self.execmd = 'baz'
else:
- if util.find_exe('tla'):
+ if util.findexe('tla'):
self.execmd = 'tla'
else:
raise util.Abort(_('cannot find a GNU Arch tool'))
--- a/hgext/convert/subversion.py Sun May 08 21:32:33 2011 +0200
+++ b/hgext/convert/subversion.py Sun May 08 16:41:41 2011 -0500
@@ -1004,7 +1004,7 @@
self.opener = scmutil.opener(self.wc)
self.wopener = scmutil.opener(self.wc)
self.childmap = mapfile(ui, self.join('hg-childmap'))
- self.is_exec = util.checkexec(self.wc) and util.is_exec or None
+ self.is_exec = util.checkexec(self.wc) and util.isexec or None
if created:
hook = os.path.join(created, 'hooks', 'pre-revprop-change')
--- a/hgext/mq.py Sun May 08 21:32:33 2011 +0200
+++ b/hgext/mq.py Sun May 08 16:41:41 2011 -0500
@@ -1174,7 +1174,7 @@
for patchname in s:
pf = os.path.join(self.path, patchname)
patchfiles = patchmod.changedfiles(pf, strip=1)
- if not wcfiles.isdisjoint(patchfiles):
+ if wcfiles.intersection(patchfiles):
self.localchangesfound(self.applied)
elif mergeq:
self.check_localchanges(refresh=self.applied)
@@ -1285,7 +1285,7 @@
if not force and parentfiles:
mm, aa, rr, dd = repo.status()[:4]
wcfiles = set(mm + aa + rr + dd)
- if not wcfiles.isdisjoint(parentfiles):
+ if wcfiles.intersection(parentfiles):
self.localchangesfound()
if d:
raise util.Abort(_("deletions found between repo revs"))
--- a/mercurial/bookmarks.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/bookmarks.py Sun May 08 16:41:41 2011 -0500
@@ -71,14 +71,6 @@
'''
refs = repo._bookmarks
- try:
- bms = repo.opener.read('bookmarks')
- except IOError, inst:
- if inst.errno != errno.ENOENT:
- raise
- bms = ''
- repo.opener.write('undo.bookmarks', bms)
-
if repo._bookmarkcurrent not in refs:
setcurrent(repo, None)
for mark in refs.keys():
--- a/mercurial/commands.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/commands.py Sun May 08 16:41:41 2011 -0500
@@ -1648,7 +1648,7 @@
# editor
ui.status(_("Checking commit editor...\n"))
editor = ui.geteditor()
- cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
+ cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
if not cmdpath:
if editor == 'vi':
ui.write(_(" No commit editor set and can't find vi in PATH\n"))
--- a/mercurial/dirstate.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/dirstate.py Sun May 08 16:41:41 2011 -0500
@@ -138,7 +138,7 @@
p = self._join(x)
if os.path.islink(p):
return 'l'
- if util.is_exec(p):
+ if util.isexec(p):
return 'x'
return ''
return f
@@ -153,7 +153,7 @@
def f(x):
if 'l' in fallback(x):
return 'l'
- if util.is_exec(self._join(x)):
+ if util.isexec(self._join(x)):
return 'x'
return ''
return f
--- a/mercurial/dispatch.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/dispatch.py Sun May 08 16:41:41 2011 -0500
@@ -182,10 +182,21 @@
return -1
-def aliasargs(fn):
- if hasattr(fn, 'args'):
- return fn.args
- return []
+def aliasargs(fn, givenargs):
+ args = getattr(fn, 'args', [])
+ if args and givenargs:
+ cmd = ' '.join(map(util.shellquote, args))
+
+ nums = []
+ def replacer(m):
+ num = int(m.group(1)) - 1
+ nums.append(num)
+ return givenargs[num]
+ cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
+ givenargs = [x for i, x in enumerate(givenargs)
+ if i not in nums]
+ args = shlex.split(cmd)
+ return args + givenargs
class cmdalias(object):
def __init__(self, name, definition, cmdtable):
@@ -263,7 +274,7 @@
else:
self.fn, self.opts = tableentry
- self.args = aliasargs(self.fn) + args
+ self.args = aliasargs(self.fn, args)
if cmd not in commands.norepo.split(' '):
self.norepo = False
if self.help.startswith("hg " + cmd):
@@ -330,7 +341,7 @@
aliases, entry = cmdutil.findcmd(cmd, commands.table,
ui.config("ui", "strict"))
cmd = aliases[0]
- args = aliasargs(entry[0]) + args
+ args = aliasargs(entry[0], args)
defaults = ui.config("defaults", cmd)
if defaults:
args = map(util.expandpath, shlex.split(defaults)) + args
--- a/mercurial/filemerge.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/filemerge.py Sun May 08 16:41:41 2011 -0500
@@ -31,10 +31,10 @@
continue
p = util.lookupreg(k, _toolstr(ui, tool, "regname"))
if p:
- p = util.find_exe(p + _toolstr(ui, tool, "regappend"))
+ p = util.findexe(p + _toolstr(ui, tool, "regappend"))
if p:
return p
- return util.find_exe(_toolstr(ui, tool, "executable", tool))
+ return util.findexe(_toolstr(ui, tool, "executable", tool))
def _picktool(repo, ui, path, binary, symlink):
def check(tool, pat, symlink, binary):
--- a/mercurial/localrepo.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/localrepo.py Sun May 08 16:41:41 2011 -0500
@@ -678,6 +678,17 @@
raise error.RepoError(
_("abandoned transaction found - run hg recover"))
+ journalfiles = self._writejournal(desc)
+ renames = [(x, undoname(x)) for x in journalfiles]
+
+ tr = transaction.transaction(self.ui.warn, self.sopener,
+ self.sjoin("journal"),
+ aftertrans(renames),
+ self.store.createmode)
+ self._transref = weakref.ref(tr)
+ return tr
+
+ def _writejournal(self, desc):
# save dirstate for rollback
try:
ds = self.opener.read("dirstate")
@@ -689,16 +700,15 @@
self.opener.write("journal.desc",
"%d\n%s\n" % (len(self), desc))
- renames = [(self.sjoin("journal"), self.sjoin("undo")),
- (self.join("journal.dirstate"), self.join("undo.dirstate")),
- (self.join("journal.branch"), self.join("undo.branch")),
- (self.join("journal.desc"), self.join("undo.desc"))]
- tr = transaction.transaction(self.ui.warn, self.sopener,
- self.sjoin("journal"),
- aftertrans(renames),
- self.store.createmode)
- self._transref = weakref.ref(tr)
- return tr
+ bkname = self.join('bookmarks')
+ if os.path.exists(bkname):
+ util.copyfile(bkname, self.join('journal.bookmarks'))
+ else:
+ self.opener.write('journal.bookmarks', '')
+
+ return (self.sjoin('journal'), self.join('journal.dirstate'),
+ self.join('journal.branch'), self.join('journal.desc'),
+ self.join('journal.bookmarks'))
def recover(self):
lock = self.lock()
@@ -1954,6 +1964,11 @@
util.rename(src, dest)
return a
+def undoname(fn):
+ base, name = os.path.split(fn)
+ assert name.startswith('journal')
+ return os.path.join(base, name.replace('journal', 'undo', 1))
+
def instance(ui, path, create):
return localrepository(ui, util.localpath(path), create)
--- a/mercurial/mail.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/mail.py Sun May 08 16:41:41 2011 -0500
@@ -112,7 +112,7 @@
raise util.Abort(_('smtp specified as email transport, '
'but no smtp host configured'))
else:
- if not util.find_exe(method):
+ if not util.findexe(method):
raise util.Abort(_('%r specified as email transport, '
'but not in PATH') % method)
--- a/mercurial/posix.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/posix.py Sun May 08 16:41:41 2011 -0500
@@ -44,7 +44,7 @@
args = user and ("%s@%s" % (user, host)) or host
return port and ("%s -p %s" % (args, port)) or args
-def is_exec(f):
+def isexec(f):
"""check whether a file is executable"""
return (os.lstat(f).st_mode & 0100 != 0)
@@ -221,7 +221,7 @@
"""Return True if the stat object st is from the current user."""
return st.st_uid == os.getuid()
-def find_exe(command):
+def findexe(command):
'''Find executable for command searching like which does.
If command is a basename then PATH is searched for command.
PATH isn't searched if command is an absolute or relative path.
@@ -263,10 +263,6 @@
'''return name of current user'''
return getpass.getuser()
-def expand_glob(pats):
- '''On Windows, expand the implicit globs in a list of patterns'''
- return list(pats)
-
def username(uid=None):
"""Return the name of the user with the given uid.
--- a/mercurial/scmutil.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/scmutil.py Sun May 08 16:41:41 2011 -0500
@@ -176,7 +176,7 @@
self._trustnlink = None
@util.propertycache
- def _can_symlink(self):
+ def _cansymlink(self):
return util.checklink(self.base)
def _fixfilemode(self, name):
@@ -243,7 +243,7 @@
if not os.path.exists(dirname):
util.makedirs(dirname, self.createmode)
- if self._can_symlink:
+ if self._cansymlink:
try:
os.symlink(src, linkname)
except OSError, err:
--- a/mercurial/util.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/util.py Sun May 08 16:41:41 2011 -0500
@@ -319,7 +319,7 @@
elif mainfrozen():
_sethgexecutable(sys.executable)
else:
- exe = find_exe('hg') or os.path.basename(sys.argv[0])
+ exe = findexe('hg') or os.path.basename(sys.argv[0])
_sethgexecutable(exe)
return _hgexecutable
@@ -445,10 +445,10 @@
return hardlink, num
-_windows_reserved_filenames = '''con prn aux nul
+_winreservednames = '''con prn aux nul
com1 com2 com3 com4 com5 com6 com7 com8 com9
lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split()
-_windows_reserved_chars = ':*?"<>|'
+_winreservedchars = ':*?"<>|'
def checkwinfilename(path):
'''Check that the base-relative path is a valid filename on Windows.
Returns None if the path is ok, or a UI string describing the problem.
@@ -472,14 +472,14 @@
if not n:
continue
for c in n:
- if c in _windows_reserved_chars:
+ if c in _winreservedchars:
return _("filename contains '%s', which is reserved "
"on Windows") % c
if ord(c) <= 31:
return _("filename contains %r, which is invalid "
"on Windows") % c
base = n.split('.')[0]
- if base and base.lower() in _windows_reserved_filenames:
+ if base and base.lower() in _winreservednames:
return _("filename contains '%s', which is reserved "
"on Windows") % base
t = n[-1]
--- a/mercurial/windows.py Sun May 08 21:32:33 2011 +0200
+++ b/mercurial/windows.py Sun May 08 16:41:41 2011 -0500
@@ -163,7 +163,7 @@
def isowner(st):
return True
-def find_exe(command):
+def findexe(command):
'''Find executable for command searching like cmd.exe does.
If command is a basename then PATH is searched for command.
PATH isn't searched if command is an absolute or relative path.
--- a/tests/run-tests.py Sun May 08 21:32:33 2011 +0200
+++ b/tests/run-tests.py Sun May 08 16:41:41 2011 -0500
@@ -717,7 +717,7 @@
def ignore(msg):
result('i', (test, msg))
- if (test.startswith("test-") and '~' not in test and
+ if (os.path.basename(test).startswith("test-") and '~' not in test and
('.' not in test or test.endswith('.py') or
test.endswith('.bat') or test.endswith('.t'))):
if not os.path.exists(test):
@@ -796,7 +796,7 @@
# Make a tmp subdirectory to work in
testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
- os.path.join(HGTMP, test)
+ os.path.join(HGTMP, os.path.basename(test))
os.mkdir(testtmp)
ret, out = runner(testpath, testtmp, options, [
@@ -902,7 +902,7 @@
the one we expect it to be. If not, print a warning to stderr."""
expecthg = os.path.join(PYTHONDIR, 'mercurial')
actualhg = _gethgpath()
- if actualhg != expecthg:
+ if os.path.abspath(actualhg) != os.path.abspath(expecthg):
sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
' (expected %s)\n'
% (verb, actualhg, expecthg))
--- a/tests/test-alias.t Sun May 08 21:32:33 2011 +0200
+++ b/tests/test-alias.t Sun May 08 16:41:41 2011 -0500
@@ -17,6 +17,7 @@
> mylog = log
> lognull = log -r null
> shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
+ > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
> dln = lognull --debug
> nousage = rollback
> put = export -r 0 -o "\$FOO/%R.diff"
@@ -127,6 +128,10 @@
$ hg shortlog
0 e63c23eaa88a | 1970-01-01 00:00 +0000
+positional arguments
+
+ $ hg positional 'node|short' rev
+ 0 e63c23eaa88a | 1970-01-01 00:00 +0000
interaction with defaults
--- a/tests/test-bookmarks.t Sun May 08 21:32:33 2011 +0200
+++ b/tests/test-bookmarks.t Sun May 08 16:41:41 2011 -0500
@@ -235,6 +235,7 @@
Y 2:db815d6d32e6
* Z 2:db815d6d32e6
x y 2:db815d6d32e6
+
test summary
$ hg summary
@@ -249,6 +250,22 @@
$ hg id
db815d6d32e6 tip Y/Z/x y
+test rollback
+
+ $ echo foo > f1
+ $ hg ci -Amr
+ adding f1
+ $ hg bookmark -f Y -r 1
+ $ hg bookmark -f Z -r 1
+ $ hg rollback
+ repository tip rolled back to revision 2 (undo commit)
+ working directory now based on revision 2
+ $ hg bookmarks
+ X2 1:925d80f479bb
+ Y 2:db815d6d32e6
+ * Z 2:db815d6d32e6
+ x y 2:db815d6d32e6
+
test clone
$ hg bookmarks
--- a/tests/test-fncache.t Sun May 08 21:32:33 2011 +0200
+++ b/tests/test-fncache.t Sun May 08 16:41:41 2011 -0500
@@ -76,6 +76,7 @@
.hg/last-message.txt
.hg/requires
.hg/undo
+ .hg/undo.bookmarks
.hg/undo.branch
.hg/undo.desc
.hg/undo.dirstate
@@ -102,6 +103,7 @@
.hg/store/data/tst.d.hg
.hg/store/data/tst.d.hg/_foo.i
.hg/store/undo
+ .hg/undo.bookmarks
.hg/undo.branch
.hg/undo.desc
.hg/undo.dirstate
--- a/tests/test-hardlinks.t Sun May 08 21:32:33 2011 +0200
+++ b/tests/test-hardlinks.t Sun May 08 16:41:41 2011 -0500
@@ -194,6 +194,7 @@
2 r4/.hg/store/data/f1.i
2 r4/.hg/store/fncache
2 r4/.hg/store/undo
+ 2 r4/.hg/undo.bookmarks
2 r4/.hg/undo.branch
2 r4/.hg/undo.desc
2 r4/.hg/undo.dirstate
@@ -222,6 +223,7 @@
2 r4/.hg/store/data/f1.i
2 r4/.hg/store/fncache
2 r4/.hg/store/undo
+ 2 r4/.hg/undo.bookmarks
2 r4/.hg/undo.branch
2 r4/.hg/undo.desc
2 r4/.hg/undo.dirstate
--- a/tests/test-hup.t Sun May 08 21:32:33 2011 +0200
+++ b/tests/test-hup.t Sun May 08 16:41:41 2011 -0500
@@ -17,4 +17,4 @@
rollback completed
killed!
$ echo .hg/* .hg/store/*
- .hg/00changelog.i .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
+ .hg/00changelog.i .hg/journal.bookmarks .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
--- a/tests/test-inherit-mode.t Sun May 08 21:32:33 2011 +0200
+++ b/tests/test-inherit-mode.t Sun May 08 16:41:41 2011 -0500
@@ -77,6 +77,7 @@
00660 ./.hg/store/data/foo.i
00660 ./.hg/store/fncache
00660 ./.hg/store/undo
+ 00660 ./.hg/undo.bookmarks
00660 ./.hg/undo.branch
00660 ./.hg/undo.desc
00660 ./.hg/undo.dirstate
@@ -117,6 +118,7 @@
00660 ../push/.hg/store/data/foo.i
00660 ../push/.hg/store/fncache
00660 ../push/.hg/store/undo
+ 00660 ../push/.hg/undo.bookmarks
00660 ../push/.hg/undo.branch
00660 ../push/.hg/undo.desc
00660 ../push/.hg/undo.dirstate