Changeset 105bd3eb46a4…
Parent 0b1d58ee5c34…
by Kevin Gessner <kevin@fogcreek.com>
Changes to 4 files · Browse files at 105bd3eb46a4 Showing diff from parent 0b1d58ee5c34 Diff from another changeset...
@@ -1,4 +1,4 @@ - # Copyright (C) 2009-2011 Fog Creek Software. All rights reserved.
+# Copyright (C) 2009-2012 Fog Creek Software. All rights reserved.
#
# To enable the "gestalt" extension put these lines in your ~/.hgrc:
# [extensions]
@@ -9,7 +9,7 @@#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -85,16 +85,16 @@ 1.5 redefined parseurl()'s return values, and 1.6 split up the
branches parameter into a two-tuple.
'''
- url, branches = hg.parseurl(source, None)[:2]
+ uri, branches = hg.parseurl(source, None)[:2]
if _HG_VERSION >= (1, 6, 0):
# branches will be None because we passed None into
- # parseurl(), so we can ignore that safely.
+ # parseuri(), so we can ignore that safely.
hashbranch, branches = branches
else:
# branches will contain one element or fewer because we passed
- # None into parseurl().
+ # None into parseuri().
hashbranch = branches and branches[0] or None
- return url, hashbranch
+ return uri, hashbranch
def addbranchrevs(lrepo, repo, hashbranch):
'''wrap hg.addbranchrevs to work on 1.5 and 1.6 and returns the
@@ -176,7 +176,6 @@'''))
return True
- target = ui.config('paths', 'default-push') and ui.expandpath('default-push') or source
source, hashbranch = parseurl(source)
other = hg.repository(remoteui(repo, opts), source)
revs = addbranchrevs(repo, other, hashbranch)
|
@@ -90,10 +90,8 @@ if before != after:
try:
os.rename(self.__temporary_path, self.__original_path)
- except WindowsError:
+ except (IOError, OSError, WindowsError):
shutil.copyfile(self.__temporary_path, self.__original_path)
- except (IOError, OSError):
- pass
def get_cookiejar(ui):
global current_user
@@ -117,13 +115,18 @@ try:
cj = CookieJar(cookie_path)
if not os.path.exists(cookie_path):
- cj.save()
+ try:
+ cj.save()
+ except Exception, e:
+ ui.warn(_('unable to save cookies: %s') % str(e))
+ # save() destroys the tempfile; get a new one
+ cj = CookieJar(cookie_path)
if os.name == 'posix':
os.chmod(cookie_path, stat.S_IREAD | stat.S_IWRITE)
cj.load(ignore_discard=True, ignore_expires=True)
return cj
- except IOError:
- ui.warn(_('Cookie file %s exists, but could not be opened.\nContinuing without cookie authentication.\n') % cookie_path)
+ except IOError, e:
+ ui.warn(_('Cookie file %s exists, but could not be opened (%s).\nContinuing without cookie authentication.\n') % (cookie_path, e))
return MozillaCookieJar(tempfile.NamedTemporaryFile().name)
def make_cookie(request, name, value):
@@ -193,7 +196,10 @@ cj.add_cookie_header(request)
response = func(*args, **kwargs)
cj.extract_cookies(response, args[0])
- cj.save(ignore_discard=True, ignore_expires=True)
+ try:
+ cj.save(ignore_discard=True, ignore_expires=True)
+ except Exception, e:
+ ui.warn(_('unable to save cookies: %s') % str(e))
else:
response = func(*args, **kwargs)
return response
|
@@ -2,50 +2,41 @@ import os
import zipfile
-folders = ['bfiles', '_custom']
-extensions = ['.py']
-excludes = ['setup.py']
-
def compile_extensions():
compileall.compile_dir(os.path.dirname(__file__), force=1)
-def check_item(item):
- for exclude in excludes:
- if item[1].endswith(exclude):
- return False
- if item[1] in folders:
- return True
- for extension in extensions:
- if item[1].endswith(extension):
- return True
- return False
+def walk(dir_root):
+ for dirpath, dirnames, filenames in os.walk(dir_root):
+ dirnames_set = set(dirnames)
+ if 'tests' in dirnames_set:
+ dirnames.remove('tests')
-def list_files(dir_root, zip_root):
- subdirs = []
- items = []
- for item in os.listdir(dir_root):
- path = os.path.join(dir_root, item)
- zip_path = os.path.join(zip_root, item)
- if os.path.isfile(path):
- items.append([path, zip_path])
- else:
- subdirs.append([path, zip_path])
- for subdir in subdirs:
- items.extend(list_files(subdir[0], subdir[1]))
- return [f for f in items if check_item(f)]
+ for filename in filenames:
+ ignore, ext = os.path.splitext(filename)
+ if filename == 'setup.py':
+ continue
+ if ext not in ('.py', '.pyc'):
+ continue
+ yield os.path.join(dirpath, filename)
def build_release():
- compile_extensions()
- dir = os.path.dirname(__file__)
- absdir = os.path.abspath(dir)
- files = list_files(absdir, '.')
+ absdir = os.path.abspath(os.path.dirname(__file__))
+ target = os.path.join(absdir, 'kiln_extensions.zip')
print 'Creating ZIP archive...'
- zip = zipfile.ZipFile(os.path.join(absdir, 'kiln_extensions.zip'), 'w')
- for file in files:
- zip.write(file[0], file[1])
- zip.close()
+ f = None
+ try:
+ f = zipfile.ZipFile(target, 'w')
+ for filename in walk(absdir):
+ zip_filename = os.path.join(
+ 'kiln_extensions',
+ os.path.relpath(filename, absdir))
+ print ' %s' % zip_filename
+ f.write(filename, zip_filename)
+ finally:
+ if f: f.close()
print 'Success!'
if __name__ == '__main__':
+ compile_extensions()
build_release()
|
Loading...