mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
df01883f9b | |||
1fc99f4e47 | |||
1775dbe176 | |||
521cd3ce67 | |||
5470df6219 | |||
0ed2bd1d95 | |||
c7a4eefa7e | |||
43c3d9ea17 | |||
4259b8a2ac | |||
2816d4f387 | |||
44469464d2 | |||
c95583bf4f | |||
6a5644d392 | |||
fe08675956 | |||
be0e8ac232 | |||
47c1a63a07 | |||
559b846b17 | |||
7c6c64d463 | |||
3778f9d47e |
@ -114,3 +114,8 @@ class PagedCommand(Command):
|
||||
"""Command which defaults to output in a pager, as its
|
||||
display tends to be larger than one screen full.
|
||||
"""
|
||||
|
||||
class MirrorSafeCommand(object):
|
||||
"""Command permits itself to run within a mirror,
|
||||
and does not require a working directory.
|
||||
"""
|
||||
|
@ -19,39 +19,39 @@ XML File Format
|
||||
A manifest XML file (e.g. 'default.xml') roughly conforms to the
|
||||
following DTD:
|
||||
|
||||
<!DOCTYPE manifest [
|
||||
<!ELEMENT manifest (remote*,
|
||||
default?,
|
||||
remove-project*,
|
||||
project*,
|
||||
add-remote*)>
|
||||
|
||||
<!ELEMENT remote (EMPTY)>
|
||||
<!ATTLIST remote name ID #REQUIRED>
|
||||
<!ATTLIST remote fetch CDATA #REQUIRED>
|
||||
<!ATTLIST remote review CDATA #IMPLIED>
|
||||
<!ATTLIST remote project-name CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT default (EMPTY)>
|
||||
<!ATTLIST default remote IDREF #IMPLIED>
|
||||
<!ATTLIST default revision CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT project (remote*)>
|
||||
<!ATTLIST project name CDATA #REQUIRED>
|
||||
<!ATTLIST project path CDATA #IMPLIED>
|
||||
<!ATTLIST project remote IDREF #IMPLIED>
|
||||
<!ATTLIST project revision CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT add-remote (EMPTY)>
|
||||
<!ATTLIST add-remote to-project ID #REQUIRED>
|
||||
<!ATTLIST add-remote name ID #REQUIRED>
|
||||
<!ATTLIST add-remote fetch CDATA #REQUIRED>
|
||||
<!ATTLIST add-remote review CDATA #IMPLIED>
|
||||
<!ATTLIST add-remote project-name CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT remove-project (EMPTY)>
|
||||
<!ATTLIST remove-project name CDATA #REQUIRED>
|
||||
]>
|
||||
<!DOCTYPE manifest [
|
||||
<!ELEMENT manifest (remote*,
|
||||
default?,
|
||||
remove-project*,
|
||||
project*,
|
||||
add-remote*)>
|
||||
|
||||
<!ELEMENT remote (EMPTY)>
|
||||
<!ATTLIST remote name ID #REQUIRED>
|
||||
<!ATTLIST remote fetch CDATA #REQUIRED>
|
||||
<!ATTLIST remote review CDATA #IMPLIED>
|
||||
<!ATTLIST remote project-name CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT default (EMPTY)>
|
||||
<!ATTLIST default remote IDREF #IMPLIED>
|
||||
<!ATTLIST default revision CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT project (remote*)>
|
||||
<!ATTLIST project name CDATA #REQUIRED>
|
||||
<!ATTLIST project path CDATA #IMPLIED>
|
||||
<!ATTLIST project remote IDREF #IMPLIED>
|
||||
<!ATTLIST project revision CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT add-remote (EMPTY)>
|
||||
<!ATTLIST add-remote to-project ID #REQUIRED>
|
||||
<!ATTLIST add-remote name ID #REQUIRED>
|
||||
<!ATTLIST add-remote fetch CDATA #REQUIRED>
|
||||
<!ATTLIST add-remote review CDATA #IMPLIED>
|
||||
<!ATTLIST add-remote project-name CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT remove-project (EMPTY)>
|
||||
<!ATTLIST remove-project name CDATA #REQUIRED>
|
||||
]>
|
||||
|
||||
A description of the elements and their attributes follows.
|
||||
|
||||
@ -179,16 +179,14 @@ manifest, stored in `$TOP_DIR/.repo/local_manifest.xml`.
|
||||
|
||||
For example:
|
||||
|
||||
----
|
||||
$ cat .repo/local_manifest.xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest>
|
||||
<project path="manifest"
|
||||
name="tools/manifest" />
|
||||
<project path="platform-manifest"
|
||||
name="platform/manifest" />
|
||||
</manifest>
|
||||
----
|
||||
$ cat .repo/local_manifest.xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest>
|
||||
<project path="manifest"
|
||||
name="tools/manifest" />
|
||||
<project path="platform-manifest"
|
||||
name="platform/manifest" />
|
||||
</manifest>
|
||||
|
||||
Users may add projects to the local manifest prior to a `repo sync`
|
||||
invocation, instructing repo to automatically download and manage
|
||||
|
4
error.py
4
error.py
@ -17,6 +17,10 @@ class ManifestParseError(Exception):
|
||||
"""Failed to parse the manifest file.
|
||||
"""
|
||||
|
||||
class ManifestInvalidRevisionError(Exception):
|
||||
"""The revision value in a project is incorrect.
|
||||
"""
|
||||
|
||||
class EditorError(Exception):
|
||||
"""Unspecified error from the user's text editor.
|
||||
"""
|
||||
|
30
main.py
30
main.py
@ -27,8 +27,12 @@ import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from command import InteractiveCommand, PagedCommand
|
||||
import git_command
|
||||
from command import InteractiveCommand
|
||||
from command import MirrorSafeCommand
|
||||
from command import PagedCommand
|
||||
from editor import Editor
|
||||
from error import ManifestInvalidRevisionError
|
||||
from error import NoSuchProjectError
|
||||
from error import RepoChangedException
|
||||
from manifest import Manifest
|
||||
@ -45,6 +49,12 @@ global_options.add_option('-p', '--paginate',
|
||||
global_options.add_option('--no-pager',
|
||||
dest='no_pager', action='store_true',
|
||||
help='disable the pager')
|
||||
global_options.add_option('--trace',
|
||||
dest='trace', action='store_true',
|
||||
help='trace git command execution')
|
||||
global_options.add_option('--version',
|
||||
dest='show_version', action='store_true',
|
||||
help='display this version of repo')
|
||||
|
||||
class _Repo(object):
|
||||
def __init__(self, repodir):
|
||||
@ -68,6 +78,15 @@ class _Repo(object):
|
||||
argv = []
|
||||
gopts, gargs = global_options.parse_args(glob)
|
||||
|
||||
if gopts.trace:
|
||||
git_command.TRACE = True
|
||||
if gopts.show_version:
|
||||
if name == 'help':
|
||||
name = 'version'
|
||||
else:
|
||||
print >>sys.stderr, 'fatal: invalid usage of --version'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
cmd = self.commands[name]
|
||||
except KeyError:
|
||||
@ -80,6 +99,12 @@ class _Repo(object):
|
||||
cmd.manifest = Manifest(cmd.repodir)
|
||||
Editor.globalConfig = cmd.manifest.globalConfig
|
||||
|
||||
if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
|
||||
print >>sys.stderr, \
|
||||
"fatal: '%s' requires a working directory"\
|
||||
% name
|
||||
sys.exit(1)
|
||||
|
||||
if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
|
||||
config = cmd.manifest.globalConfig
|
||||
if gopts.pager:
|
||||
@ -94,6 +119,9 @@ class _Repo(object):
|
||||
copts, cargs = cmd.OptionParser.parse_args(argv)
|
||||
try:
|
||||
cmd.Execute(copts, cargs)
|
||||
except ManifestInvalidRevisionError, e:
|
||||
print >>sys.stderr, 'error: %s' % str(e)
|
||||
sys.exit(1)
|
||||
except NoSuchProjectError, e:
|
||||
if e.name:
|
||||
print >>sys.stderr, 'error: project %s not found' % e.name
|
||||
|
74
manifest.py
74
manifest.py
@ -18,7 +18,7 @@ import sys
|
||||
import xml.dom.minidom
|
||||
|
||||
from git_config import GitConfig, IsId
|
||||
from project import Project, MetaProject, R_HEADS
|
||||
from project import Project, MetaProject, R_HEADS, HEAD
|
||||
from remote import Remote
|
||||
from error import ManifestParseError
|
||||
|
||||
@ -73,6 +73,76 @@ class Manifest(object):
|
||||
except OSError, e:
|
||||
raise ManifestParseError('cannot link manifest %s' % name)
|
||||
|
||||
def _RemoteToXml(self, r, doc, root):
|
||||
e = doc.createElement('remote')
|
||||
root.appendChild(e)
|
||||
e.setAttribute('name', r.name)
|
||||
e.setAttribute('fetch', r.fetchUrl)
|
||||
if r.reviewUrl is not None:
|
||||
e.setAttribute('review', r.reviewUrl)
|
||||
if r.projectName is not None:
|
||||
e.setAttribute('project-name', r.projectName)
|
||||
|
||||
def Save(self, fd, peg_rev=False):
|
||||
"""Write the current manifest out to the given file descriptor.
|
||||
"""
|
||||
doc = xml.dom.minidom.Document()
|
||||
root = doc.createElement('manifest')
|
||||
doc.appendChild(root)
|
||||
|
||||
d = self.default
|
||||
sort_remotes = list(self.remotes.keys())
|
||||
sort_remotes.sort()
|
||||
|
||||
for r in sort_remotes:
|
||||
self._RemoteToXml(self.remotes[r], doc, root)
|
||||
if self.remotes:
|
||||
root.appendChild(doc.createTextNode(''))
|
||||
|
||||
have_default = False
|
||||
e = doc.createElement('default')
|
||||
if d.remote:
|
||||
have_default = True
|
||||
e.setAttribute('remote', d.remote.name)
|
||||
if d.revision:
|
||||
have_default = True
|
||||
e.setAttribute('revision', d.revision)
|
||||
if have_default:
|
||||
root.appendChild(e)
|
||||
root.appendChild(doc.createTextNode(''))
|
||||
|
||||
sort_projects = list(self.projects.keys())
|
||||
sort_projects.sort()
|
||||
|
||||
for p in sort_projects:
|
||||
p = self.projects[p]
|
||||
e = doc.createElement('project')
|
||||
root.appendChild(e)
|
||||
e.setAttribute('name', p.name)
|
||||
if p.relpath != p.name:
|
||||
e.setAttribute('path', p.relpath)
|
||||
if not d.remote or p.remote.name != d.remote.name:
|
||||
e.setAttribute('remote', p.remote.name)
|
||||
if peg_rev:
|
||||
if self.IsMirror:
|
||||
e.setAttribute('revision',
|
||||
p.bare_git.rev_parse(p.revision + '^0'))
|
||||
else:
|
||||
e.setAttribute('revision',
|
||||
p.work_git.rev_parse(HEAD + '^0'))
|
||||
elif not d.revision or p.revision != d.revision:
|
||||
e.setAttribute('revision', p.revision)
|
||||
|
||||
for r in p.extraRemotes:
|
||||
self._RemoteToXml(p.extraRemotes[r], doc, e)
|
||||
for c in p.copyfiles:
|
||||
ce = doc.createElement('copyfile')
|
||||
ce.setAttribute('src', c.src)
|
||||
ce.setAttribute('dest', c.dest)
|
||||
e.appendChild(ce)
|
||||
|
||||
doc.writexml(fd, '', ' ', '\n', 'UTF-8')
|
||||
|
||||
@property
|
||||
def projects(self):
|
||||
self._Load()
|
||||
@ -324,7 +394,7 @@ class Manifest(object):
|
||||
if not self.IsMirror:
|
||||
# src is project relative;
|
||||
# dest is relative to the top of the tree
|
||||
project.AddCopyFile(src, os.path.join(self.topdir, dest))
|
||||
project.AddCopyFile(src, dest, os.path.join(self.topdir, dest))
|
||||
|
||||
def _get_remote(self, node):
|
||||
name = node.getAttribute('remote')
|
||||
|
75
project.py
75
project.py
@ -25,6 +25,7 @@ from color import Coloring
|
||||
from git_command import GitCommand
|
||||
from git_config import GitConfig, IsId
|
||||
from error import GitError, ImportError, UploadError
|
||||
from error import ManifestInvalidRevisionError
|
||||
from remote import Remote
|
||||
|
||||
HEAD = 'HEAD'
|
||||
@ -177,13 +178,15 @@ class DiffColoring(Coloring):
|
||||
|
||||
|
||||
class _CopyFile:
|
||||
def __init__(self, src, dest):
|
||||
def __init__(self, src, dest, abssrc, absdest):
|
||||
self.src = src
|
||||
self.dest = dest
|
||||
self.abs_src = abssrc
|
||||
self.abs_dest = absdest
|
||||
|
||||
def _Copy(self):
|
||||
src = self.src
|
||||
dest = self.dest
|
||||
src = self.abs_src
|
||||
dest = self.abs_dest
|
||||
# copy file if it does not exist or is out of date
|
||||
if not os.path.exists(dest) or not filecmp.cmp(src, dest):
|
||||
try:
|
||||
@ -357,7 +360,7 @@ class Project(object):
|
||||
else: f_status = '-'
|
||||
|
||||
if i and i.src_path:
|
||||
line = ' %s%s\t%s => (%s%%)' % (i_status, f_status,
|
||||
line = ' %s%s\t%s => %s (%s%%)' % (i_status, f_status,
|
||||
i.src_path, p, i.level)
|
||||
else:
|
||||
line = ' %s%s\t%s' % (i_status, f_status, p)
|
||||
@ -528,7 +531,6 @@ class Project(object):
|
||||
return False
|
||||
|
||||
if self.worktree:
|
||||
self._RepairAndroidImportErrors()
|
||||
self._InitMRef()
|
||||
else:
|
||||
self._InitMirrorHead()
|
||||
@ -545,30 +547,6 @@ class Project(object):
|
||||
for file in self.copyfiles:
|
||||
file._Copy()
|
||||
|
||||
def _RepairAndroidImportErrors(self):
|
||||
if self.name in ['platform/external/iptables',
|
||||
'platform/external/libpcap',
|
||||
'platform/external/tcpdump',
|
||||
'platform/external/webkit',
|
||||
'platform/system/wlan/ti']:
|
||||
# I hate myself for doing this...
|
||||
#
|
||||
# In the initial Android 1.0 release these projects were
|
||||
# shipped, some users got them, and then the history had
|
||||
# to be rewritten to correct problems with their imports.
|
||||
# The 'android-1.0' tag may still be pointing at the old
|
||||
# history, so we need to drop the tag and fetch it again.
|
||||
#
|
||||
try:
|
||||
remote = self.GetRemote(self.remote.name)
|
||||
relname = remote.ToLocal(R_HEADS + 'release-1.0')
|
||||
tagname = R_TAGS + 'android-1.0'
|
||||
if self._revlist(not_rev(relname), tagname):
|
||||
cmd = ['fetch', remote.name, '+%s:%s' % (tagname, tagname)]
|
||||
GitCommand(self, cmd, bare = True).Wait()
|
||||
except GitError:
|
||||
pass
|
||||
|
||||
def Sync_LocalHalf(self):
|
||||
"""Perform only the local IO portion of the sync process.
|
||||
Network access is not required.
|
||||
@ -582,6 +560,12 @@ class Project(object):
|
||||
|
||||
rem = self.GetRemote(self.remote.name)
|
||||
rev = rem.ToLocal(self.revision)
|
||||
try:
|
||||
self.bare_git.rev_parse('--verify', '%s^0' % rev)
|
||||
except GitError:
|
||||
raise ManifestInvalidRevisionError(
|
||||
'revision %s in %s not found' % (self.revision, self.name))
|
||||
|
||||
branch = self.CurrentBranch
|
||||
|
||||
if branch is None:
|
||||
@ -709,11 +693,11 @@ class Project(object):
|
||||
self._CopyFiles()
|
||||
return True
|
||||
|
||||
def AddCopyFile(self, src, dest):
|
||||
def AddCopyFile(self, src, dest, absdest):
|
||||
# dest should already be an absolute path, but src is project relative
|
||||
# make src an absolute path
|
||||
src = os.path.join(self.worktree, src)
|
||||
self.copyfiles.append(_CopyFile(src, dest))
|
||||
abssrc = os.path.join(self.worktree, src)
|
||||
self.copyfiles.append(_CopyFile(src, dest, abssrc, absdest))
|
||||
|
||||
def DownloadPatchSet(self, change_id, patch_id):
|
||||
"""Download a single patch set of a single change to FETCH_HEAD.
|
||||
@ -770,7 +754,8 @@ class Project(object):
|
||||
"""
|
||||
cb = self.CurrentBranch
|
||||
kill = []
|
||||
for name in self._allrefs.keys():
|
||||
left = self._allrefs
|
||||
for name in left.keys():
|
||||
if name.startswith(R_HEADS):
|
||||
name = name[len(R_HEADS):]
|
||||
if cb is None or name != cb:
|
||||
@ -783,14 +768,12 @@ class Project(object):
|
||||
self.work_git.DetachHead(HEAD)
|
||||
kill.append(cb)
|
||||
|
||||
deleted = set()
|
||||
if kill:
|
||||
try:
|
||||
old = self.bare_git.GetHead()
|
||||
except GitError:
|
||||
old = 'refs/heads/please_never_use_this_as_a_branch_name'
|
||||
|
||||
rm_re = re.compile(r"^Deleted branch (.*)\.$")
|
||||
try:
|
||||
self.bare_git.DetachHead(rev)
|
||||
|
||||
@ -802,22 +785,20 @@ class Project(object):
|
||||
b.Wait()
|
||||
finally:
|
||||
self.bare_git.SetHead(old)
|
||||
left = self._allrefs
|
||||
|
||||
for line in b.stdout.split("\n"):
|
||||
m = rm_re.match(line)
|
||||
if m:
|
||||
deleted.add(m.group(1))
|
||||
|
||||
if deleted:
|
||||
self.CleanPublishedCache()
|
||||
for branch in kill:
|
||||
if (R_HEADS + branch) not in left:
|
||||
self.CleanPublishedCache()
|
||||
break
|
||||
|
||||
if cb and cb not in kill:
|
||||
kill.append(cb)
|
||||
kill.sort()
|
||||
kill.sort()
|
||||
|
||||
kept = []
|
||||
for branch in kill:
|
||||
if branch not in deleted:
|
||||
if (R_HEADS + branch) in left:
|
||||
branch = self.GetBranch(branch)
|
||||
base = branch.LocalMerge
|
||||
if not base:
|
||||
@ -872,7 +853,11 @@ class Project(object):
|
||||
if not os.path.exists(self.gitdir):
|
||||
os.makedirs(self.gitdir)
|
||||
self.bare_git.init()
|
||||
self.config.SetString('core.bare', None)
|
||||
|
||||
if self.manifest.IsMirror:
|
||||
self.config.SetString('core.bare', 'true')
|
||||
else:
|
||||
self.config.SetString('core.bare', None)
|
||||
|
||||
hooks = self._gitdir_path('hooks')
|
||||
try:
|
||||
|
@ -17,9 +17,9 @@ import re
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from command import Command
|
||||
from command import Command, MirrorSafeCommand
|
||||
|
||||
class Forall(Command):
|
||||
class Forall(Command, MirrorSafeCommand):
|
||||
common = False
|
||||
helpSummary = "Run a shell command in each project"
|
||||
helpUsage = """
|
||||
@ -30,10 +30,22 @@ Executes the same shell command in each project.
|
||||
|
||||
Environment
|
||||
-----------
|
||||
pwd is the project's working directory.
|
||||
pwd is the project's working directory. If the current client is
|
||||
a mirror client, then pwd is the Git repository.
|
||||
|
||||
REPO_PROJECT is set to the unique name of the project.
|
||||
|
||||
REPO_PATH is the path relative the the root of the client.
|
||||
|
||||
REPO_REMOTE is the name of the remote system from the manifest.
|
||||
|
||||
REPO_LREV is the name of the revision from the manifest, translated
|
||||
to a local tracking branch. If you need to pass the manifest
|
||||
revision to a locally executed git command, use REPO_LREV.
|
||||
|
||||
REPO_RREV is the name of the revision from the manifest, exactly
|
||||
as written in the manifest.
|
||||
|
||||
shell positional arguments ($1, $2, .., $#) are set to any arguments
|
||||
following <command>.
|
||||
|
||||
@ -66,13 +78,31 @@ not redirected.
|
||||
cmd.append(cmd[0])
|
||||
cmd.extend(opt.command[1:])
|
||||
|
||||
mirror = self.manifest.IsMirror
|
||||
rc = 0
|
||||
for project in self.GetProjects(args):
|
||||
env = dict(os.environ.iteritems())
|
||||
env['REPO_PROJECT'] = project.name
|
||||
def setenv(name, val):
|
||||
if val is None:
|
||||
val = ''
|
||||
env[name] = val
|
||||
|
||||
setenv('REPO_PROJECT', project.name)
|
||||
setenv('REPO_PATH', project.relpath)
|
||||
setenv('REPO_REMOTE', project.remote.name)
|
||||
setenv('REPO_LREV', project\
|
||||
.GetRemote(project.remote.name)\
|
||||
.ToLocal(project.revision))
|
||||
setenv('REPO_RREV', project.revision)
|
||||
|
||||
if mirror:
|
||||
setenv('GIT_DIR', project.gitdir)
|
||||
cwd = project.gitdir
|
||||
else:
|
||||
cwd = project.worktree
|
||||
|
||||
p = subprocess.Popen(cmd,
|
||||
cwd = project.worktree,
|
||||
cwd = cwd,
|
||||
shell = shell,
|
||||
env = env)
|
||||
r = p.wait()
|
||||
|
@ -13,13 +13,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import re
|
||||
import sys
|
||||
from formatter import AbstractFormatter, DumbWriter
|
||||
|
||||
from color import Coloring
|
||||
from command import PagedCommand
|
||||
from command import PagedCommand, MirrorSafeCommand
|
||||
|
||||
class Help(PagedCommand):
|
||||
class Help(PagedCommand, MirrorSafeCommand):
|
||||
common = False
|
||||
helpSummary = "Display detailed help on a command"
|
||||
helpUsage = """
|
||||
@ -77,6 +78,7 @@ The most commonly used repo commands are:
|
||||
print fmt % (name, summary)
|
||||
print """
|
||||
See 'repo help <command>' for more information on a specific command.
|
||||
See 'repo help --all' for a complete list of recognized commands.
|
||||
"""
|
||||
|
||||
def _PrintCommandHelp(self, cmd):
|
||||
@ -105,14 +107,24 @@ See 'repo help <command>' for more information on a specific command.
|
||||
body = body.strip()
|
||||
body = body.replace('%prog', me)
|
||||
|
||||
asciidoc_hdr = re.compile(r'^\n?([^\n]{1,})\n(={2,}|-{2,})$')
|
||||
for para in body.split("\n\n"):
|
||||
if para.startswith(' '):
|
||||
self.write('%s', para)
|
||||
self.nl()
|
||||
self.nl()
|
||||
else:
|
||||
self.wrap.add_flowing_data(para)
|
||||
self.wrap.end_paragraph(1)
|
||||
continue
|
||||
|
||||
m = asciidoc_hdr.match(para)
|
||||
if m:
|
||||
self.heading('%s', m.group(1))
|
||||
self.nl()
|
||||
self.heading('%s', ''.ljust(len(m.group(1)),'-'))
|
||||
self.nl()
|
||||
continue
|
||||
|
||||
self.wrap.add_flowing_data(para)
|
||||
self.wrap.end_paragraph(1)
|
||||
self.wrap.end_paragraph(0)
|
||||
|
||||
out = _Out(self.manifest.globalConfig)
|
||||
|
@ -17,12 +17,12 @@ import os
|
||||
import sys
|
||||
|
||||
from color import Coloring
|
||||
from command import InteractiveCommand
|
||||
from command import InteractiveCommand, MirrorSafeCommand
|
||||
from error import ManifestParseError
|
||||
from remote import Remote
|
||||
from git_command import git, MIN_GIT_VERSION
|
||||
|
||||
class Init(InteractiveCommand):
|
||||
class Init(InteractiveCommand, MirrorSafeCommand):
|
||||
common = True
|
||||
helpSummary = "Initialize repo in the current directory"
|
||||
helpUsage = """
|
||||
@ -89,8 +89,9 @@ default.xml will be used.
|
||||
|
||||
def _SyncManifest(self, opt):
|
||||
m = self.manifest.manifestProject
|
||||
is_new = not m.Exists
|
||||
|
||||
if not m.Exists:
|
||||
if is_new:
|
||||
if not opt.manifest_url:
|
||||
print >>sys.stderr, 'fatal: manifest url (-u) is required.'
|
||||
sys.exit(1)
|
||||
@ -117,11 +118,20 @@ default.xml will be used.
|
||||
r.Save()
|
||||
|
||||
if opt.mirror:
|
||||
m.config.SetString('repo.mirror', 'true')
|
||||
if is_new:
|
||||
m.config.SetString('repo.mirror', 'true')
|
||||
else:
|
||||
print >>sys.stderr, 'fatal: --mirror not supported on existing client'
|
||||
sys.exit(1)
|
||||
|
||||
if not m.Sync_NetworkHalf():
|
||||
r = m.GetRemote(m.remote.name)
|
||||
print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url
|
||||
sys.exit(1)
|
||||
|
||||
m.Sync_NetworkHalf()
|
||||
m.Sync_LocalHalf()
|
||||
m.StartBranch('default')
|
||||
if is_new or m.CurrentBranch is None:
|
||||
m.StartBranch('default')
|
||||
|
||||
def _LinkManifest(self, name):
|
||||
if not name:
|
||||
|
77
subcmds/manifest.py
Normal file
77
subcmds/manifest.py
Normal file
@ -0,0 +1,77 @@
|
||||
#
|
||||
# Copyright (C) 2009 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from command import PagedCommand
|
||||
|
||||
class Manifest(PagedCommand):
|
||||
common = False
|
||||
helpSummary = "Manifest inspection utility"
|
||||
helpUsage = """
|
||||
%prog [-o {-|NAME.xml} [-r]]
|
||||
"""
|
||||
_helpDescription = """
|
||||
|
||||
With the -o option, exports the current manifest for inspection.
|
||||
The manifest and (if present) local_manifest.xml are combined
|
||||
together to produce a single manifest file. This file can be stored
|
||||
in a Git repository for use during future 'repo init' invocations.
|
||||
|
||||
"""
|
||||
|
||||
@property
|
||||
def helpDescription(self):
|
||||
help = self._helpDescription + '\n'
|
||||
r = os.path.dirname(__file__)
|
||||
r = os.path.dirname(r)
|
||||
fd = open(os.path.join(r, 'docs', 'manifest-format.txt'))
|
||||
for line in fd:
|
||||
help += line
|
||||
fd.close()
|
||||
return help
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option('-r', '--revision-as-HEAD',
|
||||
dest='peg_rev', action='store_true',
|
||||
help='Save revisions as current HEAD')
|
||||
p.add_option('-o', '--output-file',
|
||||
dest='output_file',
|
||||
help='File to save the manifest to',
|
||||
metavar='-|NAME.xml')
|
||||
|
||||
def _Output(self, opt):
|
||||
if opt.output_file == '-':
|
||||
fd = sys.stdout
|
||||
else:
|
||||
fd = open(opt.output_file, 'w')
|
||||
self.manifest.Save(fd,
|
||||
peg_rev = opt.peg_rev)
|
||||
fd.close()
|
||||
if opt.output_file != '-':
|
||||
print >>sys.stderr, 'Saved manifest to %s' % opt.output_file
|
||||
|
||||
def Execute(self, opt, args):
|
||||
if args:
|
||||
self.Usage()
|
||||
|
||||
if opt.output_file is not None:
|
||||
self._Output(opt)
|
||||
return
|
||||
|
||||
print >>sys.stderr, 'error: no operation to perform'
|
||||
print >>sys.stderr, 'error: see repo help manifest'
|
||||
sys.exit(1)
|
@ -19,11 +19,11 @@ import subprocess
|
||||
import sys
|
||||
|
||||
from git_command import GIT
|
||||
from command import Command
|
||||
from command import Command, MirrorSafeCommand
|
||||
from error import RepoChangedException, GitError
|
||||
from project import R_HEADS
|
||||
|
||||
class Sync(Command):
|
||||
class Sync(Command, MirrorSafeCommand):
|
||||
common = True
|
||||
helpSummary = "Update working tree to the latest revision"
|
||||
helpUsage = """
|
||||
|
35
subcmds/version.py
Normal file
35
subcmds/version.py
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright (C) 2009 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
from command import Command, MirrorSafeCommand
|
||||
from git_command import git
|
||||
from project import HEAD
|
||||
|
||||
class Version(Command, MirrorSafeCommand):
|
||||
common = False
|
||||
helpSummary = "Display the version of repo"
|
||||
helpUsage = """
|
||||
%prog
|
||||
"""
|
||||
|
||||
def Execute(self, opt, args):
|
||||
rp = self.manifest.repoProject
|
||||
rem = rp.GetRemote(rp.remote.name)
|
||||
|
||||
print 'repo version %s' % rp.work_git.describe(HEAD)
|
||||
print ' (from %s)' % rem.url
|
||||
print git.version().strip()
|
||||
print 'Python %s' % sys.version
|
Reference in New Issue
Block a user