32
32
def __init__( self ):
37
36
def print_help( self ):
38
print("Usage: " + the.program.name + " revert [--repo=REPO] [--all] [FILE]...")
37
print "Usage: " + the.program.name + " revert [--repo=REPO] [--all] [FILE]..."
40
39
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789
41
print("Revert any local changes to a file in the home directory.")
43
print("This reverts the content of the named files, in the local filesystem, specified")
44
print("relative to the home directory, to its state in the repo. Specifying individual")
45
print("files and directories will revert them (recursively, in the case of")
46
print("directories). Or you can revert all files in your home directory by specifying")
47
print("no files and explicitly using the --all option.")
49
print("To see a list files that can be reverted, type:")
50
print(" " + the.program.name + " status")
53
print(" --all confirm that you want to revert all files")
54
print(" --quiet do not report changes to the home directory")
55
print(" -r, --repo=REPO select the repo to check-out or create (defaults to 'home')")
56
print(" -v, --verbose display information about what is being done")
57
print(" --help display help and exit")
40
print "Revert any local changes to a file in the home directory."
42
print "This reverts the content of the named files, in the local filesystem, specified"
43
print "relative to the home directory, to its state in the repo. Specifying individual"
44
print "files and directories will revert them (recursively, in the case of"
45
print "directories). Or you can revert all files in your home directory by specifying"
46
print "no files and explicitly using the --all option."
48
print "To see a list files that can be reverted, type:"
49
print " " + the.program.name + " status"
52
print " --all confirm that you want to revert all files"
53
print " -r, --repo=REPO select the repo to check-out or create (defaults to 'home')"
54
print " -v, --verbose display information about what is being done"
55
print " --help display help and exit"
61
59
def parse_command_line( self ):
62
60
opts, args = getopt.gnu_getopt(
63
61
sys.argv[ 1: ], "r:v",
64
[ "all", "quiet", "repo=", "verbose", "help" ] )
62
[ "all", "repo=", "verbose", "help" ] )
65
63
for opt, optarg in opts:
68
elif opt == "--quiet":
70
66
elif opt in [ '--repo', '-r' ]:
71
if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
67
if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
72
68
raise the.program.FatalError(
73
69
'invalid repository name: ' + optarg )
75
elif opt in [ '-v', '--verbose' ]:
71
elif opt in [ '--verbose', '-v' ]:
77
73
elif opt == "--help":
80
76
# discard first argument (the command)
108
104
if the.repo.vcs.has_changes():
109
105
raise the.program.FatalError(
110
106
'repo has local changes: %s\n'
111
'Hint: see "%s stage-revert --help"' %
107
'Hint: see "%s stage-revert --help"' %
112
108
( the.repo.name, the.program.name ) )
115
walker = CopyOutWalker( files if files else None, not self.quiet )
111
walker = CopyOutWalker( files if files else None )