Commit 374d65e5 authored by maruel@chromium.org's avatar maruel@chromium.org

Move the changelist files into a subdirectory for cached files implementation.

Review URL: http://codereview.chromium.org/115612

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@16597 0039d316-1c4b-4281-b951-d872f2087c98
parent 672343d7
...@@ -10,6 +10,7 @@ import getpass ...@@ -10,6 +10,7 @@ import getpass
import os import os
import random import random
import re import re
import shutil
import string import string
import subprocess import subprocess
import sys import sys
...@@ -21,7 +22,7 @@ import xml.dom.minidom ...@@ -21,7 +22,7 @@ import xml.dom.minidom
# gcl now depends on gclient. # gcl now depends on gclient.
import gclient import gclient
__version__ = '1.0' __version__ = '1.1'
CODEREVIEW_SETTINGS = { CODEREVIEW_SETTINGS = {
...@@ -34,7 +35,6 @@ CODEREVIEW_SETTINGS = { ...@@ -34,7 +35,6 @@ CODEREVIEW_SETTINGS = {
# globals that store the root of the current repository and the directory where # globals that store the root of the current repository and the directory where
# we store information about changelists. # we store information about changelists.
repository_root = "" repository_root = ""
gcl_info_dir = ""
# Filename where we store repository specific information for gcl. # Filename where we store repository specific information for gcl.
CODEREVIEW_SETTINGS_FILE = "codereview.settings" CODEREVIEW_SETTINGS_FILE = "codereview.settings"
...@@ -110,10 +110,12 @@ def GetRepositoryRoot(): ...@@ -110,10 +110,12 @@ def GetRepositoryRoot():
def GetInfoDir(): def GetInfoDir():
"""Returns the directory where gcl info files are stored.""" """Returns the directory where gcl info files are stored."""
global gcl_info_dir return os.path.join(GetRepositoryRoot(), '.svn', 'gcl_info')
if not gcl_info_dir:
gcl_info_dir = os.path.join(GetRepositoryRoot(), '.svn', 'gcl_info')
return gcl_info_dir def GetChangesDir():
"""Returns the directory where gcl change files are stored."""
return os.path.join(GetInfoDir(), 'changes')
def GetCodeReviewSetting(key): def GetCodeReviewSetting(key):
...@@ -373,7 +375,7 @@ def GetChangelistInfoFile(changename): ...@@ -373,7 +375,7 @@ def GetChangelistInfoFile(changename):
"""Returns the file that stores information about a changelist.""" """Returns the file that stores information about a changelist."""
if not changename or re.search(r'[^\w-]', changename): if not changename or re.search(r'[^\w-]', changename):
ErrorExit("Invalid changelist name: " + changename) ErrorExit("Invalid changelist name: " + changename)
return os.path.join(GetInfoDir(), changename) return os.path.join(GetChangesDir(), changename)
def LoadChangelistInfoForMultiple(changenames, fail_on_not_found=True, def LoadChangelistInfoForMultiple(changenames, fail_on_not_found=True,
...@@ -442,7 +444,7 @@ def LoadChangelistInfo(changename, fail_on_not_found=True, ...@@ -442,7 +444,7 @@ def LoadChangelistInfo(changename, fail_on_not_found=True,
def GetCLs(): def GetCLs():
"""Returns a list of all the changelists in this repository.""" """Returns a list of all the changelists in this repository."""
cls = os.listdir(GetInfoDir()) cls = os.listdir(GetChangesDir())
if CODEREVIEW_SETTINGS_FILE in cls: if CODEREVIEW_SETTINGS_FILE in cls:
cls.remove(CODEREVIEW_SETTINGS_FILE) cls.remove(CODEREVIEW_SETTINGS_FILE)
return cls return cls
...@@ -1020,10 +1022,19 @@ def main(argv=None): ...@@ -1020,10 +1022,19 @@ def main(argv=None):
Help() Help()
return 0; return 0;
# Create the directory where we store information about changelists if it # Create the directories where we store information about changelists if it
# doesn't exist. # doesn't exist.
if not os.path.exists(GetInfoDir()): if not os.path.exists(GetInfoDir()):
os.mkdir(GetInfoDir()) os.mkdir(GetInfoDir())
if not os.path.exists(GetChangesDir()):
os.mkdir(GetChangesDir())
# For smooth upgrade support, move the files in GetInfoDir() to
# GetChangesDir().
# TODO(maruel): Remove this code in August 2009.
for file in os.listdir(unicode(GetInfoDir())):
file_path = os.path.join(unicode(GetInfoDir()), file)
if os.path.isfile(file_path) and file != CODEREVIEW_SETTINGS_FILE:
shutil.move(file_path, GetChangesDir())
# Commands that don't require an argument. # Commands that don't require an argument.
command = argv[1] command = argv[1]
......
...@@ -54,7 +54,8 @@ class GclUnittest(GclTestsBase): ...@@ -54,7 +54,8 @@ class GclUnittest(GclTestsBase):
members = [ members = [
'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS', 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS',
'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks', 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks',
'ErrorExit', 'GenerateChangeName', 'GenerateDiff', 'GetCLs', 'ErrorExit', 'GenerateChangeName', 'GenerateDiff', 'GetChangesDir',
'GetCLs',
'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor',
'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
'GetModifiedFiles', 'GetRepositoryRoot', 'GetModifiedFiles', 'GetRepositoryRoot',
...@@ -63,10 +64,10 @@ class GclUnittest(GclTestsBase): ...@@ -63,10 +64,10 @@ class GclUnittest(GclTestsBase):
'MISSING_TEST_MSG', 'Opened', 'PresubmitCL', 'ReadFile', 'MISSING_TEST_MSG', 'Opened', 'PresubmitCL', 'ReadFile',
'RunShell', 'RunShell',
'RunShellWithReturnCode', 'SEPARATOR', 'SendToRietveld', 'TryChange', 'RunShellWithReturnCode', 'SEPARATOR', 'SendToRietveld', 'TryChange',
'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 'gclient', 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile',
'gcl_info_dir', 'getpass', 'main', 'os', 'random', 're', 'read_gcl_info', 'gclient', 'getpass', 'main', 'os', 'random', 're', 'read_gcl_info',
'repository_root', 'string', 'subprocess', 'sys', 'tempfile', 'upload', 'repository_root', 'shutil', 'string', 'subprocess', 'sys', 'tempfile',
'urllib2', 'xml', 'upload', 'urllib2', 'xml',
] ]
# If this test fails, you should add the relevant test. # If this test fails, you should add the relevant test.
self.compareMembers(gcl, members) self.compareMembers(gcl, members)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment