Changeset 0b1d58ee5c34…
Parent 67d19149537f…
by Kevin Gessner <kevin@fogcreek.com>
Changes to 3 files · Browse files at 0b1d58ee5c34 Showing diff from parent 67d19149537f Diff from another changeset...
@@ -1155,13 +1155,14 @@ f = bfutil.splitstandin(f)
def getdatafn():
+ fd = None
try:
fd = open(path, 'rb')
return fd.read()
finally:
- fd.close()
+ if fd: fd.close()
- getdata = getdatafn
+ if path: getdata = getdatafn
write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata)
if subrepos:
|
@@ -36,9 +36,17 @@
def prepush(repo, other, force, revs):
try:
- # Mercurial 1.6 and higher
from mercurial import discovery
- return discovery.prepush(repo, other, force, revs, False)
+ try:
+ # Mercurial 1.6 through 2.0
+ return discovery.prepush(repo, other, force, revs, False)
+ except AttributeError:
+ # Mercurial 2.1 and higher
+ fci = discovery.findcommonincoming(repo, other, force=force)
+ outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs, commoninc=fci, force=force)
+ if not force:
+ discovery.checkheads(repo, other, outgoing, fci[2], False)
+ return [True]
except ImportError:
# Mercurial 1.5 and lower
return repo.prepush(other, False, revs)
|
@@ -6,6 +6,7 @@ #
# For help on the usage of "hg kiln" use:
# hg help kiln
+# hg help -e kiln
#
# 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
@@ -31,10 +32,14 @@This extension will also notify you when a Kiln server you access has an
updated version of the Kiln Client and Tools available.
To disable the check for a version 'X.Y.Z' and all lower versions, add the
-following line in the [kiln] section of your hgrc:
+following line in the [kiln] section of your hgrc::
+
ignoreversion = X.Y.Z
+
+This extension also lets you create or add changesets to a code review when
+pushing to Kiln. See :hg:`help push` and
+http://kiln.stackexchange.com/questions/4679/ for more information.
'''
-import httplib
import os
import re
import unicodedata
@@ -45,7 +50,7 @@
from cookielib import MozillaCookieJar
from hashlib import md5
-from mercurial import commands, cmdutil, demandimport, error, extensions, hg, \
+from mercurial import commands, cmdutil, demandimport, extensions, hg, \
httprepo, localrepo, match, util
from mercurial import ui as hgui
from mercurial import url as hgurl
@@ -84,13 +89,10 @@
Inspect self.errors to see the API errors thrown.
'''
- self.errors = []
- for error in obj['errors']:
- data = error['codeError'], error['sError']
- self.errors.append('%s: %s' % data)
+ self.errors = dict((e['codeError'], e['sError']) for e in obj['errors'])
def __str__(self):
- return '\n'.join(self.errors)
+ return '\n'.join('%s: %s' % (k, v) for k, v in self.errors.items())
def urljoin(*components):
url = components[0]
@@ -332,7 +334,7 @@ if not os.path.exists(cookiepath):
return ''
cj = MozillaCookieJar(cookiepath)
- except IOError, e:
+ except IOError:
return ''
domain = get_domain(url)
@@ -372,7 +374,7 @@ # Mercurial assumes Unix newlines by default and so do we.
fp.write('\n[paths]\n%s = %s\n' % (path, value))
fp.close()
- except IOError, e:
+ except IOError:
return
def unremember_path(ui, repo):
@@ -536,8 +538,8 @@ url = fd.headers.getheaders('location')[0]
elif 'uri' in fd.headers:
url = fd.headers.getheaders('uri')[0]
- except HTTPError as e:
- raise util.Abort(_('Invalid URL: %s' % url))
+ except urllib2.HTTPError:
+ raise util.Abort(_('Invalid URL: %s') % url)
def find_slug(slug, l, attr=None):
if not l:
@@ -566,8 +568,14 @@ 'fCentral': False,
'sDefaultPermission': 'inherit',
'token': token}
- repo.ui.write('branching from %s' % url)
- return call_api(repo.ui, baseurl, 'Api/1.0/Repo/Create', params, post=True)
+ repo.ui.write(_('branching from %s\n') % url)
+ try:
+ return call_api(repo.ui, baseurl, 'Api/1.0/Repo/Create', params, post=True)
+ except APIError, e:
+ if 'RepoNameAlreadyUsed' in e.errors:
+ repo.ui.write_err(_('error: a repo with this name already exists: %s\n') % name)
+ return
+ raise
def normalize_user(s):
'''Takes a Unicode string and returns an ASCII string.'''
|
Loading...