Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
79d2c570
Commit
79d2c570
authored
Jan 25, 2012
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codereview: support for subrepositories
R=golang-dev, adg CC=golang-dev
https://golang.org/cl/5564054
parent
8efc020d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
18 deletions
+43
-18
lib/codereview/codereview.py
lib/codereview/codereview.py
+43
-18
No files found.
lib/codereview/codereview.py
View file @
79d2c570
...
...
@@ -955,14 +955,23 @@ def CheckTabfmt(ui, repo, files, just_warn):
#######################################################################
# CONTRIBUTORS file parsing
contributors = {}
contributorsCache = None
contributorsURL = None
def ReadContributors(ui, repo):
global contributors
global contributorsCache
if contributorsCache is not None:
return contributorsCache
try:
f = open(repo.root + '/CONTRIBUTORS', 'r')
if contributorsURL is not None:
opening = contributorsURL
f = urllib2.urlopen(contributorsURL)
else:
opening = repo.root + '/CONTRIBUTORS'
f = open(repo.root + '/CONTRIBUTORS', 'r')
except:
ui.write("
warning
:
cannot
open
%
s
:
%
s
\
n
" % (
repo.root+'/CONTRIBUTORS'
, ExceptionDetail()))
ui.write("
warning
:
cannot
open
%
s
:
%
s
\
n
" % (
opening
, ExceptionDetail()))
return
for line in f:
...
...
@@ -980,6 +989,9 @@ def ReadContributors(ui, repo):
for extra in m.group(3).split():
contributors[extra[1:-1].lower()] = (name, email)
contributorsCache = contributors
return contributors
def CheckContributor(ui, repo, user=None):
set_status("
checking
CONTRIBUTORS
file
")
user, userline = FindContributor(ui, repo, user, warn=False)
...
...
@@ -997,6 +1009,7 @@ def FindContributor(ui, repo, user=None, warn=True):
if m:
user = m.group(1)
contributors = ReadContributors(ui, repo)
if user not in contributors:
if warn:
ui.warn("
warning
:
cannot
find
%
s
in
CONTRIBUTORS
\
n
" % (user,))
...
...
@@ -2163,27 +2176,35 @@ def reposetup(ui, repo):
global
codereview_disabled
global
defaultcc
# Read repository-specific options from lib/codereview/codereview.cfg or codereview.cfg.
root
=
''
try
:
root
=
repo
.
root
except
:
# Yes, repo might not have root; see issue 959.
codereview_disabled
=
'codereview disabled: repository has no root'
return
repo_config_path
=
''
# Read repository-specific options from lib/codereview/codereview.cfg
p1
=
root
+
'/lib/codereview/codereview.cfg'
p2
=
root
+
'/codereview.cfg'
if
os
.
access
(
p1
,
os
.
F_OK
):
repo_config_path
=
p1
else
:
repo_config_path
=
p2
try
:
repo_config_path
=
repo
.
root
+
'/lib/codereview/codereview.cfg'
f
=
open
(
repo_config_path
)
for
line
in
f
:
if
line
.
startswith
(
'defaultcc: '
):
defaultcc
=
SplitCommaSpace
(
line
[
10
:])
if
line
.
startswith
(
'defaultcc:'
):
defaultcc
=
SplitCommaSpace
(
line
[
len
(
'defaultcc:'
):])
if
line
.
startswith
(
'contributors:'
):
global
contributorsURL
contributorsURL
=
line
[
len
(
'contributors:'
):].
strip
()
except
:
# If there are no options, chances are good this is not
# a code review repository; stop now before we foul
# things up even worse. Might also be that repo doesn't
# even have a root. See issue 959.
if
repo_config_path
==
''
:
codereview_disabled
=
'codereview disabled: repository has no root'
else
:
codereview_disabled
=
'codereview disabled: cannot open '
+
repo_config_path
codereview_disabled
=
'codereview disabled: cannot open '
+
repo_config_path
return
InstallMatch
(
ui
,
repo
)
ReadContributors
(
ui
,
repo
)
RietveldSetup
(
ui
,
repo
)
# Disable the Mercurial commands that might change the repository.
...
...
@@ -3298,7 +3319,11 @@ class MercurialVCS(VersionControlSystem):
if not err and mqparent != "":
self.base_rev = mqparent
else:
self.base_rev = RunShell(["
hg
", "
parents
", "
-
q
"]).split(':')[1].strip()
out = RunShell(["
hg
", "
parents
", "
-
q
"], silent_ok=True).strip()
if not out:
# No revisions; use 0 to mean a repository with nothing.
out = "
0
:
0
"
self.base_rev = out.split(':')[1].strip()
def _GetRelPath(self, filename):
"""Get relative path of a file according to the current directory,
given its logical path in the repo."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment