except (TypeError, ValueError):
croak("garbled date %s" % self.date)
+def registered(fn):
+ "Is this a workfile for a registered history?"
+ return os.path.exists(backend.history(fn))
+
class History:
"Encapsulate a revision list and some methods on it"
def __init__(self, name):
self.symbols = {}
self.branch = "trunk"
self.lockrevs = []
- if not os.path.exists(backend.history(self.name)):
+ if not registered(self.name):
croak("%s is not registered" % self.name)
backend.parse(self)
self.by_revno_d = {}
for arg in ctx.args:
if not os.path.exists(arg):
croak("I see no '%s' here." % arg)
- if os.path.exists(backend.history(arg)):
+ if registered(arg):
metadata = History(arg)
ctx.resolve(metadata)
if ctx.is_empty():
if not comment.edit(content="", trailer=trailer):
announce("in %s, commit cancelled" % arg)
else:
- if not os.path.exists(backend.history(arg)):
+ if not registered(arg):
backend.add(arg)
with backend.lifter(arg):
backend.checkin(arg, comment.content())
for arg in ctx.args:
if not os.path.exists(arg):
croak("I see no '%s' here." % arg)
- elif not os.path.exists(backend.history(arg)):
+ elif not registered(arg):
croak("%s is not registered." % arg)
for arg in ctx.args:
metadata = History(arg)
(source, target) = args
if not os.path.exists(source):
croak("I see no '%s' here." % source)
- elif not os.path.exists(backend.history(source)):
+ elif not registered(source):
croak("%s is not registered, skipping" % source)
- elif os.path.exists(backend.history(target)):
+ elif registered(target):
croak("%s is registered, I won't step on it" % source)
elif os.path.exists(target):
croak("%s exists, please delete manually if you want it gone" % target)
for arg in ctx.args:
if not os.path.exists(arg):
croak("I see no '%s' here." % arg)
- elif not os.path.exists(backend.history(arg)):
+ elif not registered(arg):
croak("%s is not registered, skipping" % arg)
else:
with backend.lifter(arg):
useremail = capture_or_die("git config --get user.email").strip()
attribution = "%s <%s>" % (username, useremail)
for arg in ctx.args:
- if not os.path.exists(backend.history(arg)):
+ if not registered(arg):
croak("%s is not registered" % arg)
executable = os.stat(arg).st_mode & stat.S_IXUSR
if executable: