Mercurial > hg-stable
changeset 13388:a184dbd9b2c5
localrepo: sort hg bookmark output
sort bookmarks before we write them to stdout to get a predictable output.
author | David Soria Parra <dsp@php.net> |
---|---|
date | Fri, 11 Feb 2011 20:35:32 +0100 |
parents | 900a92862a7b (diff) 0be2fe6a0843 (current diff) |
children | 3efc99ac2ac4 |
files | mercurial/commands.py tests/test-bookmarks-pushpull.t tests/test-bookmarks-rebase.t tests/test-bookmarks.t |
diffstat | 7 files changed, 109 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Fri Feb 11 20:35:30 2011 +0100 +++ b/hgext/mq.py Fri Feb 11 20:35:32 2011 +0100 @@ -1061,15 +1061,17 @@ # go backwards with qpush) if patch: info = self.isapplied(patch) - if info: - if info[0] < len(self.applied) - 1: - raise util.Abort( - _("cannot push to a previous patch: %s") % patch) + if info and info[0] >= len(self.applied) - 1: self.ui.warn( _('qpush: %s is already at the top\n') % patch) return 0 + pushable, reason = self.pushable(patch) - if not pushable: + if pushable: + if self.series.index(patch) < self.series_end(): + raise util.Abort( + _("cannot push to a previous patch: %s") % patch) + else: if reason: reason = _('guarded by %r') % reason else:
--- a/mercurial/commands.py Fri Feb 11 20:35:30 2011 +0100 +++ b/mercurial/commands.py Fri Feb 11 20:35:32 2011 +0100 @@ -530,7 +530,7 @@ if len(marks) == 0: ui.status(_("no bookmarks set\n")) else: - for bmark, n in marks.iteritems(): + for bmark, n in sorted(marks.iteritems()): if ui.configbool('bookmarks', 'track.current'): current = repo._bookmarkcurrent if bmark == current and n == cur:
--- a/mercurial/url.py Fri Feb 11 20:35:30 2011 +0100 +++ b/mercurial/url.py Fri Feb 11 20:35:32 2011 +0100 @@ -71,6 +71,38 @@ return userpass + '@' + hostport return hostport +def readauthforuri(ui, uri): + # Read configuration + config = dict() + for key, val in ui.configitems('auth'): + if '.' not in key: + ui.warn(_("ignoring invalid [auth] key '%s'\n") % key) + continue + group, setting = key.rsplit('.', 1) + gdict = config.setdefault(group, dict()) + if setting in ('username', 'cert', 'key'): + val = util.expandpath(val) + gdict[setting] = val + + # Find the best match + scheme, hostpath = uri.split('://', 1) + bestlen = 0 + bestauth = None + for group, auth in config.iteritems(): + prefix = auth.get('prefix') + if not prefix: + continue + p = prefix.split('://', 1) + if len(p) > 1: + schemes, prefix = [p[0]], p[1] + else: + schemes = (auth.get('schemes') or 'https').split() + if (prefix == '*' or hostpath.startswith(prefix)) and \ + len(prefix) > bestlen and scheme in schemes: + bestlen = len(prefix) + bestauth = group, auth + return bestauth + _safe = ('abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' '0123456789' '_.-/') @@ -123,9 +155,11 @@ return (user, passwd) if not user: - auth = self.readauthtoken(authuri) - if auth: + res = readauthforuri(self.ui, authuri) + if res: + group, auth = res user, passwd = auth.get('username'), auth.get('password') + self.ui.debug("using auth.%s.* for authentication\n" % group) if not user or not passwd: if not self.ui.interactive(): raise util.Abort(_('http authorization required')) @@ -148,38 +182,6 @@ msg = _('http auth: user %s, password %s\n') self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set')) - def readauthtoken(self, uri): - # Read configuration - config = dict() - for key, val in self.ui.configitems('auth'): - if '.' not in key: - self.ui.warn(_("ignoring invalid [auth] key '%s'\n") % key) - continue - group, setting = key.split('.', 1) - gdict = config.setdefault(group, dict()) - if setting in ('username', 'cert', 'key'): - val = util.expandpath(val) - gdict[setting] = val - - # Find the best match - scheme, hostpath = uri.split('://', 1) - bestlen = 0 - bestauth = None - for auth in config.itervalues(): - prefix = auth.get('prefix') - if not prefix: - continue - p = prefix.split('://', 1) - if len(p) > 1: - schemes, prefix = [p[0]], p[1] - else: - schemes = (auth.get('schemes') or 'https').split() - if (prefix == '*' or hostpath.startswith(prefix)) and \ - len(prefix) > bestlen and scheme in schemes: - bestlen = len(prefix) - bestauth = auth - return bestauth - class proxyhandler(urllib2.ProxyHandler): def __init__(self, ui): proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') @@ -621,7 +623,13 @@ return keepalive.KeepAliveHandler._start_transaction(self, h, req) def https_open(self, req): - self.auth = self.pwmgr.readauthtoken(req.get_full_url()) + res = readauthforuri(self.ui, req.get_full_url()) + if res: + group, auth = res + self.auth = auth + self.ui.debug("using auth.%s.* for authentication\n" % group) + else: + self.auth = None return self.do_open(self._makeconnection, req) def _makeconnection(self, host, port=None, *args, **kwargs):
--- a/tests/test-bookmarks-pushpull.t Fri Feb 11 20:35:30 2011 +0100 +++ b/tests/test-bookmarks-pushpull.t Fri Feb 11 20:35:32 2011 +0100 @@ -48,8 +48,8 @@ no changes found importing bookmark X $ hg bookmark + X 0:4e3505fd9583 Y 0:4e3505fd9583 - X 0:4e3505fd9583 export bookmark by name @@ -62,10 +62,10 @@ no changes found exporting bookmark W $ hg -R ../a bookmarks - Y 0:4e3505fd9583 + W -1:000000000000 X 0:4e3505fd9583 + Y 0:4e3505fd9583 * Z 0:4e3505fd9583 - W -1:000000000000 delete a remote bookmark @@ -97,8 +97,8 @@ adding f1 $ hg book -f X $ hg book + * X 1:0d2164f0ce0d Y 0:4e3505fd9583 - * X 1:0d2164f0ce0d Z 1:0d2164f0ce0d $ cd ../b @@ -109,8 +109,8 @@ adding f2 $ hg book -f X $ hg book + * X 1:9b140be10808 Y 0:4e3505fd9583 - * X 1:9b140be10808 foo -1:000000000000 foobar -1:000000000000 @@ -124,8 +124,8 @@ not updating divergent bookmark X (run 'hg heads' to see heads, 'hg merge' to merge) $ hg book + * X 1:9b140be10808 Y 0:4e3505fd9583 - * X 1:9b140be10808 foo -1:000000000000 foobar -1:000000000000 $ hg push -f ../a @@ -136,8 +136,8 @@ adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) $ hg -R ../a book + * X 1:0d2164f0ce0d Y 0:4e3505fd9583 - * X 1:0d2164f0ce0d Z 1:0d2164f0ce0d hgweb
--- a/tests/test-bookmarks-rebase.t Fri Feb 11 20:35:30 2011 +0100 +++ b/tests/test-bookmarks-rebase.t Fri Feb 11 20:35:32 2011 +0100 @@ -31,8 +31,8 @@ bookmark list $ hg bookmark + one 1:925d80f479bb * two 3:2ae46b1d99a7 - one 1:925d80f479bb rebase
--- a/tests/test-bookmarks.t Fri Feb 11 20:35:30 2011 +0100 +++ b/tests/test-bookmarks.t Fri Feb 11 20:35:32 2011 +0100 @@ -54,8 +54,8 @@ list bookmarks $ hg bookmarks + * X 0:f7b1eb17ad24 * X2 0:f7b1eb17ad24 - * X 0:f7b1eb17ad24 Y -1:000000000000 $ echo b > b @@ -89,8 +89,8 @@ bookmarks X and X2 moved to rev 1, Y at rev -1 $ hg bookmarks + * X 1:925d80f479bb * X2 1:925d80f479bb - * X 1:925d80f479bb Y -1:000000000000 bookmark rev 0 again @@ -104,10 +104,10 @@ bookmarks X and X2 moved to rev 2, Y at rev -1, Z at rev 0 $ hg bookmarks + * X 2:0316ce92851d * X2 2:0316ce92851d - * X 2:0316ce92851d + Y -1:000000000000 Z 0:f7b1eb17ad24 - Y -1:000000000000 rename nonexistent bookmark
--- a/tests/test-mq-qpush-fail.t Fri Feb 11 20:35:30 2011 +0100 +++ b/tests/test-mq-qpush-fail.t Fri Feb 11 20:35:32 2011 +0100 @@ -88,3 +88,49 @@ applying patch1 unable to read patch1 [1] + +Test qpush to a patch below the currently applied patch. + + $ hg qq -c guardedseriesorder + $ hg qnew a + $ hg qguard +block + $ hg qnew b + $ hg qnew c + + $ hg qpop -a + popping c + popping b + popping a + patch queue now empty + +try to push and pop while a is guarded + + $ hg qpush a + cannot push 'a' - guarded by ['+block'] + [1] + $ hg qpush -a + applying b + patch b is empty + applying c + patch c is empty + now at: c + +now try it when a is unguarded, and we're at the top of the queue + $ hg qsel block + number of guarded, applied patches has changed from 1 to 0 + $ hg qpush b + abort: cannot push to a previous patch: b + [255] + $ hg qpush a + abort: cannot push to a previous patch: a + [255] + +and now we try it one more time with a unguarded, while we're not at the top of the queue + + $ hg qpop b + popping c + now at: b + $ hg qpush a + abort: cannot push to a previous patch: a + [255] +