1
# Copyright (C) 2004 Aaron Bentley
2
# <aaron.bentley@utoronto.ca>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
sys.path=[os.path.realpath(os.path.dirname(__file__)+"/..")]+sys.path
26
from pylon.util import tmpdir
27
from pylon import errors
32
__docformat__ = "restructuredtext"
33
__doc__ = "Native show-changeset command"
35
class ShowChangeset(commands.BaseCommand):
36
"""Show the changes made by a changeset"""
38
self.description = self.__doc__
40
def get_completer(self, arg, index):
41
iter_r = cmdutil.iter_revision_completions(arg, arch.tree_root("."))
42
iter_d = cmdutil.iter_dir_completions(arg)
43
return cmdutil.iter_combine([iter_r, iter_d])
46
def do_command(self, cmdargs):
47
parser=self.get_parser()
48
(options, args) = parser.parse_args(cmdargs)
52
tree = arch.tree_root(".")
56
revision = cmdutil.determine_revision_arch(tree, args[0])
57
tempdir = tmpdir(os.getcwd())
59
except errors.CantDetermineRevision:
61
if os.access(args[0], os.X_OK) and os.path.isdir(args[0]):
64
elif os.access(args[0], os.R_OK) and os.path.isfile(args[0]):
65
tempdir = tmpdir(os.getcwd())
66
dirspec = pylon.util.untar_parent(args[0], tempdir)
73
cmdutil.ensure_archive_registered(revision.archive)
74
changeset = revision.get_patch(dir)
76
changeset = arch.Changeset(dirspec)
78
munger = pylon.ChangesetMunger(changeset)
81
for line in pylon.iter_changes(munger):
82
cmdutil.colorize(line)
83
except errors.InvalidChangeset, e:
84
raise errors.CommandFailedWrapper(e)
87
for line in pylon.diff_iter2(munger.changeset):
88
cmdutil.colorize(line)
92
shutil.rmtree(tempdir)
97
parser = cmdutil.CmdOptionParser("fai show-changeset REVISION/DIR")
98
parser.add_option("-d", "--diff", action="store_true",
99
dest="diff", help="Show diffs")
102
def help(self, parser=None):
104
Prints a help message.
106
:param parser: If supplied, the parser to use for generating help. If \
107
not supplied, it is retrieved.
108
:type parser: cmdutil.CmdOptionParser
111
parser=self.get_parser()
115
def add_command(commands):
116
commands["show-changeset"] = ShowChangeset
119
# arch-tag: 04abf5e0-b961-4367-9c47-d2d25f8f0ddb