diff options
author | Shawn O. Pearce <sop@google.com> | 2009-03-05 10:32:38 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-03-05 10:32:38 -0800 |
commit | c7a4eefa7e775b64916a66b52ca6c5f31e2cf5c8 (patch) | |
tree | 49451ef2767128c809e48f980766c1a02d6504aa /subcmds/manifest.py | |
parent | 43c3d9ea17f1436a6b3b2e7e7827da6f48a21da9 (diff) | |
download | git-repo-c7a4eefa7e775b64916a66b52ca6c5f31e2cf5c8.tar.gz |
Add repo manifest -o to save a manifestv1.6.2
This can be useful to create a new manifest from an existing client,
especially if the client wants to use the "-r" option to set each
project's revision to the current commit SHA-1, making a sort of a
tag file that can be used to recreate this exact state elsewhere.
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds/manifest.py')
-rw-r--r-- | subcmds/manifest.py | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/subcmds/manifest.py b/subcmds/manifest.py index 69906faa..4374a9d0 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.py | |||
@@ -16,16 +16,21 @@ | |||
16 | import os | 16 | import os |
17 | import sys | 17 | import sys |
18 | 18 | ||
19 | from command import Command | 19 | from command import PagedCommand |
20 | 20 | ||
21 | class Manifest(Command): | 21 | class Manifest(PagedCommand): |
22 | common = False | 22 | common = False |
23 | helpSummary = "Manifest file" | 23 | helpSummary = "Manifest inspection utility" |
24 | helpUsage = """ | 24 | helpUsage = """ |
25 | %prog | 25 | %prog [-o {-|NAME.xml} [-r]] |
26 | """ | 26 | """ |
27 | _helpDescription = """ | 27 | _helpDescription = """ |
28 | The repo manifest file describes the projects mapped into the client. | 28 | |
29 | With the -o option, exports the current manifest for inspection. | ||
30 | The manifest and (if present) local_manifest.xml are combined | ||
31 | together to produce a single manifest file. This file can be stored | ||
32 | in a Git repository for use during future 'repo init' invocations. | ||
33 | |||
29 | """ | 34 | """ |
30 | 35 | ||
31 | @property | 36 | @property |
@@ -39,6 +44,34 @@ The repo manifest file describes the projects mapped into the client. | |||
39 | fd.close() | 44 | fd.close() |
40 | return help | 45 | return help |
41 | 46 | ||
47 | def _Options(self, p): | ||
48 | p.add_option('-r', '--revision-as-HEAD', | ||
49 | dest='peg_rev', action='store_true', | ||
50 | help='Save revisions as current HEAD') | ||
51 | p.add_option('-o', '--output-file', | ||
52 | dest='output_file', | ||
53 | help='File to save the manifest to', | ||
54 | metavar='-|NAME.xml') | ||
55 | |||
56 | def _Output(self, opt): | ||
57 | if opt.output_file == '-': | ||
58 | fd = sys.stdout | ||
59 | else: | ||
60 | fd = open(opt.output_file, 'w') | ||
61 | self.manifest.Save(fd, | ||
62 | peg_rev = opt.peg_rev) | ||
63 | fd.close() | ||
64 | if opt.output_file != '-': | ||
65 | print >>sys.stderr, 'Saved manifest to %s' % opt.output_file | ||
66 | |||
42 | def Execute(self, opt, args): | 67 | def Execute(self, opt, args): |
68 | if args: | ||
69 | self.Usage() | ||
70 | |||
71 | if opt.output_file is not None: | ||
72 | self._Output(opt) | ||
73 | return | ||
74 | |||
75 | print >>sys.stderr, 'error: no operation to perform' | ||
43 | print >>sys.stderr, 'error: see repo help manifest' | 76 | print >>sys.stderr, 'error: see repo help manifest' |
44 | sys.exit(1) | 77 | sys.exit(1) |