Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/logilab/common/hg.py

Issue 739393004: Revert "Revert "pylint: upgrade to 1.3.1"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/logilab/common/graph.py ('k') | third_party/logilab/common/logging_ext.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3 #
4 # This file is part of logilab-common.
5 #
6 # logilab-common is free software: you can redistribute it and/or modify it unde r
7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation, either version 2.1 of the License, or (at your option) an y
9 # later version.
10 #
11 # logilab-common is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU Lesser General Public License along
17 # with logilab-common. If not, see <http://www.gnu.org/licenses/>.
18 """mercurial utilities (mercurial should be installed)"""
19
20 __docformat__ = "restructuredtext en"
21
22 import os
23 import sys
24 import os.path as osp
25
26 try:
27 from mercurial.error import RepoError
28 from mercurial.__version__ import version as hg_version
29 except ImportError:
30 from mercurial.repo import RepoError
31 from mercurial.version import get_version
32 hg_version = get_version()
33
34 from mercurial.hg import repository as Repository
35 from mercurial.ui import ui as Ui
36 from mercurial.node import short
37 try:
38 # mercurial >= 1.2 (?)
39 from mercurial.cmdutil import walkchangerevs
40 except ImportError, ex:
41 from mercurial.commands import walkchangerevs
42 try:
43 # mercurial >= 1.1 (.1?)
44 from mercurial.util import cachefunc
45 except ImportError, ex:
46 def cachefunc(func):
47 return func
48 try:
49 # mercurial >= 1.3.1
50 from mercurial import encoding
51 _encoding = encoding.encoding
52 except ImportError:
53 try:
54 from mercurial.util import _encoding
55 except ImportError:
56 import locale
57 # stay compatible with mercurial 0.9.1 (etch debian release)
58 # (borrowed from mercurial.util 1.1.2)
59 try:
60 _encoding = os.environ.get("HGENCODING")
61 if sys.platform == 'darwin' and not _encoding:
62 # On darwin, getpreferredencoding ignores the locale environment and
63 # always returns mac-roman. We override this if the environment is
64 # not C (has been customized by the user).
65 locale.setlocale(locale.LC_CTYPE, '')
66 _encoding = locale.getlocale()[1]
67 if not _encoding:
68 _encoding = locale.getpreferredencoding() or 'ascii'
69 except locale.Error:
70 _encoding = 'ascii'
71 try:
72 # demandimport causes problems when activated, ensure it isn't
73 # XXX put this in apycot where the pb has been noticed?
74 from mercurial import demandimport
75 demandimport.disable()
76 except:
77 pass
78
79 Ui.warn = lambda *args, **kwargs: 0 # make it quiet
80
81 def find_repository(path):
82 """returns <path>'s mercurial repository
83
84 None if <path> is not under hg control
85 """
86 path = osp.realpath(osp.abspath(path))
87 while not osp.isdir(osp.join(path, ".hg")):
88 oldpath = path
89 path = osp.dirname(path)
90 if path == oldpath:
91 return None
92 return path
93
94
95 def get_repository(path):
96 """Simple function that open a hg repository"""
97 repopath = find_repository(path)
98 if repopath is None:
99 raise RuntimeError('no repository found in %s' % osp.abspath(path))
100 return Repository(Ui(), path=repopath)
101
102 def incoming(wdrepo, masterrepo):
103 try:
104 return wdrepo.findincoming(masterrepo)
105 except AttributeError:
106 from mercurial import hg, discovery
107 revs, checkout = hg.addbranchrevs(wdrepo, masterrepo, ('', []), None)
108 common, incoming, rheads = discovery.findcommonincoming(
109 wdrepo, masterrepo, heads=revs)
110 if not masterrepo.local():
111 from mercurial import bundlerepo, changegroup
112 if revs is None and masterrepo.capable('changegroupsubset'):
113 revs = rheads
114 if revs is None:
115 cg = masterrepo.changegroup(incoming, "incoming")
116 else:
117 cg = masterrepo.changegroupsubset(incoming, revs, 'incoming')
118 fname = changegroup.writebundle(cg, None, "HG10UN")
119 # use the created uncompressed bundlerepo
120 masterrepo = bundlerepo.bundlerepository(wdrepo.ui, wdrepo.root, fna me)
121 return masterrepo.changelog.nodesbetween(incoming, revs)[0]
122
123 def outgoing(wdrepo, masterrepo):
124 try:
125 return wdrepo.findoutgoing(masterrepo)
126 except AttributeError:
127 from mercurial import hg, discovery
128 revs, checkout = hg.addbranchrevs(wdrepo, wdrepo, ('', []), None)
129 o = discovery.findoutgoing(wdrepo, masterrepo)
130 return wdrepo.changelog.nodesbetween(o, revs)[0]
OLDNEW
« no previous file with comments | « third_party/logilab/common/graph.py ('k') | third_party/logilab/common/logging_ext.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698