Changeset bf74641d43fb…
Parent 03426ac40250…
by Benjamin Pollack <benjamin@fogcreek.com>
Changes to 6 files · Browse files at bf74641d43fb Showing diff from parent 03426ac40250 Diff from another changeset...
@@ -1,4 +1,4 @@ - # Copyright (C) 2009-2010 Fog Creek Software. All rights reserved.
+# Copyright (C) 2009-2011 Fog Creek Software. All rights reserved.
#
# 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
|
@@ -1,3 +1,7 @@ + # Portions copyright (C) 2011 Fog Creek Software.
+# Portions copyright (C) 2010 Alexandru Totolici
+# http://hackd.net/projects/caseguard/
+#
# This Mercurial extension prevents users from adding:
# * filenames that differ only by case (i.e. 'FOO' and 'foo')
# * Windows-reserved filenames.
@@ -33,8 +37,6 @@# repository tracks. All changes must be committed before caseguard will
# allow files to be added (this means 'hg rm foo; hg add FOO' will fail).
#
-# Copyright (C) 2010 - Alexandru Totolici
-# http://hackd.net/projects/caseguard/
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
|
@@ -1,4 +1,4 @@ - # Copyright (C) 2009-2010 Fog Creek Software. All rights reserved.
+# Copyright (C) 2009-2011 Fog Creek Software. All rights reserved.
#
# To enable the "gestalt" extension put these lines in your ~/.hgrc:
# [extensions]
|
@@ -143,7 +143,7 @@ else:
fd = urllib2.urlopen(url + '?' + data)
obj = json.load(fd)
- except:
+ except Exception:
raise util.Abort(_('Path guessing requires Fog Creek Kiln 2.0. If you'
' are running Kiln 2.0 and continue to experience'
' problems, please contact Fog Creek Software.'))
|
@@ -1,4 +1,4 @@ - # Copyright (C) 2009-2010 Fog Creek Software. All rights reserved.
+# Copyright (C) 2009-2011 Fog Creek Software. All rights reserved.
#
# To enable the "kilnauth" extension put these lines in your ~/.hgrc:
# [extensions]
@@ -31,12 +31,12 @@If you ever need to logout of Kiln, simply run ``hg logout''
'''
+from cookielib import MozillaCookieJar, Cookie
+from urllib2 import Request
import os
+import re
+import shutil
import stat
-import re
-from urllib2 import Request
-from cookielib import MozillaCookieJar, Cookie
-import shutil
import sys
import tempfile
@@ -76,11 +76,16 @@ pass
def save(self, *args, **kwargs):
+ with open(self.__temporary_path, 'rb') as f:
+ before = md5(f.read()).digest()
super(CookieJar, self).save(*args, **kwargs)
- try:
- shutil.copyfile(self.__temporary_path, self.__original_path)
- except IOError:
- pass
+ with open(self.__temporary_path, 'rb') as f:
+ after = md5(f.read()).digest()
+ if before != after:
+ try:
+ os.rename(self.__temporary_path, self.__original_path)
+ except (IOError, WindowsError, OSError):
+ pass
def get_cookiejar(ui):
global current_user
@@ -109,9 +114,9 @@ os.chmod(cookie_path, stat.S_IREAD | stat.S_IWRITE)
cj.load(ignore_discard=True, ignore_expires=True)
return cj
- except IOError, e:
+ except IOError:
ui.warn(_('Cookie file %s exists, but could not be opened.\nContinuing without cookie authentication.\n') % cookie_path)
- return MozillaCookieJar()
+ return MozillaCookieJar(tempfile.NamedTemporaryFile().name)
def make_cookie(request, name, value):
domain = request.get_host()
|
- # Copyright (C) 2009-2010 Fog Creek Software. All rights reserved.
+# Copyright (C) 2009-2011 Fog Creek Software. All rights reserved.
#
# To enable the "kilnpath" extension put these lines in your ~/.hgrc:
# [extensions]
# kilnpath = /path/to/kilnpath.py
#
# 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
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'''Lets users identify repository paths by custom schemes like kiln://Project/Group/Repository.
This extensions knows how to expand Kiln repository paths from
kiln://Project/Group/Repository to
the full http://your.fogbugz.com/kiln/Repo/Project/Group/Repository,
so you only have to type
"hg pull kiln://Project/Group/Repository" at the command line.
This extensions works for pull, push, incoming, outgoing, and clone.
To specify the Kiln path prefix, add a [kiln_scheme] section to your hg config like so:
[kiln_scheme]
kiln = https://your.fogbugz.com/kiln/Repo
'''
import os
from mercurial import extensions, commands, hg, ui
def urlcombine(pre, suff):
if pre.endswith("/"):
pre = pre[0:len(pre) - 1]
if not suff.startswith("/"):
suff = "/" + suff
return pre + suff
def add_schemes(ui):
schemes = ui.configitems('kiln_scheme')
for scheme, prefix in schemes:
hg.schemes[scheme] = KilnRepo(scheme, prefix)
class KilnRepo(object):
def __init__(self, scheme, prefix):
self.scheme = scheme
self.prefix = prefix
def instance(self, ui, path, create):
path_pieces = path.split(":", 1)
if len(path_pieces) <= 1:
return None
suffix = path_pieces[1]
if suffix.startswith("//"):
suffix = suffix[2:]
path_full = urlcombine(self.prefix, suffix)
try:
# Mercurial >= 1.9
return hg._peerlookup(path_full).instance(ui, path_full, create)
except AttributeError:
# Mercurial <= 1.8
return hg._lookup(path_full).instance(ui, path_full, create)
def extsetup(*args):
if len(args) > 0:
add_schemes(args[0])
else:
add_schemes(ui.ui())
|
Loading...