DEBUG_COMMANDS = 1 # Show commands as they are executed
DEBUG_PARSE = 2 # Debug logfile parse
+# If true (option -T) use an artificial clock for regression testing
+pseudotime = False
+
def do_or_die(dcmd, legend=b"", loud=False):
"Either execute a command or raise a fatal exception."
if legend:
maxrevno += 1
elif line.startswith("date"):
fields = line.split()
- date = fields[1] + " " + fields[2]
- if date.endswith(";"):
- date = date[:-1]
- date = date.replace("/", "-").replace(" ", "T") + "Z"
+ if pseudotime:
+ # Artificial date one day after the epoch
+ # to avoid timezone issues.
+ date = rfc3339(86400 + len(self) * 60)
+ else:
+ date = fields[1] + " " + fields[2]
+ if date.endswith(";"):
+ date = date[:-1]
+ date = date.replace("/","-").replace(" ","T") + "Z"
self.revlist[-1].date = date
elif line.startswith("======================="):
if not self.revlist[-1].log.endswith("\n"):
if revspec and len(revspec) > 1:
croak("checkout needs an empty or singleton revision spec")
mark = 0
- username = capture_or_die("git config --get user.name").strip()
- useremail = capture_or_die("git config --get user.email").strip()
+ if pseudotime:
+ username = "J. Random Hacker"
+ useremail = "jrh@nowhere.man"
+ else:
+ username = capture_or_die("git config --get user.name").strip()
+ useremail = capture_or_die("git config --get user.email").strip()
attribution = "%s <%s>" % (username, useremail)
for arg in args:
executable = os.stat(arg).st_mode & stat.S_IXUSR
if __name__ == "__main__":
- command = sys.argv[1:]
+ command = list(sys.argv[1:])
+ while command and command[0].startswith("-"):
+ if command[0] == '-d':
+ debug += 1
+ if command[0] == '-T':
+ pseudotime = True
+ command.pop(0)
if not command:
help_method()
else:
- command = list(command)
- while command[0] == "-d":
- debug += 1
- command.pop(0)
try:
apply(dispatch[command[0]], command[1:])
except KeyError:
If no files are specified, all eligible files are operated on in sequence.
A '-d' option before the main command word turns on debugging
-messages; it can be repeated for higher debugging levels.
+messages; it can be repeated for higher debugging levels. A -T option
+sets up an artificial clock that ticks once on each revision and
+fixes the user information to be used in fast-export; it's for
+regression testing.
== DANGER! DANGER! ==
This is a proof-of-concept alpha release. The 'branch' and
esac
}
+TESTOPTS=-T
+
# Catches dumb and obvious case of code having a Python syntax error
-src >>/dev/null 2>&1
+src $TESTOPTS >>/dev/null 2>&1
check "smoke test"
-cat >testfile$$ <<EOF
+cat >testfile1 <<EOF
Now is the time
EOF
-src add testfile$$ >/dev/null
+src $TESTOPTS add testfile1 >/dev/null
check "add"
-src commit -m "First comment" testfile$$ >/dev/null
+src $TESTOPTS commit -m "First comment" testfile1 >/dev/null
check "commit with -m option"
-src cat testfile$$ | diff testfile$$ - >/dev/null
+src $TESTOPTS cat testfile1 | diff testfile1 - >/dev/null
check "content check after first commit"
-cat >testfile$$ <<EOF
+cat >testfile1 <<EOF
Now is the time
for all good men
EOF
-echo "Second comment" | src commit - testfile$$ >/dev/null
+echo "Second comment" | src $TESTOPTS commit - testfile1 >/dev/null
check "commit with -"
-src cat testfile$$ | diff testfile$$ -
+src $TESTOPTS cat testfile1 | diff testfile1 -
check "content check after second commit"
+cat >testfile2 <<EOF
+= testfile1 =====================================================================
+2 * 1970-01-02T00:01:00Z Second comment
+1 - 1970-01-02T00:02:00Z First comment
+EOF
+
+src $TESTOPTS list testfile1 >testfile3
+
+diff testfile2 testfile3
+check "list test"
+
# end