import sys, os, subprocess, time, calendar, stat, glob, shutil, hashlib
-version="0.16"
+version="0.17"
def rfc3339(t):
"RFC3339 string from Unix time."
return self.by_revno_d[revno]
except KeyError:
if revno == 0:
+ raise ValueError
# This case comes up if we try to select the
# tip revision of a history without revisions.
croak("{0} has no revisions".format(self.name))
Amends the stored comment for a specified revision, defaulting to the
latest revision on the current branch. Flags are as for commit.
-src add ['file'...]
- Initialize new project histories for specified files. Creates
- the repository directory if required. This command is not intended
- for human use - commit adds files when necessary. It's a helper
- for Emacs VC mode.
-
src checkout ['revision'] ['file'...]
Refresh the working copies of the file(s) from their history files.
'co' is a synonym for checkout.
except OSError:
croak(" %s creation failed, check directory permissions." % repodir)
args = list(args)
- comment = CommentContext("commit", args)
+ addonly = False
+ while args:
+ if args[0] == '--':
+ args.pop(0)
+ break
+ elif args[0] == '-a':
+ addonly = True
+ args.pop(0)
+ else:
+ break
+ if not addonly:
+ comment = CommentContext("commit", args)
ctx = CommandContext("commit", args,
require_empty=True,
- parse_revspec=comment.parse_revspec)
+ parse_revspec=not addonly and comment.parse_revspec)
for arg in ctx.args:
if not os.path.exists(arg):
croak("I see no '%s' here." % arg)
if os.path.isdir(arg):
croak("cannot commit directory '%s'" % arg)
for arg in ctx.args:
- if registered(arg):
+ if not registered(arg):
+ trailer = "Committing initial revision of {0}".format(arg)
+ revcount = 0
+ elif addonly:
+ croak("attempt to re-add a registeed file failed")
+ else:
metadata = History(arg)
ctx.resolve(metadata)
- if ctx.is_empty():
+ if len(metadata) and ctx.is_empty():
ctx.select_tip(metadata)
trailer = "Committing {0} revision {1}.\n".format(arg, ctx.start)
revcount = len(metadata)
- else:
- trailer = "Committing initial revision of {0}".format(arg)
- revcount = 0
- if not comment.edit(content="", trailer=trailer):
+ if not addonly and not comment.edit(content="", trailer=trailer):
announce("in %s, commit cancelled" % arg)
else:
if not registered(arg):
backend.add(arg)
- with backend.lifter(arg):
- backend.checkin(arg, comment.content())
+ if not addonly:
+ with backend.lifter(arg):
+ backend.checkin(arg, comment.content())
make_stamp(arg)
if not quiet and len(args) > 1:
announce("%s -> %d" % (arg, revcount))
if not quiet and len(args) > 1:
announce("%s : %d" % (arg, ctx.start))
-def add_method(*args):
- "Register a file into src control."
- if not os.path.exists(repodir):
- try:
- os.mkdir(repodir)
- except OSError:
- croak(" %s creation failed, check directory permissions." % repodir)
- ctx = CommandContext("add", args, require_empty=True)
- for arg in ctx.args:
- if not os.path.exists(arg):
- croak("I see no '%s' here." % arg)
- elif os.path.exists(backend.history(arg)):
- croak("%s is already registered." % arg)
- elif os.path.isdir(arg):
- croak("cannot commit directory '%s'" % arg)
- for arg in ctx.args:
- if not os.path.exists(backend.history(arg)):
- backend.add(arg)
- if not quiet and len(ctx.args) > 1:
- announce("%s -> 0" % arg)
-
def list_method(*args):
"Generate a summary listing of commits, one line per commit."
args = list(args)
"ci": commit_method,
"amend": amend_method,
"am": amend_method,
- "add": add_method,
"list": list_method,
"li": list_method,
"log": log_method,