2005-06-05 02:16:32 +04:00
|
|
|
# commands.py - command processing for mercurial
|
|
|
|
#
|
|
|
|
# Copyright 2005 Matt Mackall <mpm@selenic.com>
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms
|
|
|
|
# of the GNU General Public License, incorporated herein by reference.
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
from demandload import demandload
|
2005-07-14 18:30:49 +04:00
|
|
|
demandload(globals(), "os re sys signal shutil")
|
2005-08-17 02:53:47 +04:00
|
|
|
demandload(globals(), "fancyopts ui hg util lock")
|
2005-07-06 06:19:01 +04:00
|
|
|
demandload(globals(), "fnmatch hgweb mdiff random signal time traceback")
|
2005-07-27 22:18:44 +04:00
|
|
|
demandload(globals(), "errno socket version struct atexit")
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
class UnknownCommand(Exception):
|
|
|
|
"""Exception raised if command is not in the command table."""
|
2005-06-01 12:25:42 +04:00
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
def filterfiles(filters, files):
|
2005-07-14 13:42:28 +04:00
|
|
|
l = [x for x in files if x in filters]
|
2005-06-01 23:48:34 +04:00
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
for t in filters:
|
2005-07-14 13:42:28 +04:00
|
|
|
if t and t[-1] != "/":
|
|
|
|
t += "/"
|
|
|
|
l += [x for x in files if x.startswith(t)]
|
2005-06-01 23:48:34 +04:00
|
|
|
return l
|
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
def relfilter(repo, files):
|
2005-07-06 06:19:22 +04:00
|
|
|
cwd = repo.getcwd()
|
|
|
|
if cwd:
|
|
|
|
return filterfiles([util.pconvert(cwd)], files)
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
return files
|
2005-06-01 23:48:34 +04:00
|
|
|
|
2005-06-01 12:25:42 +04:00
|
|
|
def relpath(repo, args):
|
2005-07-06 06:19:22 +04:00
|
|
|
cwd = repo.getcwd()
|
|
|
|
if cwd:
|
2005-08-13 03:06:52 +04:00
|
|
|
return [util.normpath(os.path.join(cwd, x)) for x in args]
|
2005-06-01 12:25:42 +04:00
|
|
|
return args
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-08-08 00:43:11 +04:00
|
|
|
def matchpats(repo, cwd, pats = [], opts = {}, head = ''):
|
|
|
|
return util.matcher(repo, cwd, pats or ['.'], opts.get('include'),
|
2005-07-21 21:21:33 +04:00
|
|
|
opts.get('exclude'), head)
|
|
|
|
|
2005-08-03 21:10:48 +04:00
|
|
|
def makewalk(repo, pats, opts, head = ''):
|
2005-07-18 18:54:21 +04:00
|
|
|
cwd = repo.getcwd()
|
2005-08-08 00:43:11 +04:00
|
|
|
files, matchfn = matchpats(repo, cwd, pats, opts, head)
|
2005-08-03 21:10:48 +04:00
|
|
|
def walk():
|
|
|
|
for src, fn in repo.walk(files = files, match = matchfn):
|
2005-08-12 23:16:58 +04:00
|
|
|
yield src, fn, util.pathto(cwd, fn)
|
2005-08-03 21:10:48 +04:00
|
|
|
return files, matchfn, walk()
|
|
|
|
|
|
|
|
def walk(repo, pats, opts, head = ''):
|
|
|
|
files, matchfn, results = makewalk(repo, pats, opts, head)
|
|
|
|
for r in results: yield r
|
2005-07-18 18:54:21 +04:00
|
|
|
|
2005-07-03 06:29:54 +04:00
|
|
|
revrangesep = ':'
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def revrange(ui, repo, revs, revlog=None):
|
2005-07-03 06:29:54 +04:00
|
|
|
if revlog is None:
|
|
|
|
revlog = repo.changelog
|
|
|
|
revcount = revlog.count()
|
|
|
|
def fix(val, defval):
|
2005-07-14 13:42:28 +04:00
|
|
|
if not val:
|
|
|
|
return defval
|
2005-07-03 06:29:54 +04:00
|
|
|
try:
|
|
|
|
num = int(val)
|
2005-07-14 13:42:28 +04:00
|
|
|
if str(num) != val:
|
|
|
|
raise ValueError
|
|
|
|
if num < 0:
|
|
|
|
num += revcount
|
2005-07-03 06:29:54 +04:00
|
|
|
if not (0 <= num < revcount):
|
|
|
|
raise ValueError
|
|
|
|
except ValueError:
|
|
|
|
try:
|
|
|
|
num = repo.changelog.rev(repo.lookup(val))
|
|
|
|
except KeyError:
|
|
|
|
try:
|
|
|
|
num = revlog.rev(revlog.lookup(val))
|
|
|
|
except KeyError:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort('invalid revision identifier %s', val)
|
2005-07-03 06:29:54 +04:00
|
|
|
return num
|
|
|
|
for spec in revs:
|
|
|
|
if spec.find(revrangesep) >= 0:
|
|
|
|
start, end = spec.split(revrangesep, 1)
|
|
|
|
start = fix(start, 0)
|
|
|
|
end = fix(end, revcount - 1)
|
|
|
|
if end > start:
|
|
|
|
end += 1
|
|
|
|
step = 1
|
|
|
|
else:
|
|
|
|
end -= 1
|
|
|
|
step = -1
|
|
|
|
for rev in xrange(start, end, step):
|
|
|
|
yield str(rev)
|
|
|
|
else:
|
|
|
|
yield spec
|
|
|
|
|
2005-07-20 16:08:11 +04:00
|
|
|
def make_filename(repo, r, pat, node=None,
|
|
|
|
total=None, seqno=None, revwidth=None):
|
2005-07-06 06:23:56 +04:00
|
|
|
node_expander = {
|
|
|
|
'H': lambda: hg.hex(node),
|
|
|
|
'R': lambda: str(r.rev(node)),
|
|
|
|
'h': lambda: hg.short(node),
|
|
|
|
}
|
|
|
|
expander = {
|
|
|
|
'%': lambda: '%',
|
|
|
|
'b': lambda: os.path.basename(repo.root),
|
|
|
|
}
|
|
|
|
|
2005-07-19 19:42:36 +04:00
|
|
|
try:
|
|
|
|
if node:
|
|
|
|
expander.update(node_expander)
|
|
|
|
if node and revwidth is not None:
|
|
|
|
expander['r'] = lambda: str(r.rev(node)).zfill(revwidth)
|
|
|
|
if total is not None:
|
|
|
|
expander['N'] = lambda: str(total)
|
|
|
|
if seqno is not None:
|
|
|
|
expander['n'] = lambda: str(seqno)
|
|
|
|
if total is not None and seqno is not None:
|
|
|
|
expander['n'] = lambda:str(seqno).zfill(len(str(total)))
|
|
|
|
|
|
|
|
newname = []
|
|
|
|
patlen = len(pat)
|
|
|
|
i = 0
|
|
|
|
while i < patlen:
|
2005-07-06 06:23:56 +04:00
|
|
|
c = pat[i]
|
2005-07-19 19:42:36 +04:00
|
|
|
if c == '%':
|
|
|
|
i += 1
|
|
|
|
c = pat[i]
|
|
|
|
c = expander[c]()
|
|
|
|
newname.append(c)
|
|
|
|
i += 1
|
2005-07-20 16:08:11 +04:00
|
|
|
return ''.join(newname)
|
2005-07-19 19:42:36 +04:00
|
|
|
except KeyError, inst:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort("invalid format spec '%%%s' in output file name",
|
2005-07-19 19:42:36 +04:00
|
|
|
inst.args[0])
|
2005-07-06 06:23:56 +04:00
|
|
|
|
2005-07-20 16:08:11 +04:00
|
|
|
def make_file(repo, r, pat, node=None,
|
|
|
|
total=None, seqno=None, revwidth=None, mode='wb'):
|
|
|
|
if not pat or pat == '-':
|
|
|
|
if 'w' in mode: return sys.stdout
|
|
|
|
else: return sys.stdin
|
|
|
|
if hasattr(pat, 'write') and 'w' in mode:
|
|
|
|
return pat
|
|
|
|
if hasattr(pat, 'read') and 'r' in mode:
|
|
|
|
return pat
|
|
|
|
return open(make_filename(repo, r, pat, node, total, seqno, revwidth),
|
|
|
|
mode)
|
|
|
|
|
2005-08-15 08:09:32 +04:00
|
|
|
def dodiff(fp, ui, repo, files=None, node1=None, node2=None, match=util.always, changes=None):
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
def date(c):
|
|
|
|
return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
|
|
|
|
|
2005-08-15 08:09:32 +04:00
|
|
|
if not changes:
|
|
|
|
(c, a, d, u) = repo.changes(node1, node2, files, match = match)
|
|
|
|
else:
|
|
|
|
(c, a, d, u) = changes
|
2005-07-01 09:28:18 +04:00
|
|
|
if files:
|
|
|
|
c, a, d = map(lambda x: filterfiles(files, x), (c, a, d))
|
|
|
|
|
|
|
|
if not c and not a and not d:
|
|
|
|
return
|
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
if node2:
|
|
|
|
change = repo.changelog.read(node2)
|
|
|
|
mmap2 = repo.manifest.read(change[0])
|
|
|
|
date2 = date(change)
|
2005-07-14 13:42:28 +04:00
|
|
|
def read(f):
|
|
|
|
return repo.file(f).read(mmap2[f])
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
else:
|
|
|
|
date2 = time.asctime()
|
|
|
|
if not node1:
|
|
|
|
node1 = repo.dirstate.parents()[0]
|
2005-07-14 13:42:28 +04:00
|
|
|
def read(f):
|
|
|
|
return repo.wfile(f).read()
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-06-17 23:37:23 +04:00
|
|
|
if ui.quiet:
|
|
|
|
r = None
|
|
|
|
else:
|
|
|
|
hexfunc = ui.verbose and hg.hex or hg.short
|
|
|
|
r = [hexfunc(node) for node in [node1, node2] if node]
|
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
change = repo.changelog.read(node1)
|
|
|
|
mmap = repo.manifest.read(change[0])
|
|
|
|
date1 = date(change)
|
|
|
|
|
|
|
|
for f in c:
|
2005-06-08 08:06:05 +04:00
|
|
|
to = None
|
|
|
|
if f in mmap:
|
|
|
|
to = repo.file(f).read(mmap[f])
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
tn = read(f)
|
2005-07-03 06:29:54 +04:00
|
|
|
fp.write(mdiff.unidiff(to, date1, tn, date2, f, r))
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
for f in a:
|
2005-06-06 22:51:09 +04:00
|
|
|
to = None
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
tn = read(f)
|
2005-07-03 06:29:54 +04:00
|
|
|
fp.write(mdiff.unidiff(to, date1, tn, date2, f, r))
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
for f in d:
|
|
|
|
to = repo.file(f).read(mmap[f])
|
2005-06-06 22:51:09 +04:00
|
|
|
tn = None
|
2005-07-03 06:29:54 +04:00
|
|
|
fp.write(mdiff.unidiff(to, date1, tn, date2, f, r))
|
2005-06-13 11:49:21 +04:00
|
|
|
|
2005-08-15 00:23:45 +04:00
|
|
|
def show_changeset(ui, repo, rev=0, changenode=None, filelog=None, brinfo=None):
|
2005-06-13 11:49:21 +04:00
|
|
|
"""show a single changeset or file revision"""
|
|
|
|
changelog = repo.changelog
|
|
|
|
if filelog:
|
|
|
|
log = filelog
|
|
|
|
filerev = rev
|
|
|
|
node = filenode = filelog.node(filerev)
|
|
|
|
changerev = filelog.linkrev(filenode)
|
|
|
|
changenode = changenode or changelog.node(changerev)
|
|
|
|
else:
|
|
|
|
log = changelog
|
2005-06-14 11:01:18 +04:00
|
|
|
changerev = rev
|
2005-06-13 11:49:21 +04:00
|
|
|
if changenode is None:
|
|
|
|
changenode = changelog.node(changerev)
|
|
|
|
elif not changerev:
|
|
|
|
rev = changerev = changelog.rev(changenode)
|
|
|
|
node = changenode
|
|
|
|
|
|
|
|
if ui.quiet:
|
2005-08-17 03:50:42 +04:00
|
|
|
ui.write("%d:%s\n" % (rev, hg.short(node)))
|
2005-06-13 11:49:21 +04:00
|
|
|
return
|
|
|
|
|
|
|
|
changes = changelog.read(changenode)
|
|
|
|
|
2005-07-27 20:14:52 +04:00
|
|
|
parents = [(log.rev(p), ui.verbose and hg.hex(p) or hg.short(p))
|
|
|
|
for p in log.parents(node)
|
|
|
|
if ui.debugflag or p != hg.nullid]
|
2005-06-13 11:49:21 +04:00
|
|
|
if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1:
|
|
|
|
parents = []
|
|
|
|
|
2005-07-27 20:14:52 +04:00
|
|
|
if ui.verbose:
|
|
|
|
ui.write("changeset: %d:%s\n" % (changerev, hg.hex(changenode)))
|
|
|
|
else:
|
|
|
|
ui.write("changeset: %d:%s\n" % (changerev, hg.short(changenode)))
|
|
|
|
|
2005-07-13 08:55:42 +04:00
|
|
|
for tag in repo.nodetags(changenode):
|
|
|
|
ui.status("tag: %s\n" % tag)
|
|
|
|
for parent in parents:
|
|
|
|
ui.write("parent: %d:%s\n" % parent)
|
2005-06-13 11:49:21 +04:00
|
|
|
if filelog:
|
2005-07-13 08:55:42 +04:00
|
|
|
ui.debug("file rev: %d:%s\n" % (filerev, hg.hex(filenode)))
|
2005-07-27 20:14:52 +04:00
|
|
|
|
2005-08-15 00:23:45 +04:00
|
|
|
if brinfo and changenode in brinfo:
|
|
|
|
br = brinfo[changenode]
|
|
|
|
ui.write("branch: %s\n" % " ".join(br))
|
|
|
|
|
2005-07-27 20:14:52 +04:00
|
|
|
ui.debug("manifest: %d:%s\n" % (repo.manifest.rev(changes[0]),
|
2005-07-13 08:55:42 +04:00
|
|
|
hg.hex(changes[0])))
|
2005-06-13 11:49:21 +04:00
|
|
|
ui.status("user: %s\n" % changes[1])
|
|
|
|
ui.status("date: %s\n" % time.asctime(
|
|
|
|
time.localtime(float(changes[2].split(' ')[0]))))
|
2005-07-27 20:14:52 +04:00
|
|
|
|
2005-06-28 09:50:28 +04:00
|
|
|
if ui.debugflag:
|
2005-07-01 08:54:01 +04:00
|
|
|
files = repo.changes(changelog.parents(changenode)[0], changenode)
|
2005-06-27 09:17:28 +04:00
|
|
|
for key, value in zip(["files:", "files+:", "files-:"], files):
|
|
|
|
if value:
|
|
|
|
ui.note("%-12s %s\n" % (key, " ".join(value)))
|
2005-06-28 09:50:28 +04:00
|
|
|
else:
|
|
|
|
ui.note("files: %s\n" % " ".join(changes[3]))
|
2005-07-27 20:14:52 +04:00
|
|
|
|
2005-06-14 11:01:18 +04:00
|
|
|
description = changes[4].strip()
|
2005-06-13 11:49:21 +04:00
|
|
|
if description:
|
2005-06-14 06:36:40 +04:00
|
|
|
if ui.verbose:
|
|
|
|
ui.status("description:\n")
|
2005-06-14 11:01:18 +04:00
|
|
|
ui.status(description)
|
2005-07-01 10:40:32 +04:00
|
|
|
ui.status("\n\n")
|
2005-06-14 06:36:40 +04:00
|
|
|
else:
|
2005-06-14 11:01:18 +04:00
|
|
|
ui.status("summary: %s\n" % description.splitlines()[0])
|
2005-06-13 11:49:21 +04:00
|
|
|
ui.status("\n")
|
|
|
|
|
2005-06-25 12:16:39 +04:00
|
|
|
def show_version(ui):
|
2005-06-18 19:32:41 +04:00
|
|
|
"""output version and copyright information"""
|
2005-08-06 18:43:12 +04:00
|
|
|
ui.write("Mercurial Distributed SCM (version %s)\n"
|
|
|
|
% version.get_version())
|
2005-06-18 19:32:41 +04:00
|
|
|
ui.status(
|
|
|
|
"\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n"
|
|
|
|
"This is free software; see the source for copying conditions. "
|
|
|
|
"There is NO\nwarranty; "
|
|
|
|
"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
|
|
|
|
)
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def help_(ui, cmd=None):
|
|
|
|
"""show help for a given command or all commands"""
|
2005-08-06 16:27:31 +04:00
|
|
|
if cmd and cmd != 'shortlist':
|
2005-08-06 18:43:12 +04:00
|
|
|
key, i = find(cmd)
|
|
|
|
# synopsis
|
2005-08-06 17:04:59 +04:00
|
|
|
ui.write("%s\n\n" % i[2])
|
|
|
|
|
2005-08-06 18:43:12 +04:00
|
|
|
# description
|
|
|
|
doc = i[0].__doc__
|
|
|
|
if ui.quiet:
|
|
|
|
doc = doc.splitlines(0)[0]
|
|
|
|
ui.write("%s\n" % doc.rstrip())
|
|
|
|
|
|
|
|
# aliases
|
|
|
|
if not ui.quiet:
|
|
|
|
aliases = ', '.join(key.split('|')[1:])
|
|
|
|
if aliases:
|
|
|
|
ui.write("\naliases: %s\n" % aliases)
|
|
|
|
|
|
|
|
# options
|
|
|
|
if not ui.quiet and i[1]:
|
|
|
|
ui.write("\noptions:\n\n")
|
2005-08-06 17:04:59 +04:00
|
|
|
for s, l, d, c in i[1]:
|
|
|
|
opt = ' '
|
|
|
|
if s:
|
|
|
|
opt = opt + '-' + s + ' '
|
|
|
|
if l:
|
|
|
|
opt = opt + '--' + l + ' '
|
|
|
|
if d:
|
|
|
|
opt = opt + '(' + str(d) + ')'
|
|
|
|
ui.write(opt, "\n")
|
|
|
|
if c:
|
|
|
|
ui.write(' %s\n' % c)
|
|
|
|
|
2005-06-05 07:09:00 +04:00
|
|
|
else:
|
2005-08-06 18:43:12 +04:00
|
|
|
# program name
|
2005-07-03 15:58:05 +04:00
|
|
|
if ui.verbose:
|
2005-06-25 12:16:39 +04:00
|
|
|
show_version(ui)
|
2005-07-03 15:58:05 +04:00
|
|
|
else:
|
2005-08-06 18:43:12 +04:00
|
|
|
ui.status("Mercurial Distributed SCM\n")
|
|
|
|
ui.status('\n')
|
2005-08-06 16:27:31 +04:00
|
|
|
|
2005-08-06 18:43:12 +04:00
|
|
|
# list of commands
|
2005-08-06 16:27:31 +04:00
|
|
|
if cmd == "shortlist":
|
2005-08-06 18:43:12 +04:00
|
|
|
ui.status('basic commands (use "hg help" '
|
|
|
|
'for the full list or option "-v" for details):\n\n')
|
|
|
|
elif ui.verbose:
|
|
|
|
ui.status('list of commands:\n\n')
|
|
|
|
else:
|
|
|
|
ui.status('list of commands (use "hg help -v" '
|
|
|
|
'to show aliases and global options):\n\n')
|
2005-06-05 07:09:00 +04:00
|
|
|
|
|
|
|
h = {}
|
2005-08-06 16:27:31 +04:00
|
|
|
cmds = {}
|
2005-06-26 17:14:04 +04:00
|
|
|
for c, e in table.items():
|
|
|
|
f = c.split("|")[0]
|
2005-08-06 16:27:31 +04:00
|
|
|
if cmd == "shortlist" and not f.startswith("^"):
|
2005-07-03 15:58:05 +04:00
|
|
|
continue
|
2005-08-06 18:43:12 +04:00
|
|
|
f = f.lstrip("^")
|
2005-07-03 15:58:05 +04:00
|
|
|
if not ui.debugflag and f.startswith("debug"):
|
2005-06-26 17:14:04 +04:00
|
|
|
continue
|
2005-06-05 07:09:00 +04:00
|
|
|
d = ""
|
2005-06-25 12:16:39 +04:00
|
|
|
if e[0].__doc__:
|
|
|
|
d = e[0].__doc__.splitlines(0)[0].rstrip()
|
|
|
|
h[f] = d
|
2005-08-06 16:27:31 +04:00
|
|
|
cmds[f]=c.lstrip("^")
|
2005-06-05 07:09:00 +04:00
|
|
|
|
|
|
|
fns = h.keys()
|
|
|
|
fns.sort()
|
|
|
|
m = max(map(len, fns))
|
|
|
|
for f in fns:
|
2005-08-06 16:27:31 +04:00
|
|
|
if ui.verbose:
|
|
|
|
commands = cmds[f].replace("|",", ")
|
|
|
|
ui.write(" %s:\n %s\n"%(commands,h[f]))
|
|
|
|
else:
|
|
|
|
ui.write(' %-*s %s\n' % (m, f, h[f]))
|
2005-06-05 07:09:00 +04:00
|
|
|
|
2005-08-06 18:43:12 +04:00
|
|
|
# global options
|
|
|
|
if ui.verbose:
|
|
|
|
ui.write("\nglobal options:\n\n")
|
|
|
|
for s, l, d, c in globalopts:
|
|
|
|
opt = ' '
|
|
|
|
if s:
|
|
|
|
opt = opt + '-' + s + ' '
|
|
|
|
if l:
|
|
|
|
opt = opt + '--' + l + ' '
|
|
|
|
if d:
|
|
|
|
opt = opt + '(' + str(d) + ')'
|
|
|
|
ui.write(opt, "\n")
|
|
|
|
if c:
|
|
|
|
ui.write(' %s\n' % c)
|
2005-06-05 07:09:00 +04:00
|
|
|
|
|
|
|
# Commands start here, listed alphabetically
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-18 18:54:21 +04:00
|
|
|
def add(ui, repo, *pats, **opts):
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
'''add the specified files on the next commit'''
|
2005-07-18 18:54:21 +04:00
|
|
|
names = []
|
|
|
|
q = dict(zip(pats, pats))
|
2005-07-19 19:15:59 +04:00
|
|
|
for src, abs, rel in walk(repo, pats, opts):
|
2005-07-18 18:54:21 +04:00
|
|
|
if rel in q or abs in q:
|
|
|
|
names.append(abs)
|
|
|
|
elif repo.dirstate.state(abs) == '?':
|
|
|
|
ui.status('adding %s\n' % rel)
|
|
|
|
names.append(abs)
|
|
|
|
repo.add(names)
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-23 07:45:48 +04:00
|
|
|
def addremove(ui, repo, *pats, **opts):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""add all new files, delete all missing files"""
|
2005-07-23 07:45:48 +04:00
|
|
|
q = dict(zip(pats, pats))
|
2005-07-29 20:42:28 +04:00
|
|
|
add, remove = [], []
|
|
|
|
for src, abs, rel in walk(repo, pats, opts):
|
2005-08-12 19:12:08 +04:00
|
|
|
if src == 'f' and repo.dirstate.state(abs) == '?':
|
|
|
|
add.append(abs)
|
|
|
|
if rel not in q: ui.status('adding ', rel, '\n')
|
|
|
|
if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
|
2005-07-29 20:42:28 +04:00
|
|
|
remove.append(abs)
|
|
|
|
if rel not in q: ui.status('removing ', rel, '\n')
|
|
|
|
repo.add(add)
|
|
|
|
repo.remove(remove)
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-20 15:23:12 +04:00
|
|
|
def annotate(ui, repo, *pats, **opts):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""show changeset information per file line"""
|
2005-06-01 12:25:42 +04:00
|
|
|
def getnode(rev):
|
|
|
|
return hg.short(repo.changelog.node(rev))
|
|
|
|
|
|
|
|
def getname(rev):
|
|
|
|
try:
|
|
|
|
return bcache[rev]
|
|
|
|
except KeyError:
|
|
|
|
cl = repo.changelog.read(repo.changelog.node(rev))
|
|
|
|
name = cl[1]
|
|
|
|
f = name.find('@')
|
|
|
|
if f >= 0:
|
|
|
|
name = name[:f]
|
2005-06-30 21:22:59 +04:00
|
|
|
f = name.find('<')
|
|
|
|
if f >= 0:
|
|
|
|
name = name[f+1:]
|
2005-06-01 12:25:42 +04:00
|
|
|
bcache[rev] = name
|
|
|
|
return name
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-07-21 21:22:54 +04:00
|
|
|
if not pats:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort('at least one file name or pattern required')
|
2005-07-21 21:22:54 +04:00
|
|
|
|
2005-06-01 12:25:42 +04:00
|
|
|
bcache = {}
|
|
|
|
opmap = [['user', getname], ['number', str], ['changeset', getnode]]
|
2005-07-16 10:56:39 +04:00
|
|
|
if not opts['user'] and not opts['changeset']:
|
|
|
|
opts['number'] = 1
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-16 10:58:56 +04:00
|
|
|
if opts['rev']:
|
|
|
|
node = repo.changelog.lookup(opts['rev'])
|
2005-07-16 10:56:39 +04:00
|
|
|
else:
|
|
|
|
node = repo.dirstate.parents()[0]
|
2005-06-01 12:25:42 +04:00
|
|
|
change = repo.changelog.read(node)
|
|
|
|
mmap = repo.manifest.read(change[0])
|
2005-07-21 21:22:54 +04:00
|
|
|
for src, abs, rel in walk(repo, pats, opts):
|
2005-07-23 23:11:49 +04:00
|
|
|
if abs not in mmap:
|
|
|
|
ui.warn("warning: %s is not in the repository!\n" % rel)
|
|
|
|
continue
|
|
|
|
|
2005-07-20 15:23:12 +04:00
|
|
|
lines = repo.file(abs).annotate(mmap[abs])
|
2005-06-01 12:25:42 +04:00
|
|
|
pieces = []
|
|
|
|
|
|
|
|
for o, f in opmap:
|
2005-07-16 10:56:39 +04:00
|
|
|
if opts[o]:
|
2005-07-14 13:42:28 +04:00
|
|
|
l = [f(n) for n, dummy in lines]
|
2005-07-23 23:11:49 +04:00
|
|
|
if l:
|
|
|
|
m = max(map(len, l))
|
|
|
|
pieces.append(["%*s" % (m, x) for x in l])
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-23 23:11:49 +04:00
|
|
|
if pieces:
|
|
|
|
for p, l in zip(zip(*pieces), lines):
|
|
|
|
ui.write("%s: %s" % (" ".join(p), l[1]))
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def cat(ui, repo, file1, rev=None, **opts):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""output the latest or given revision of a file"""
|
2005-07-14 13:42:28 +04:00
|
|
|
r = repo.file(relpath(repo, [file1])[0])
|
|
|
|
if rev:
|
2005-08-17 03:22:44 +04:00
|
|
|
try:
|
|
|
|
# assume all revision numbers are for changesets
|
|
|
|
n = repo.lookup(rev)
|
|
|
|
change = repo.changelog.read(n)
|
|
|
|
m = repo.manifest.read(change[0])
|
|
|
|
n = m[relpath(repo, [file1])[0]]
|
|
|
|
except hg.RepoError, KeyError:
|
|
|
|
n = r.lookup(rev)
|
2005-07-14 13:42:28 +04:00
|
|
|
else:
|
|
|
|
n = r.tip()
|
2005-07-20 14:48:16 +04:00
|
|
|
fp = make_file(repo, r, opts['output'], node=n)
|
2005-07-06 06:23:56 +04:00
|
|
|
fp.write(r.read(n))
|
2005-06-05 01:45:31 +04:00
|
|
|
|
2005-07-14 18:30:49 +04:00
|
|
|
def clone(ui, source, dest=None, **opts):
|
2005-06-27 03:20:46 +04:00
|
|
|
"""make a copy of an existing repository"""
|
|
|
|
if dest is None:
|
2005-06-30 09:55:25 +04:00
|
|
|
dest = os.path.basename(os.path.normpath(source))
|
2005-06-30 20:47:31 +04:00
|
|
|
|
|
|
|
if os.path.exists(dest):
|
|
|
|
ui.warn("abort: destination '%s' already exists\n" % dest)
|
|
|
|
return 1
|
2005-06-30 02:04:56 +04:00
|
|
|
|
2005-08-14 02:41:51 +04:00
|
|
|
dest = os.path.realpath(dest)
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
class Dircleanup:
|
|
|
|
def __init__(self, dir_):
|
2005-07-06 06:12:57 +04:00
|
|
|
self.rmtree = shutil.rmtree
|
2005-07-14 13:42:28 +04:00
|
|
|
self.dir_ = dir_
|
|
|
|
os.mkdir(dir_)
|
2005-06-30 22:07:50 +04:00
|
|
|
def close(self):
|
2005-07-14 13:42:28 +04:00
|
|
|
self.dir_ = None
|
2005-06-30 22:07:50 +04:00
|
|
|
def __del__(self):
|
2005-07-14 13:42:28 +04:00
|
|
|
if self.dir_:
|
|
|
|
self.rmtree(self.dir_, True)
|
2005-06-30 22:07:50 +04:00
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
d = Dircleanup(dest)
|
2005-07-01 23:49:58 +04:00
|
|
|
abspath = source
|
2005-07-07 10:14:10 +04:00
|
|
|
source = ui.expandpath(source)
|
|
|
|
other = hg.repository(ui, source)
|
|
|
|
|
2005-07-11 04:15:20 +04:00
|
|
|
if other.dev() != -1:
|
|
|
|
abspath = os.path.abspath(source)
|
2005-07-14 18:30:49 +04:00
|
|
|
copyfile = (os.stat(dest).st_dev == other.dev()
|
|
|
|
and getattr(os, 'link', None) or shutil.copy2)
|
|
|
|
if copyfile is not shutil.copy2:
|
|
|
|
ui.note("cloning by hardlink\n")
|
2005-08-17 02:53:47 +04:00
|
|
|
# we use a lock here because because we're not nicely ordered
|
|
|
|
l = lock.lock(os.path.join(source, ".hg", "lock"))
|
|
|
|
|
2005-07-14 18:30:49 +04:00
|
|
|
util.copytree(os.path.join(source, ".hg"), os.path.join(dest, ".hg"),
|
|
|
|
copyfile)
|
2005-06-30 22:07:50 +04:00
|
|
|
try:
|
2005-07-14 13:42:28 +04:00
|
|
|
os.unlink(os.path.join(dest, ".hg", "dirstate"))
|
2005-07-23 19:14:42 +04:00
|
|
|
except OSError:
|
2005-07-14 13:42:28 +04:00
|
|
|
pass
|
2005-06-27 03:20:46 +04:00
|
|
|
|
2005-06-30 22:07:50 +04:00
|
|
|
repo = hg.repository(ui, dest)
|
2005-06-27 03:20:46 +04:00
|
|
|
|
2005-06-30 22:07:50 +04:00
|
|
|
else:
|
|
|
|
repo = hg.repository(ui, dest, create=1)
|
2005-07-06 06:12:57 +04:00
|
|
|
repo.pull(other)
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-06-30 22:07:50 +04:00
|
|
|
f = repo.opener("hgrc", "w")
|
|
|
|
f.write("[paths]\n")
|
2005-07-01 23:49:58 +04:00
|
|
|
f.write("default = %s\n" % abspath)
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-06-30 22:07:50 +04:00
|
|
|
if not opts['noupdate']:
|
|
|
|
update(ui, repo)
|
|
|
|
|
|
|
|
d.close()
|
2005-06-29 22:42:35 +04:00
|
|
|
|
2005-07-30 03:02:27 +04:00
|
|
|
def commit(ui, repo, *pats, **opts):
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
"""commit the specified files or all outstanding changes"""
|
2005-07-22 19:27:30 +04:00
|
|
|
if opts['text']:
|
|
|
|
ui.warn("Warning: -t and --text is deprecated,"
|
|
|
|
" please use -m or --message instead.\n")
|
2005-07-22 19:26:46 +04:00
|
|
|
message = opts['message'] or opts['text']
|
2005-07-14 13:42:28 +04:00
|
|
|
logfile = opts['logfile']
|
2005-07-22 19:26:46 +04:00
|
|
|
if not message and logfile:
|
2005-07-14 13:42:28 +04:00
|
|
|
try:
|
2005-08-15 00:30:01 +04:00
|
|
|
if logfile == '-':
|
|
|
|
message = sys.stdin.read()
|
|
|
|
else:
|
|
|
|
message = open(logfile).read()
|
2005-07-14 13:42:28 +04:00
|
|
|
except IOError, why:
|
2005-07-22 19:26:46 +04:00
|
|
|
ui.warn("Can't read commit message %s: %s\n" % (logfile, why))
|
2005-06-09 04:28:34 +04:00
|
|
|
|
2005-06-15 22:01:15 +04:00
|
|
|
if opts['addremove']:
|
2005-07-30 03:02:27 +04:00
|
|
|
addremove(ui, repo, *pats, **opts)
|
|
|
|
cwd = repo.getcwd()
|
|
|
|
if not pats and cwd:
|
|
|
|
opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
|
|
|
|
opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
|
2005-08-08 00:43:11 +04:00
|
|
|
fns, match = matchpats(repo, (pats and repo.getcwd()) or '', pats, opts)
|
2005-07-30 03:02:27 +04:00
|
|
|
if pats:
|
|
|
|
c, a, d, u = repo.changes(files = fns, match = match)
|
|
|
|
files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r']
|
|
|
|
else:
|
|
|
|
files = []
|
|
|
|
repo.commit(files, message, opts['user'], opts['date'], match)
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-06-16 03:57:07 +04:00
|
|
|
def copy(ui, repo, source, dest):
|
|
|
|
"""mark a file as copied or renamed for the next commit"""
|
|
|
|
return repo.copy(*relpath(repo, (source, dest)))
|
|
|
|
|
2005-07-03 23:47:45 +04:00
|
|
|
def debugcheckstate(ui, repo):
|
|
|
|
"""validate the correctness of the current dirstate"""
|
2005-06-25 10:51:39 +04:00
|
|
|
parent1, parent2 = repo.dirstate.parents()
|
2005-07-01 12:34:17 +04:00
|
|
|
repo.dirstate.read()
|
|
|
|
dc = repo.dirstate.map
|
2005-06-25 10:51:39 +04:00
|
|
|
keys = dc.keys()
|
|
|
|
keys.sort()
|
|
|
|
m1n = repo.changelog.read(parent1)[0]
|
|
|
|
m2n = repo.changelog.read(parent2)[0]
|
|
|
|
m1 = repo.manifest.read(m1n)
|
|
|
|
m2 = repo.manifest.read(m2n)
|
|
|
|
errors = 0
|
|
|
|
for f in dc:
|
|
|
|
state = repo.dirstate.state(f)
|
|
|
|
if state in "nr" and f not in m1:
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.warn("%s in state %s, but not in manifest1\n" % (f, state))
|
2005-06-25 10:51:39 +04:00
|
|
|
errors += 1
|
|
|
|
if state in "a" and f in m1:
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.warn("%s in state %s, but also in manifest1\n" % (f, state))
|
2005-06-25 10:51:39 +04:00
|
|
|
errors += 1
|
|
|
|
if state in "m" and f not in m1 and f not in m2:
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.warn("%s in state %s, but not in either manifest\n" %
|
|
|
|
(f, state))
|
2005-06-25 10:51:39 +04:00
|
|
|
errors += 1
|
|
|
|
for f in m1:
|
|
|
|
state = repo.dirstate.state(f)
|
|
|
|
if state not in "nrm":
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.warn("%s in manifest1, but listed as state %s" % (f, state))
|
2005-06-25 10:51:39 +04:00
|
|
|
errors += 1
|
|
|
|
if errors:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort(".hg/dirstate inconsistent with current parent's manifest")
|
2005-06-25 10:51:39 +04:00
|
|
|
|
2005-07-03 23:47:45 +04:00
|
|
|
def debugstate(ui, repo):
|
|
|
|
"""show the contents of the current dirstate"""
|
2005-07-01 12:34:17 +04:00
|
|
|
repo.dirstate.read()
|
|
|
|
dc = repo.dirstate.map
|
2005-06-25 10:51:39 +04:00
|
|
|
keys = dc.keys()
|
|
|
|
keys.sort()
|
2005-07-14 13:42:28 +04:00
|
|
|
for file_ in keys:
|
2005-07-23 20:11:29 +04:00
|
|
|
ui.write("%c %3o %10d %s %s\n"
|
|
|
|
% (dc[file_][0], dc[file_][1] & 0777, dc[file_][2],
|
|
|
|
time.strftime("%x %X",
|
|
|
|
time.localtime(dc[file_][3])), file_))
|
2005-06-25 10:51:39 +04:00
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def debugindex(ui, file_):
|
2005-07-03 23:47:45 +04:00
|
|
|
"""dump the contents of an index file"""
|
2005-07-14 13:42:28 +04:00
|
|
|
r = hg.revlog(hg.opener(""), file_, "")
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.write(" rev offset length base linkrev" +
|
|
|
|
" p1 p2 nodeid\n")
|
2005-06-05 01:45:31 +04:00
|
|
|
for i in range(r.count()):
|
|
|
|
e = r.index[i]
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.write("% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s..\n" % (
|
|
|
|
i, e[0], e[1], e[2], e[3],
|
|
|
|
hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])))
|
2005-06-05 01:45:31 +04:00
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def debugindexdot(ui, file_):
|
2005-07-03 23:47:45 +04:00
|
|
|
"""dump an index DAG as a .dot file"""
|
2005-07-14 13:42:28 +04:00
|
|
|
r = hg.revlog(hg.opener(""), file_, "")
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.write("digraph G {\n")
|
2005-06-05 01:45:31 +04:00
|
|
|
for i in range(r.count()):
|
|
|
|
e = r.index[i]
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.write("\t%d -> %d\n" % (r.rev(e[4]), i))
|
2005-06-05 01:45:31 +04:00
|
|
|
if e[5] != hg.nullid:
|
2005-07-03 06:57:59 +04:00
|
|
|
ui.write("\t%d -> %d\n" % (r.rev(e[5]), i))
|
|
|
|
ui.write("}\n")
|
2005-06-05 01:45:31 +04:00
|
|
|
|
Clean up walk and changes code to use normalised names properly.
New function: commands.pathto returns the relative path from one path
to another. For example, given foo/bar and baz/quux, it will return
../../baz/quux. This new function is used by the walk and status code
to print relative paths correctly.
New command: debugwalk exercises the walk code without doing anything
more.
hg.dirstate.walk now yields normalised names. For example, if you're
in the baz directory and you ask it to walk ../foo/bar/.., it will yield
names starting with foo/.
As a result of this change, all of the other walk and changes methods
in this module also return normalised names.
The util.matcher function now normalises globs and path names, so that
it will match normalised names properly.
Finally, util.matcher uses the non-glob prefix of a glob to tell walk
which directories to scan. Perviously, a glob like foo/* would scan
everything, but only return matches for foo/*. Now, foo/* only scans
under foo (using the globprefix function), which is much faster.
2005-08-01 05:42:46 +04:00
|
|
|
def debugwalk(ui, repo, *pats, **opts):
|
|
|
|
items = list(walk(repo, pats, opts))
|
2005-08-07 23:04:58 +04:00
|
|
|
if not items: return
|
Clean up walk and changes code to use normalised names properly.
New function: commands.pathto returns the relative path from one path
to another. For example, given foo/bar and baz/quux, it will return
../../baz/quux. This new function is used by the walk and status code
to print relative paths correctly.
New command: debugwalk exercises the walk code without doing anything
more.
hg.dirstate.walk now yields normalised names. For example, if you're
in the baz directory and you ask it to walk ../foo/bar/.., it will yield
names starting with foo/.
As a result of this change, all of the other walk and changes methods
in this module also return normalised names.
The util.matcher function now normalises globs and path names, so that
it will match normalised names properly.
Finally, util.matcher uses the non-glob prefix of a glob to tell walk
which directories to scan. Perviously, a glob like foo/* would scan
everything, but only return matches for foo/*. Now, foo/* only scans
under foo (using the globprefix function), which is much faster.
2005-08-01 05:42:46 +04:00
|
|
|
fmt = '%%s %%-%ds %%s' % max([len(abs) for (src, abs, rel) in items])
|
|
|
|
for i in items: print fmt % i
|
|
|
|
|
2005-07-20 15:16:20 +04:00
|
|
|
def diff(ui, repo, *pats, **opts):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""diff working directory (or selected files)"""
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
revs = []
|
|
|
|
if opts['rev']:
|
|
|
|
revs = map(lambda x: repo.lookup(x), opts['rev'])
|
2005-06-17 23:37:23 +04:00
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
if len(revs) > 2:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort("too many revisions to diff")
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-07-20 15:16:20 +04:00
|
|
|
files = []
|
2005-08-12 19:10:21 +04:00
|
|
|
match = util.always
|
|
|
|
if pats:
|
|
|
|
roots, match, results = makewalk(repo, pats, opts)
|
|
|
|
for src, abs, rel in results:
|
|
|
|
files.append(abs)
|
2005-08-03 21:10:48 +04:00
|
|
|
dodiff(sys.stdout, ui, repo, files, *revs, **{'match': match})
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-07-03 06:29:54 +04:00
|
|
|
def doexport(ui, repo, changeset, seqno, total, revwidth, opts):
|
2005-06-05 00:14:14 +04:00
|
|
|
node = repo.lookup(changeset)
|
|
|
|
prev, other = repo.changelog.parents(node)
|
|
|
|
change = repo.changelog.read(node)
|
2005-06-17 23:37:23 +04:00
|
|
|
|
2005-07-20 14:48:16 +04:00
|
|
|
fp = make_file(repo, repo.changelog, opts['output'],
|
|
|
|
node=node, total=total, seqno=seqno,
|
|
|
|
revwidth=revwidth)
|
|
|
|
if fp != sys.stdout:
|
2005-07-22 10:42:47 +04:00
|
|
|
ui.note("%s\n" % fp.name)
|
2005-07-03 06:29:54 +04:00
|
|
|
|
2005-07-03 06:57:59 +04:00
|
|
|
fp.write("# HG changeset patch\n")
|
|
|
|
fp.write("# User %s\n" % change[1])
|
|
|
|
fp.write("# Node ID %s\n" % hg.hex(node))
|
|
|
|
fp.write("# Parent %s\n" % hg.hex(prev))
|
2005-07-03 06:29:54 +04:00
|
|
|
if other != hg.nullid:
|
2005-07-03 06:57:59 +04:00
|
|
|
fp.write("# Parent %s\n" % hg.hex(other))
|
|
|
|
fp.write(change[4].rstrip())
|
|
|
|
fp.write("\n\n")
|
2005-07-03 06:29:54 +04:00
|
|
|
|
|
|
|
dodiff(fp, ui, repo, None, prev, node)
|
2005-07-20 16:08:11 +04:00
|
|
|
if fp != sys.stdout: fp.close()
|
2005-07-03 06:29:54 +04:00
|
|
|
|
|
|
|
def export(ui, repo, *changesets, **opts):
|
|
|
|
"""dump the header and diffs for one or more changesets"""
|
2005-07-04 23:06:01 +04:00
|
|
|
if not changesets:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort("export requires at least one changeset")
|
2005-07-03 06:29:54 +04:00
|
|
|
seqno = 0
|
|
|
|
revs = list(revrange(ui, repo, changesets))
|
|
|
|
total = len(revs)
|
|
|
|
revwidth = max(len(revs[0]), len(revs[-1]))
|
2005-07-22 10:42:47 +04:00
|
|
|
ui.note(len(revs) > 1 and "Exporting patches:\n" or "Exporting patch:\n")
|
2005-07-03 06:29:54 +04:00
|
|
|
for cset in revs:
|
|
|
|
seqno += 1
|
|
|
|
doexport(ui, repo, cset, seqno, total, revwidth, opts)
|
2005-06-05 00:14:14 +04:00
|
|
|
|
2005-07-29 20:49:01 +04:00
|
|
|
def forget(ui, repo, *pats, **opts):
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
"""don't add the specified files on the next commit"""
|
2005-07-29 20:49:01 +04:00
|
|
|
q = dict(zip(pats, pats))
|
|
|
|
forget = []
|
|
|
|
for src, abs, rel in walk(repo, pats, opts):
|
|
|
|
if repo.dirstate.state(abs) == 'a':
|
|
|
|
forget.append(abs)
|
|
|
|
if rel not in q: ui.status('forgetting ', rel, '\n')
|
|
|
|
repo.forget(forget)
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-08-15 00:23:45 +04:00
|
|
|
def heads(ui, repo, **opts):
|
2005-06-13 11:49:21 +04:00
|
|
|
"""show current repository heads"""
|
2005-08-15 00:23:45 +04:00
|
|
|
heads = repo.changelog.heads()
|
|
|
|
br = None
|
|
|
|
if opts['branches']:
|
|
|
|
br = repo.branchlookup(heads)
|
2005-06-03 06:07:01 +04:00
|
|
|
for n in repo.changelog.heads():
|
2005-08-15 00:23:45 +04:00
|
|
|
show_changeset(ui, repo, changenode=n, brinfo=br)
|
2005-06-03 06:07:01 +04:00
|
|
|
|
2005-06-15 09:44:43 +04:00
|
|
|
def identify(ui, repo):
|
|
|
|
"""print information about the working copy"""
|
2005-06-15 12:08:03 +04:00
|
|
|
parents = [p for p in repo.dirstate.parents() if p != hg.nullid]
|
2005-06-15 10:07:05 +04:00
|
|
|
if not parents:
|
2005-06-15 12:08:03 +04:00
|
|
|
ui.write("unknown\n")
|
2005-06-15 10:07:05 +04:00
|
|
|
return
|
|
|
|
|
2005-06-17 13:19:43 +04:00
|
|
|
hexfunc = ui.verbose and hg.hex or hg.short
|
2005-07-17 03:13:40 +04:00
|
|
|
(c, a, d, u) = repo.changes()
|
2005-06-17 13:19:43 +04:00
|
|
|
output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
|
|
|
|
(c or a or d) and "+" or "")]
|
|
|
|
|
2005-06-15 09:44:43 +04:00
|
|
|
if not ui.quiet:
|
2005-06-17 13:19:43 +04:00
|
|
|
# multiple tags for a single parent separated by '/'
|
|
|
|
parenttags = ['/'.join(tags)
|
|
|
|
for tags in map(repo.nodetags, parents) if tags]
|
|
|
|
# tags for multiple parents separated by ' + '
|
2005-07-22 11:58:16 +04:00
|
|
|
if parenttags:
|
|
|
|
output.append(' + '.join(parenttags))
|
2005-06-15 09:44:43 +04:00
|
|
|
|
2005-06-17 13:19:43 +04:00
|
|
|
ui.write("%s\n" % ' '.join(output))
|
2005-06-15 09:44:43 +04:00
|
|
|
|
2005-06-23 10:31:25 +04:00
|
|
|
def import_(ui, repo, patch1, *patches, **opts):
|
|
|
|
"""import an ordered set of patches"""
|
|
|
|
patches = (patch1,) + patches
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-06-23 10:31:25 +04:00
|
|
|
d = opts["base"]
|
|
|
|
strip = opts["strip"]
|
|
|
|
|
|
|
|
for patch in patches:
|
|
|
|
ui.status("applying %s\n" % patch)
|
|
|
|
pf = os.path.join(d, patch)
|
|
|
|
|
2005-07-22 19:26:46 +04:00
|
|
|
message = []
|
2005-07-14 19:57:01 +04:00
|
|
|
user = None
|
|
|
|
hgpatch = False
|
|
|
|
for line in file(pf):
|
|
|
|
line = line.rstrip()
|
|
|
|
if line.startswith("--- ") or line.startswith("diff -r"):
|
2005-07-14 13:42:28 +04:00
|
|
|
break
|
2005-07-14 19:57:01 +04:00
|
|
|
elif hgpatch:
|
|
|
|
# parse values when importing the result of an hg export
|
|
|
|
if line.startswith("# User "):
|
|
|
|
user = line[7:]
|
2005-07-04 09:14:40 +04:00
|
|
|
ui.debug('User: %s\n' % user)
|
2005-07-14 19:57:01 +04:00
|
|
|
elif not line.startswith("# ") and line:
|
2005-07-22 19:26:46 +04:00
|
|
|
message.append(line)
|
2005-07-14 19:57:01 +04:00
|
|
|
hgpatch = False
|
|
|
|
elif line == '# HG changeset patch':
|
|
|
|
hgpatch = True
|
2005-08-07 00:23:38 +04:00
|
|
|
message = [] # We may have collected garbage
|
2005-07-14 19:57:01 +04:00
|
|
|
else:
|
2005-07-22 19:26:46 +04:00
|
|
|
message.append(line)
|
2005-07-04 09:14:40 +04:00
|
|
|
|
2005-07-22 19:26:46 +04:00
|
|
|
# make sure message isn't empty
|
|
|
|
if not message:
|
|
|
|
message = "imported patch %s\n" % patch
|
2005-07-14 19:57:01 +04:00
|
|
|
else:
|
2005-07-22 19:26:46 +04:00
|
|
|
message = "%s\n" % '\n'.join(message)
|
|
|
|
ui.debug('message:\n%s\n' % message)
|
2005-06-23 10:31:25 +04:00
|
|
|
|
2005-08-05 01:22:36 +04:00
|
|
|
f = os.popen("patch -p%d < '%s'" % (strip, pf))
|
2005-06-23 10:31:25 +04:00
|
|
|
files = []
|
|
|
|
for l in f.read().splitlines():
|
|
|
|
l.rstrip('\r\n');
|
2005-06-26 17:18:23 +04:00
|
|
|
ui.status("%s\n" % l)
|
2005-07-11 04:14:56 +04:00
|
|
|
if l.startswith('patching file '):
|
2005-06-24 01:29:35 +04:00
|
|
|
pf = l[14:]
|
|
|
|
if pf not in files:
|
|
|
|
files.append(pf)
|
|
|
|
patcherr = f.close()
|
|
|
|
if patcherr:
|
2005-08-08 00:43:11 +04:00
|
|
|
raise util.Abort("patch failed")
|
2005-06-23 10:31:25 +04:00
|
|
|
|
|
|
|
if len(files) > 0:
|
|
|
|
addremove(ui, repo, *files)
|
2005-07-22 19:26:46 +04:00
|
|
|
repo.commit(files, message, user)
|
2005-06-23 10:31:25 +04:00
|
|
|
|
2005-08-17 07:17:16 +04:00
|
|
|
def incoming(ui, repo, source="default"):
|
|
|
|
"""show changesets not found in source"""
|
|
|
|
source = ui.expandpath(source)
|
|
|
|
other = hg.repository(ui, source)
|
|
|
|
if not other.local():
|
|
|
|
ui.warn("abort: incoming doesn't work for remote"
|
|
|
|
+ " repositories yet, sorry!\n")
|
|
|
|
return 1
|
|
|
|
o = repo.findincoming(other)
|
|
|
|
o = other.newer(o)
|
|
|
|
o.reverse()
|
|
|
|
for n in o:
|
|
|
|
show_changeset(ui, other, changenode=n)
|
|
|
|
|
2005-08-15 09:33:09 +04:00
|
|
|
def init(ui, dest="."):
|
|
|
|
"""create a new repository in the given directory"""
|
|
|
|
if not os.path.exists(dest):
|
|
|
|
os.mkdir(dest)
|
|
|
|
hg.repository(ui, dest, create=1)
|
2005-06-15 06:37:53 +04:00
|
|
|
|
2005-07-06 06:19:01 +04:00
|
|
|
def locate(ui, repo, *pats, **opts):
|
|
|
|
"""locate files matching specific patterns"""
|
2005-07-21 21:21:33 +04:00
|
|
|
end = '\n'
|
2005-07-18 18:54:21 +04:00
|
|
|
if opts['print0']: end = '\0'
|
2005-07-21 21:21:33 +04:00
|
|
|
|
|
|
|
for src, abs, rel in walk(repo, pats, opts, '(?:.*/|)'):
|
2005-07-18 18:54:21 +04:00
|
|
|
if repo.dirstate.state(abs) == '?': continue
|
2005-07-14 13:42:28 +04:00
|
|
|
if opts['fullpath']:
|
2005-07-18 18:54:21 +04:00
|
|
|
ui.write(os.path.join(repo.root, abs), end)
|
|
|
|
else:
|
|
|
|
ui.write(rel, end)
|
2005-07-06 06:19:01 +04:00
|
|
|
|
2005-07-01 11:55:10 +04:00
|
|
|
def log(ui, repo, f=None, **opts):
|
2005-06-28 14:48:21 +04:00
|
|
|
"""show the revision history of the repository or a single file"""
|
|
|
|
if f:
|
On Sat, Jul 02, 2005 at 02:11:34PM -0700, Matt Mackall wrote:
# HG changeset patch
# User Alecs King <alecsk@gmail.com>
On Sat, Jul 02, 2005 at 02:11:34PM -0700, Matt Mackall wrote:
> On Sun, Jul 03, 2005 at 12:49:27AM +0800, Alecs King wrote:
> > Hg is really very nice. The only feature i miss from git is the
> > whatchanged -p, which shows a diff along with a changeset.
> > python before, i just dig into the mercurial/commands.py a while and
> > see what diff(), dodiff(), export(), show_changeset(), log() would
> > normally do. There might be one thing or two missed or wrong. But here
> > it is: a '-d' option to 'hg log' showing the diff info. You can use 'hg
> > log -d' to show the whole history with the diff or 'hg log -d <file>' to
> > show that info of a particular file. And also works with the '-r'
> > option.
>
> Let's use -p. We're going to be combining the global and per command
> switch namespace shortly and the global -p will disappear.
Okay. '-d' changed to '-p'. Just like 'whatchanged -p', now we have
'hg log -p'.
> Also, the argument list for show_changeset is getting a bit unwieldy.
This time i remain show_changeset untouched at all. Only changed some
bits of log().
2005-07-05 00:15:44 +04:00
|
|
|
files = relpath(repo, [f])
|
|
|
|
filelog = repo.file(files[0])
|
2005-07-01 11:55:10 +04:00
|
|
|
log = filelog
|
|
|
|
lookup = filelog.lookup
|
2005-06-28 14:48:21 +04:00
|
|
|
else:
|
On Sat, Jul 02, 2005 at 02:11:34PM -0700, Matt Mackall wrote:
# HG changeset patch
# User Alecs King <alecsk@gmail.com>
On Sat, Jul 02, 2005 at 02:11:34PM -0700, Matt Mackall wrote:
> On Sun, Jul 03, 2005 at 12:49:27AM +0800, Alecs King wrote:
> > Hg is really very nice. The only feature i miss from git is the
> > whatchanged -p, which shows a diff along with a changeset.
> > python before, i just dig into the mercurial/commands.py a while and
> > see what diff(), dodiff(), export(), show_changeset(), log() would
> > normally do. There might be one thing or two missed or wrong. But here
> > it is: a '-d' option to 'hg log' showing the diff info. You can use 'hg
> > log -d' to show the whole history with the diff or 'hg log -d <file>' to
> > show that info of a particular file. And also works with the '-r'
> > option.
>
> Let's use -p. We're going to be combining the global and per command
> switch namespace shortly and the global -p will disappear.
Okay. '-d' changed to '-p'. Just like 'whatchanged -p', now we have
'hg log -p'.
> Also, the argument list for show_changeset is getting a bit unwieldy.
This time i remain show_changeset untouched at all. Only changed some
bits of log().
2005-07-05 00:15:44 +04:00
|
|
|
files = None
|
2005-07-01 11:55:10 +04:00
|
|
|
filelog = None
|
|
|
|
log = repo.changelog
|
|
|
|
lookup = repo.lookup
|
|
|
|
revlist = []
|
|
|
|
revs = [log.rev(lookup(rev)) for rev in opts['rev']]
|
|
|
|
while revs:
|
|
|
|
if len(revs) == 1:
|
|
|
|
revlist.append(revs.pop(0))
|
|
|
|
else:
|
|
|
|
a = revs.pop(0)
|
|
|
|
b = revs.pop(0)
|
|
|
|
off = a > b and -1 or 1
|
|
|
|
revlist.extend(range(a, b + off, off))
|
2005-07-04 23:00:25 +04:00
|
|
|
|
2005-07-01 11:55:10 +04:00
|
|
|
for i in revlist or range(log.count() - 1, -1, -1):
|
|
|
|
show_changeset(ui, repo, filelog=filelog, rev=i)
|
On Sat, Jul 02, 2005 at 02:11:34PM -0700, Matt Mackall wrote:
# HG changeset patch
# User Alecs King <alecsk@gmail.com>
On Sat, Jul 02, 2005 at 02:11:34PM -0700, Matt Mackall wrote:
> On Sun, Jul 03, 2005 at 12:49:27AM +0800, Alecs King wrote:
> > Hg is really very nice. The only feature i miss from git is the
> > whatchanged -p, which shows a diff along with a changeset.
> > python before, i just dig into the mercurial/commands.py a while and
> > see what diff(), dodiff(), export(), show_changeset(), log() would
> > normally do. There might be one thing or two missed or wrong. But here
> > it is: a '-d' option to 'hg log' showing the diff info. You can use 'hg
> > log -d' to show the whole history with the diff or 'hg log -d <file>' to
> > show that info of a particular file. And also works with the '-r'
> > option.
>
> Let's use -p. We're going to be combining the global and per command
> switch namespace shortly and the global -p will disappear.
Okay. '-d' changed to '-p'. Just like 'whatchanged -p', now we have
'hg log -p'.
> Also, the argument list for show_changeset is getting a bit unwieldy.
This time i remain show_changeset untouched at all. Only changed some
bits of log().
2005-07-05 00:15:44 +04:00
|
|
|
if opts['patch']:
|
|
|
|
if filelog:
|
|
|
|
filenode = filelog.node(i)
|
|
|
|
i = filelog.linkrev(filenode)
|
|
|
|
changenode = repo.changelog.node(i)
|
|
|
|
prev, other = repo.changelog.parents(changenode)
|
|
|
|
dodiff(sys.stdout, ui, repo, files, prev, changenode)
|
2005-07-14 13:37:33 +04:00
|
|
|
ui.write("\n\n")
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def manifest(ui, repo, rev=None):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""output the latest or given revision of the project manifest"""
|
2005-06-05 01:45:31 +04:00
|
|
|
if rev:
|
2005-07-13 13:42:48 +04:00
|
|
|
try:
|
|
|
|
# assume all revision numbers are for changesets
|
|
|
|
n = repo.lookup(rev)
|
|
|
|
change = repo.changelog.read(n)
|
|
|
|
n = change[0]
|
2005-07-14 13:42:28 +04:00
|
|
|
except hg.RepoError:
|
2005-07-13 13:42:48 +04:00
|
|
|
n = repo.manifest.lookup(rev)
|
2005-07-14 13:42:28 +04:00
|
|
|
else:
|
|
|
|
n = repo.manifest.tip()
|
2005-06-05 01:45:31 +04:00
|
|
|
m = repo.manifest.read(n)
|
2005-06-08 22:16:33 +04:00
|
|
|
mf = repo.manifest.readflags(n)
|
2005-06-05 01:45:31 +04:00
|
|
|
files = m.keys()
|
|
|
|
files.sort()
|
|
|
|
|
|
|
|
for f in files:
|
2005-06-08 22:16:33 +04:00
|
|
|
ui.write("%40s %3s %s\n" % (hg.hex(m[f]), mf[f] and "755" or "644", f))
|
2005-06-05 01:45:31 +04:00
|
|
|
|
2005-08-17 03:49:26 +04:00
|
|
|
def outgoing(ui, repo, dest="default-push"):
|
|
|
|
"""show changesets not found in destination"""
|
|
|
|
dest = ui.expandpath(dest)
|
|
|
|
other = hg.repository(ui, dest)
|
|
|
|
o = repo.findoutgoing(other)
|
|
|
|
o = repo.newer(o)
|
|
|
|
o.reverse()
|
|
|
|
for n in o:
|
|
|
|
show_changeset(ui, repo, changenode=n)
|
|
|
|
|
2005-07-15 11:32:45 +04:00
|
|
|
def parents(ui, repo, rev=None):
|
|
|
|
"""show the parents of the working dir or revision"""
|
|
|
|
if rev:
|
|
|
|
p = repo.changelog.parents(repo.lookup(rev))
|
2005-06-04 00:46:38 +04:00
|
|
|
else:
|
|
|
|
p = repo.dirstate.parents()
|
|
|
|
|
|
|
|
for n in p:
|
|
|
|
if n != hg.nullid:
|
2005-06-13 11:49:21 +04:00
|
|
|
show_changeset(ui, repo, changenode=n)
|
2005-06-04 00:46:38 +04:00
|
|
|
|
2005-08-17 01:52:28 +04:00
|
|
|
def paths(ui, search = None):
|
2005-08-17 05:30:41 +04:00
|
|
|
"""show definition of symbolic path names"""
|
2005-08-17 01:52:28 +04:00
|
|
|
try:
|
|
|
|
repo = hg.repository(ui=ui)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2005-07-27 20:19:59 +04:00
|
|
|
if search:
|
|
|
|
for name, path in ui.configitems("paths"):
|
|
|
|
if name == search:
|
|
|
|
ui.write("%s\n" % path)
|
|
|
|
return
|
|
|
|
ui.warn("not found!\n")
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
for name, path in ui.configitems("paths"):
|
|
|
|
ui.write("%s = %s\n" % (name, path))
|
|
|
|
|
2005-06-22 06:04:25 +04:00
|
|
|
def pull(ui, repo, source="default", **opts):
|
2005-06-05 00:14:14 +04:00
|
|
|
"""pull changes from the specified source"""
|
2005-06-28 14:30:36 +04:00
|
|
|
source = ui.expandpath(source)
|
2005-06-22 06:04:25 +04:00
|
|
|
ui.status('pulling from %s\n' % (source))
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-06-05 00:14:14 +04:00
|
|
|
other = hg.repository(ui, source)
|
2005-07-06 06:12:57 +04:00
|
|
|
r = repo.pull(other)
|
|
|
|
if not r:
|
2005-06-22 06:04:25 +04:00
|
|
|
if opts['update']:
|
|
|
|
return update(ui, repo)
|
2005-07-03 06:29:54 +04:00
|
|
|
else:
|
2005-06-22 06:04:25 +04:00
|
|
|
ui.status("(run 'hg update' to get a working copy)\n")
|
|
|
|
|
|
|
|
return r
|
2005-06-05 00:14:14 +04:00
|
|
|
|
2005-08-02 11:34:23 +04:00
|
|
|
def push(ui, repo, dest="default-push", force=False):
|
2005-06-13 07:35:41 +04:00
|
|
|
"""push changes to the specified destination"""
|
2005-06-28 14:30:36 +04:00
|
|
|
dest = ui.expandpath(dest)
|
2005-07-07 10:25:40 +04:00
|
|
|
ui.status('pushing to %s\n' % (dest))
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-07-07 10:25:40 +04:00
|
|
|
other = hg.repository(ui, dest)
|
2005-08-02 11:34:23 +04:00
|
|
|
r = repo.push(other, force)
|
2005-07-07 10:25:40 +04:00
|
|
|
return r
|
2005-06-13 07:35:41 +04:00
|
|
|
|
2005-06-22 05:53:01 +04:00
|
|
|
def rawcommit(ui, repo, *flist, **rc):
|
2005-06-05 00:14:14 +04:00
|
|
|
"raw commit interface"
|
2005-07-22 19:27:30 +04:00
|
|
|
if rc['text']:
|
|
|
|
ui.warn("Warning: -t and --text is deprecated,"
|
|
|
|
" please use -m or --message instead.\n")
|
2005-07-22 19:26:46 +04:00
|
|
|
message = rc['message'] or rc['text']
|
|
|
|
if not message and rc['logfile']:
|
2005-07-14 13:42:28 +04:00
|
|
|
try:
|
2005-07-22 19:26:46 +04:00
|
|
|
message = open(rc['logfile']).read()
|
2005-07-14 13:42:28 +04:00
|
|
|
except IOError:
|
|
|
|
pass
|
2005-07-22 19:26:46 +04:00
|
|
|
if not message and not rc['logfile']:
|
|
|
|
ui.warn("abort: missing commit message\n")
|
2005-06-05 00:14:14 +04:00
|
|
|
return 1
|
|
|
|
|
2005-06-22 05:53:01 +04:00
|
|
|
files = relpath(repo, list(flist))
|
2005-06-05 00:14:14 +04:00
|
|
|
if rc['files']:
|
|
|
|
files += open(rc['files']).read().splitlines()
|
2005-06-24 05:43:04 +04:00
|
|
|
|
|
|
|
rc['parent'] = map(repo.lookup, rc['parent'])
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-07-22 19:26:46 +04:00
|
|
|
repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent'])
|
2005-06-28 12:59:59 +04:00
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
def recover(ui, repo):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""roll back an interrupted transaction"""
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
repo.recover()
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
def remove(ui, repo, file1, *files):
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
"""remove the specified files on the next commit"""
|
2005-07-14 13:42:28 +04:00
|
|
|
repo.remove(relpath(repo, (file1,) + files))
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-07-03 07:49:46 +04:00
|
|
|
def revert(ui, repo, *names, **opts):
|
|
|
|
"""revert modified files or dirs back to their unmodified states"""
|
2005-07-03 08:51:33 +04:00
|
|
|
node = opts['rev'] and repo.lookup(opts['rev']) or \
|
|
|
|
repo.dirstate.parents()[0]
|
2005-07-03 07:49:46 +04:00
|
|
|
root = os.path.realpath(repo.root)
|
2005-07-03 08:51:33 +04:00
|
|
|
|
2005-07-03 07:49:46 +04:00
|
|
|
def trimpath(p):
|
|
|
|
p = os.path.realpath(p)
|
|
|
|
if p.startswith(root):
|
|
|
|
rest = p[len(root):]
|
|
|
|
if not rest:
|
|
|
|
return rest
|
|
|
|
if p.startswith(os.sep):
|
|
|
|
return rest[1:]
|
|
|
|
return p
|
2005-07-03 08:51:33 +04:00
|
|
|
|
2005-07-03 07:49:46 +04:00
|
|
|
relnames = map(trimpath, names or [os.getcwd()])
|
|
|
|
chosen = {}
|
2005-07-03 08:51:33 +04:00
|
|
|
|
2005-07-03 07:49:46 +04:00
|
|
|
def choose(name):
|
|
|
|
def body(name):
|
|
|
|
for r in relnames:
|
2005-07-14 13:42:28 +04:00
|
|
|
if not name.startswith(r):
|
|
|
|
continue
|
2005-07-03 07:49:46 +04:00
|
|
|
rest = name[len(r):]
|
2005-07-14 13:42:28 +04:00
|
|
|
if not rest:
|
|
|
|
return r, True
|
2005-07-03 07:49:46 +04:00
|
|
|
depth = rest.count(os.sep)
|
|
|
|
if not r:
|
2005-07-14 13:42:28 +04:00
|
|
|
if depth == 0 or not opts['nonrecursive']:
|
|
|
|
return r, True
|
2005-07-03 07:49:46 +04:00
|
|
|
elif rest[0] == os.sep:
|
2005-07-14 13:42:28 +04:00
|
|
|
if depth == 1 or not opts['nonrecursive']:
|
|
|
|
return r, True
|
2005-07-03 07:49:46 +04:00
|
|
|
return None, False
|
|
|
|
relname, ret = body(name)
|
|
|
|
if ret:
|
|
|
|
chosen[relname] = 1
|
|
|
|
return ret
|
|
|
|
|
|
|
|
r = repo.update(node, False, True, choose, False)
|
|
|
|
for n in relnames:
|
|
|
|
if n not in chosen:
|
|
|
|
ui.warn('error: no matches for %s\n' % n)
|
|
|
|
r = 1
|
|
|
|
sys.stdout.flush()
|
|
|
|
return r
|
|
|
|
|
2005-06-25 11:22:46 +04:00
|
|
|
def root(ui, repo):
|
|
|
|
"""print the root (top) of the current working dir"""
|
|
|
|
ui.write(repo.root + "\n")
|
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
def serve(ui, repo, **opts):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""export the repository via HTTP"""
|
2005-07-06 05:55:22 +04:00
|
|
|
|
|
|
|
if opts["stdio"]:
|
2005-07-07 10:20:12 +04:00
|
|
|
fin, fout = sys.stdin, sys.stdout
|
|
|
|
sys.stdout = sys.stderr
|
|
|
|
|
2005-07-06 05:55:22 +04:00
|
|
|
def getarg():
|
2005-07-07 10:20:12 +04:00
|
|
|
argline = fin.readline()[:-1]
|
2005-07-06 05:55:22 +04:00
|
|
|
arg, l = argline.split()
|
2005-07-07 10:20:12 +04:00
|
|
|
val = fin.read(int(l))
|
2005-07-06 05:55:22 +04:00
|
|
|
return arg, val
|
|
|
|
def respond(v):
|
2005-07-07 10:20:12 +04:00
|
|
|
fout.write("%d\n" % len(v))
|
|
|
|
fout.write(v)
|
|
|
|
fout.flush()
|
2005-07-06 05:55:22 +04:00
|
|
|
|
2005-07-07 10:23:27 +04:00
|
|
|
lock = None
|
|
|
|
|
2005-07-06 05:55:22 +04:00
|
|
|
while 1:
|
2005-07-07 10:20:12 +04:00
|
|
|
cmd = fin.readline()[:-1]
|
2005-07-06 05:55:22 +04:00
|
|
|
if cmd == '':
|
|
|
|
return
|
|
|
|
if cmd == "heads":
|
|
|
|
h = repo.heads()
|
|
|
|
respond(" ".join(map(hg.hex, h)) + "\n")
|
2005-07-07 10:23:27 +04:00
|
|
|
if cmd == "lock":
|
|
|
|
lock = repo.lock()
|
|
|
|
respond("")
|
|
|
|
if cmd == "unlock":
|
2005-07-14 13:42:28 +04:00
|
|
|
if lock:
|
|
|
|
lock.release()
|
2005-07-07 10:23:27 +04:00
|
|
|
lock = None
|
|
|
|
respond("")
|
2005-07-06 05:55:22 +04:00
|
|
|
elif cmd == "branches":
|
|
|
|
arg, nodes = getarg()
|
|
|
|
nodes = map(hg.bin, nodes.split(" "))
|
|
|
|
r = []
|
|
|
|
for b in repo.branches(nodes):
|
|
|
|
r.append(" ".join(map(hg.hex, b)) + "\n")
|
|
|
|
respond("".join(r))
|
|
|
|
elif cmd == "between":
|
|
|
|
arg, pairs = getarg()
|
2005-07-14 13:42:28 +04:00
|
|
|
pairs = [map(hg.bin, p.split("-")) for p in pairs.split(" ")]
|
2005-07-06 05:55:22 +04:00
|
|
|
r = []
|
|
|
|
for b in repo.between(pairs):
|
|
|
|
r.append(" ".join(map(hg.hex, b)) + "\n")
|
|
|
|
respond("".join(r))
|
|
|
|
elif cmd == "changegroup":
|
|
|
|
nodes = []
|
|
|
|
arg, roots = getarg()
|
|
|
|
nodes = map(hg.bin, roots.split(" "))
|
|
|
|
|
2005-07-07 10:20:12 +04:00
|
|
|
cg = repo.changegroup(nodes)
|
|
|
|
while 1:
|
|
|
|
d = cg.read(4096)
|
2005-07-14 13:42:28 +04:00
|
|
|
if not d:
|
|
|
|
break
|
2005-07-07 10:20:12 +04:00
|
|
|
fout.write(d)
|
|
|
|
|
2005-07-11 04:01:11 +04:00
|
|
|
fout.flush()
|
2005-07-06 05:55:22 +04:00
|
|
|
|
2005-07-07 10:23:57 +04:00
|
|
|
elif cmd == "addchangegroup":
|
|
|
|
if not lock:
|
|
|
|
respond("not locked")
|
|
|
|
continue
|
|
|
|
respond("")
|
|
|
|
|
|
|
|
r = repo.addchangegroup(fin)
|
|
|
|
respond("")
|
|
|
|
|
2005-07-04 08:51:05 +04:00
|
|
|
def openlog(opt, default):
|
2005-07-14 13:42:28 +04:00
|
|
|
if opts[opt] and opts[opt] != '-':
|
|
|
|
return open(opts[opt], 'w')
|
|
|
|
else:
|
|
|
|
return default
|
2005-07-06 05:55:22 +04:00
|
|
|
|
2005-07-04 08:47:29 +04:00
|
|
|
httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"],
|
2005-08-05 01:21:27 +04:00
|
|
|
opts["address"], opts["port"], opts["ipv6"],
|
2005-07-04 08:51:05 +04:00
|
|
|
openlog('accesslog', sys.stdout),
|
|
|
|
openlog('errorlog', sys.stderr))
|
2005-07-04 08:47:29 +04:00
|
|
|
if ui.verbose:
|
|
|
|
addr, port = httpd.socket.getsockname()
|
|
|
|
if addr == '0.0.0.0':
|
|
|
|
addr = socket.gethostname()
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
addr = socket.gethostbyaddr(addr)[0]
|
2005-07-14 13:42:28 +04:00
|
|
|
except socket.error:
|
|
|
|
pass
|
2005-07-04 08:47:29 +04:00
|
|
|
if port != 80:
|
2005-07-04 08:51:05 +04:00
|
|
|
ui.status('listening at http://%s:%d/\n' % (addr, port))
|
2005-07-04 08:47:29 +04:00
|
|
|
else:
|
2005-07-04 08:51:05 +04:00
|
|
|
ui.status('listening at http://%s/\n' % addr)
|
2005-07-04 08:47:29 +04:00
|
|
|
httpd.serve_forever()
|
2005-06-28 12:59:59 +04:00
|
|
|
|
2005-07-20 15:01:23 +04:00
|
|
|
def status(ui, repo, *pats, **opts):
|
2005-06-01 23:48:34 +04:00
|
|
|
'''show changed files in the working directory
|
|
|
|
|
2005-07-21 21:24:42 +04:00
|
|
|
M = modified
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
A = added
|
|
|
|
R = removed
|
2005-08-06 15:05:09 +04:00
|
|
|
? = not tracked
|
|
|
|
'''
|
2005-06-12 20:11:43 +04:00
|
|
|
|
Clean up walk and changes code to use normalised names properly.
New function: commands.pathto returns the relative path from one path
to another. For example, given foo/bar and baz/quux, it will return
../../baz/quux. This new function is used by the walk and status code
to print relative paths correctly.
New command: debugwalk exercises the walk code without doing anything
more.
hg.dirstate.walk now yields normalised names. For example, if you're
in the baz directory and you ask it to walk ../foo/bar/.., it will yield
names starting with foo/.
As a result of this change, all of the other walk and changes methods
in this module also return normalised names.
The util.matcher function now normalises globs and path names, so that
it will match normalised names properly.
Finally, util.matcher uses the non-glob prefix of a glob to tell walk
which directories to scan. Perviously, a glob like foo/* would scan
everything, but only return matches for foo/*. Now, foo/* only scans
under foo (using the globprefix function), which is much faster.
2005-08-01 05:42:46 +04:00
|
|
|
cwd = repo.getcwd()
|
2005-08-08 00:43:11 +04:00
|
|
|
files, matchfn = matchpats(repo, cwd, pats, opts)
|
2005-08-12 23:16:58 +04:00
|
|
|
(c, a, d, u) = [[util.pathto(cwd, x) for x in n]
|
2005-08-01 20:58:13 +04:00
|
|
|
for n in repo.changes(files=files, match=matchfn)]
|
2005-06-01 23:48:34 +04:00
|
|
|
|
2005-08-06 15:05:09 +04:00
|
|
|
changetypes = [('modified', 'M', c),
|
|
|
|
('added', 'A', a),
|
|
|
|
('removed', 'R', d),
|
|
|
|
('unknown', '?', u)]
|
|
|
|
|
|
|
|
for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
|
|
|
|
or changetypes):
|
|
|
|
for f in changes:
|
|
|
|
ui.write("%s %s\n" % (char, f))
|
2005-06-01 23:48:34 +04:00
|
|
|
|
2005-07-14 19:23:13 +04:00
|
|
|
def tag(ui, repo, name, rev=None, **opts):
|
2005-06-22 05:47:28 +04:00
|
|
|
"""add a tag for the current tip or a given revision"""
|
2005-07-22 19:27:30 +04:00
|
|
|
if opts['text']:
|
|
|
|
ui.warn("Warning: -t and --text is deprecated,"
|
|
|
|
" please use -m or --message instead.\n")
|
2005-06-22 05:47:28 +04:00
|
|
|
if name == "tip":
|
2005-07-03 06:29:54 +04:00
|
|
|
ui.warn("abort: 'tip' is a reserved name!\n")
|
|
|
|
return -1
|
2005-07-04 23:00:25 +04:00
|
|
|
if rev:
|
|
|
|
r = hg.hex(repo.lookup(rev))
|
|
|
|
else:
|
|
|
|
r = hg.hex(repo.changelog.tip())
|
|
|
|
|
2005-07-03 06:29:54 +04:00
|
|
|
if name.find(revrangesep) >= 0:
|
|
|
|
ui.warn("abort: '%s' cannot be used in a tag name\n" % revrangesep)
|
|
|
|
return -1
|
2005-06-22 05:47:28 +04:00
|
|
|
|
2005-07-04 23:00:25 +04:00
|
|
|
if opts['local']:
|
|
|
|
repo.opener("localtags", "a").write("%s %s\n" % (r, name))
|
|
|
|
return
|
|
|
|
|
2005-07-17 03:13:40 +04:00
|
|
|
(c, a, d, u) = repo.changes()
|
2005-06-22 05:47:28 +04:00
|
|
|
for x in (c, a, d, u):
|
2005-07-03 06:29:54 +04:00
|
|
|
if ".hgtags" in x:
|
|
|
|
ui.warn("abort: working copy of .hgtags is changed!\n")
|
2005-06-22 05:47:28 +04:00
|
|
|
ui.status("(please commit .hgtags manually)\n")
|
2005-07-03 06:29:54 +04:00
|
|
|
return -1
|
2005-06-22 05:47:28 +04:00
|
|
|
|
2005-07-05 00:39:21 +04:00
|
|
|
repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name))
|
2005-07-15 15:06:29 +04:00
|
|
|
if repo.dirstate.state(".hgtags") == '?':
|
2005-07-14 13:42:28 +04:00
|
|
|
repo.add([".hgtags"])
|
2005-06-22 05:47:28 +04:00
|
|
|
|
2005-07-22 19:26:46 +04:00
|
|
|
message = (opts['message'] or opts['text'] or
|
|
|
|
"Added tag %s for changeset %s" % (name, r))
|
|
|
|
repo.commit([".hgtags"], message, opts['user'], opts['date'])
|
2005-06-22 05:47:28 +04:00
|
|
|
|
2005-06-05 01:45:31 +04:00
|
|
|
def tags(ui, repo):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""list repository tags"""
|
2005-06-26 16:25:07 +04:00
|
|
|
|
2005-06-15 12:08:03 +04:00
|
|
|
l = repo.tagslist()
|
|
|
|
l.reverse()
|
2005-06-26 16:25:07 +04:00
|
|
|
for t, n in l:
|
2005-06-05 01:45:31 +04:00
|
|
|
try:
|
2005-06-26 16:25:07 +04:00
|
|
|
r = "%5d:%s" % (repo.changelog.rev(n), hg.hex(n))
|
2005-06-05 01:45:31 +04:00
|
|
|
except KeyError:
|
2005-06-26 16:25:07 +04:00
|
|
|
r = " ?:?"
|
|
|
|
ui.write("%-30s %s\n" % (t, r))
|
2005-06-05 01:45:31 +04:00
|
|
|
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
def tip(ui, repo):
|
2005-06-05 07:09:00 +04:00
|
|
|
"""show the tip revision"""
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
n = repo.changelog.tip()
|
2005-06-13 11:49:21 +04:00
|
|
|
show_changeset(ui, repo, changenode=n)
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
|
2005-06-01 23:11:19 +04:00
|
|
|
def undo(ui, repo):
|
2005-07-03 23:47:45 +04:00
|
|
|
"""undo the last commit or pull
|
|
|
|
|
|
|
|
Roll back the last pull or commit transaction on the
|
|
|
|
repository, restoring the project to its earlier state.
|
|
|
|
|
|
|
|
This command should be used with care. There is only one level of
|
|
|
|
undo and there is no redo.
|
|
|
|
|
|
|
|
This command is not intended for use on public repositories. Once
|
|
|
|
a change is visible for pull by other users, undoing it locally is
|
|
|
|
ineffective.
|
|
|
|
"""
|
2005-06-01 22:40:19 +04:00
|
|
|
repo.undo()
|
|
|
|
|
2005-08-15 00:23:45 +04:00
|
|
|
def update(ui, repo, node=None, merge=False, clean=False, branch=None):
|
2005-06-05 06:34:35 +04:00
|
|
|
'''update or merge working directory
|
|
|
|
|
|
|
|
If there are no outstanding changes in the working directory and
|
|
|
|
there is a linear relationship between the current version and the
|
|
|
|
requested version, the result is the requested version.
|
|
|
|
|
|
|
|
Otherwise the result is a merge between the contents of the
|
|
|
|
current working directory and the requested version. Files that
|
|
|
|
changed between either parent are marked as changed for the next
|
|
|
|
commit and a commit must be performed before any further updates
|
|
|
|
are allowed.
|
|
|
|
'''
|
2005-08-15 00:23:45 +04:00
|
|
|
if branch:
|
|
|
|
br = repo.branchlookup(branch=branch)
|
|
|
|
found = []
|
|
|
|
for x in br:
|
|
|
|
if branch in br[x]:
|
|
|
|
found.append(x)
|
|
|
|
if len(found) > 1:
|
|
|
|
ui.warn("Found multiple heads for %s\n" % branch)
|
|
|
|
for x in found:
|
|
|
|
show_changeset(ui, repo, changenode=x, brinfo=br)
|
|
|
|
return 1
|
|
|
|
if len(found) == 1:
|
|
|
|
node = found[0]
|
|
|
|
ui.warn("Using head %s for branch %s\n" % (hg.short(node), branch))
|
|
|
|
else:
|
|
|
|
ui.warn("branch %s not found\n" % (branch))
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
node = node and repo.lookup(node) or repo.changelog.tip()
|
2005-06-08 08:06:05 +04:00
|
|
|
return repo.update(node, allow=merge, force=clean)
|
2005-06-05 06:34:35 +04:00
|
|
|
|
2005-06-05 00:24:23 +04:00
|
|
|
def verify(ui, repo):
|
|
|
|
"""verify the integrity of the repository"""
|
|
|
|
return repo.verify()
|
|
|
|
|
2005-06-05 07:09:00 +04:00
|
|
|
# Command options and aliases are listed here, alphabetically
|
|
|
|
|
2005-06-01 12:25:42 +04:00
|
|
|
table = {
|
2005-08-06 10:16:37 +04:00
|
|
|
"^add":
|
|
|
|
(add,
|
|
|
|
[('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
"hg add [OPTION]... [FILE]..."),
|
2005-08-06 10:16:37 +04:00
|
|
|
"addremove":
|
|
|
|
(addremove,
|
|
|
|
[('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
|
|
|
"hg addremove [OPTION]... [FILE]..."),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^annotate":
|
|
|
|
(annotate,
|
2005-07-22 11:47:35 +04:00
|
|
|
[('r', 'rev', '', 'revision'),
|
2005-07-14 13:42:28 +04:00
|
|
|
('u', 'user', None, 'show user'),
|
|
|
|
('n', 'number', None, 'show revision number'),
|
2005-07-22 11:47:35 +04:00
|
|
|
('c', 'changeset', None, 'show changeset'),
|
|
|
|
('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
'hg annotate [OPTION]... FILE...'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"cat":
|
|
|
|
(cat,
|
|
|
|
[('o', 'output', "", 'output to file')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg cat [-o OUTFILE] FILE [REV]'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^clone":
|
|
|
|
(clone,
|
|
|
|
[('U', 'noupdate', None, 'skip update after cloning')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg clone [-U] SOURCE [DEST]'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^commit|ci":
|
|
|
|
(commit,
|
2005-07-15 12:38:57 +04:00
|
|
|
[('A', 'addremove', None, 'run add/remove during commit'),
|
2005-07-30 03:02:27 +04:00
|
|
|
('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search'),
|
2005-07-22 18:59:13 +04:00
|
|
|
('m', 'message', "", 'commit message'),
|
2005-07-22 11:47:35 +04:00
|
|
|
('t', 'text', "", 'commit message (deprecated: use -m)'),
|
2005-07-22 19:26:46 +04:00
|
|
|
('l', 'logfile', "", 'commit message file'),
|
2005-07-14 13:42:28 +04:00
|
|
|
('d', 'date', "", 'date code'),
|
|
|
|
('u', 'user', "", 'user')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg commit [OPTION]... [FILE]...'),
|
|
|
|
"copy": (copy, [], 'hg copy SOURCE DEST'),
|
2005-07-03 23:47:45 +04:00
|
|
|
"debugcheckstate": (debugcheckstate, [], 'debugcheckstate'),
|
|
|
|
"debugstate": (debugstate, [], 'debugstate'),
|
2005-07-15 12:38:57 +04:00
|
|
|
"debugindex": (debugindex, [], 'debugindex FILE'),
|
|
|
|
"debugindexdot": (debugindexdot, [], 'debugindexdot FILE'),
|
2005-08-06 10:16:37 +04:00
|
|
|
"debugwalk":
|
|
|
|
(debugwalk,
|
|
|
|
[('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
'debugwalk [OPTION]... [FILE]...'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^diff":
|
|
|
|
(diff,
|
2005-07-22 11:47:35 +04:00
|
|
|
[('r', 'rev', [], 'revision'),
|
|
|
|
('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
'hg diff [-I] [-X] [-r REV1 [-r REV2]] [FILE]...'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^export":
|
|
|
|
(export,
|
|
|
|
[('o', 'output', "", 'output to file')],
|
2005-07-15 12:38:57 +04:00
|
|
|
"hg export [-o OUTFILE] REV..."),
|
2005-08-06 10:16:37 +04:00
|
|
|
"forget":
|
|
|
|
(forget,
|
|
|
|
[('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
"hg forget [OPTION]... FILE..."),
|
2005-08-15 08:22:40 +04:00
|
|
|
"heads":
|
|
|
|
(heads,
|
|
|
|
[('b', 'branches', None, 'find branch info')],
|
|
|
|
'hg [-b] heads'),
|
2005-07-15 12:38:57 +04:00
|
|
|
"help": (help_, [], 'hg help [COMMAND]'),
|
2005-06-15 09:44:43 +04:00
|
|
|
"identify|id": (identify, [], 'hg identify'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"import|patch":
|
|
|
|
(import_,
|
|
|
|
[('p', 'strip', 1, 'path strip'),
|
|
|
|
('b', 'base', "", 'base path')],
|
2005-07-15 12:38:57 +04:00
|
|
|
"hg import [-p NUM] [-b BASE] PATCH..."),
|
2005-08-17 07:17:16 +04:00
|
|
|
"incoming": (incoming, [], 'hg incoming [SOURCE]'),
|
2005-08-15 09:33:09 +04:00
|
|
|
"^init": (init, [], 'hg init [DEST]'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"locate":
|
|
|
|
(locate,
|
2005-07-22 11:47:35 +04:00
|
|
|
[('r', 'rev', '', 'revision'),
|
|
|
|
('0', 'print0', None, 'end records with NUL'),
|
2005-07-14 13:42:28 +04:00
|
|
|
('f', 'fullpath', None, 'print complete paths'),
|
2005-07-18 18:54:21 +04:00
|
|
|
('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
'hg locate [OPTION]... [PATTERN]...'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^log|history":
|
|
|
|
(log,
|
|
|
|
[('r', 'rev', [], 'revision'),
|
|
|
|
('p', 'patch', None, 'show patch')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg log [-r REV1 [-r REV2]] [-p] [FILE]'),
|
|
|
|
"manifest": (manifest, [], 'hg manifest [REV]'),
|
2005-08-17 03:49:26 +04:00
|
|
|
"outgoing": (outgoing, [], 'hg outgoing [DEST]'),
|
2005-07-15 12:38:57 +04:00
|
|
|
"parents": (parents, [], 'hg parents [REV]'),
|
2005-08-17 05:30:41 +04:00
|
|
|
"paths": (paths, [], 'hg paths [NAME]'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^pull":
|
|
|
|
(pull,
|
|
|
|
[('u', 'update', None, 'update working directory')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg pull [-u] [SOURCE]'),
|
2005-08-02 11:34:23 +04:00
|
|
|
"^push":
|
|
|
|
(push,
|
|
|
|
[('f', 'force', None, 'force push')],
|
2005-08-16 22:42:30 +04:00
|
|
|
'hg push [-f] [DEST]'),
|
2005-07-14 13:42:28 +04:00
|
|
|
"rawcommit":
|
|
|
|
(rawcommit,
|
|
|
|
[('p', 'parent', [], 'parent'),
|
|
|
|
('d', 'date', "", 'date code'),
|
|
|
|
('u', 'user', "", 'user'),
|
|
|
|
('F', 'files', "", 'file list'),
|
2005-07-22 19:26:46 +04:00
|
|
|
('m', 'message', "", 'commit message'),
|
|
|
|
('t', 'text', "", 'commit message (deprecated: use -m)'),
|
|
|
|
('l', 'logfile', "", 'commit message file')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg rawcommit [OPTION]... [FILE]...'),
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
"recover": (recover, [], "hg recover"),
|
2005-07-15 12:38:57 +04:00
|
|
|
"^remove|rm": (remove, [], "hg remove FILE..."),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^revert":
|
|
|
|
(revert,
|
|
|
|
[("n", "nonrecursive", None, "don't recurse into subdirs"),
|
|
|
|
("r", "rev", "", "revision")],
|
2005-07-22 11:47:35 +04:00
|
|
|
"hg revert [-n] [-r REV] [NAME]..."),
|
2005-06-25 11:22:46 +04:00
|
|
|
"root": (root, [], "hg root"),
|
2005-07-14 13:42:28 +04:00
|
|
|
"^serve":
|
|
|
|
(serve,
|
|
|
|
[('A', 'accesslog', '', 'access log file'),
|
|
|
|
('E', 'errorlog', '', 'error log file'),
|
|
|
|
('p', 'port', 8000, 'listen port'),
|
|
|
|
('a', 'address', '', 'interface address'),
|
|
|
|
('n', 'name', os.getcwd(), 'repository name'),
|
|
|
|
('', 'stdio', None, 'for remote clients'),
|
2005-08-05 01:21:27 +04:00
|
|
|
('t', 'templates', "", 'template map'),
|
|
|
|
('6', 'ipv6', None, 'use IPv6 in addition to IPv4')],
|
2005-07-15 12:38:57 +04:00
|
|
|
"hg serve [OPTION]..."),
|
2005-08-06 10:09:10 +04:00
|
|
|
"^status":
|
|
|
|
(status,
|
|
|
|
[('m', 'modified', None, 'show only modified files'),
|
|
|
|
('a', 'added', None, 'show only added files'),
|
|
|
|
('r', 'removed', None, 'show only removed files'),
|
|
|
|
('u', 'unknown', None, 'show only unknown (not tracked) files'),
|
|
|
|
('I', 'include', [], 'include path in search'),
|
|
|
|
('X', 'exclude', [], 'exclude path from search')],
|
2005-08-16 22:42:30 +04:00
|
|
|
"hg status [OPTION]... [FILE]..."),
|
2005-07-14 13:42:28 +04:00
|
|
|
"tag":
|
|
|
|
(tag,
|
|
|
|
[('l', 'local', None, 'make the tag local'),
|
2005-07-22 19:26:46 +04:00
|
|
|
('m', 'message', "", 'commit message'),
|
|
|
|
('t', 'text', "", 'commit message (deprecated: use -m)'),
|
2005-07-14 13:42:28 +04:00
|
|
|
('d', 'date', "", 'date code'),
|
|
|
|
('u', 'user', "", 'user')],
|
2005-07-15 12:38:57 +04:00
|
|
|
'hg tag [OPTION]... NAME [REV]'),
|
2005-06-05 01:45:31 +04:00
|
|
|
"tags": (tags, [], 'hg tags'),
|
big heap of command clean-up work
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
big heap of command clean-up work
Migrate add, forget, remove, commit, diff, addremove, tip, log,
recover, and serve.
Fix up filterfiles, relfilter, and relpath to be a bit more bulletproof
Alphabetize functions and the command table
Make everything in commands.py relative-path aware
manifest hash: f0856031a7be4e49289677b467f29bcf24ebce4a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCof6gywK+sNU5EO8RAoW1AJsHu8vchPSjls7wVbvsq/UKlGhqtgCgtnnl
xSBxyf/TEVWjHIk3uTa8WSE=
=YPMl
-----END PGP SIGNATURE-----
2005-06-04 23:18:56 +04:00
|
|
|
"tip": (tip, [], 'hg tip'),
|
2005-06-01 22:40:19 +04:00
|
|
|
"undo": (undo, [], 'hg undo'),
|
2005-07-03 15:58:05 +04:00
|
|
|
"^update|up|checkout|co":
|
2005-07-14 13:42:28 +04:00
|
|
|
(update,
|
2005-08-15 00:23:45 +04:00
|
|
|
[('b', 'branch', "", 'checkout the head of a specific branch'),
|
|
|
|
('m', 'merge', None, 'allow merging of conflicts'),
|
2005-07-14 13:42:28 +04:00
|
|
|
('C', 'clean', None, 'overwrite locally modified files')],
|
2005-08-15 09:18:49 +04:00
|
|
|
'hg update [-b TAG] [-m] [-C] [REV]'),
|
2005-06-05 00:24:23 +04:00
|
|
|
"verify": (verify, [], 'hg verify'),
|
2005-06-25 12:16:39 +04:00
|
|
|
"version": (show_version, [], 'hg version'),
|
2005-06-01 12:25:42 +04:00
|
|
|
}
|
|
|
|
|
2005-08-06 16:27:31 +04:00
|
|
|
globalopts = [('v', 'verbose', None, 'verbose mode'),
|
|
|
|
('', 'debug', None, 'debug mode'),
|
|
|
|
('q', 'quiet', None, 'quiet mode'),
|
2005-07-03 23:47:45 +04:00
|
|
|
('', 'profile', None, 'profile'),
|
|
|
|
('R', 'repository', "", 'repository root directory'),
|
|
|
|
('', 'traceback', None, 'print traceback on exception'),
|
|
|
|
('y', 'noninteractive', None, 'run non-interactively'),
|
|
|
|
('', 'version', None, 'output version information and exit'),
|
2005-07-27 22:18:44 +04:00
|
|
|
('', 'time', None, 'time how long the command takes'),
|
2005-07-14 13:42:28 +04:00
|
|
|
]
|
2005-07-03 23:47:45 +04:00
|
|
|
|
2005-08-17 01:52:28 +04:00
|
|
|
norepo = "clone init version help debugindex debugindexdot paths"
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-06-01 23:11:19 +04:00
|
|
|
def find(cmd):
|
|
|
|
for e in table.keys():
|
2005-06-15 05:06:57 +04:00
|
|
|
if re.match("(%s)$" % e, cmd):
|
2005-08-06 18:43:12 +04:00
|
|
|
return e, table[e]
|
2005-06-01 23:11:19 +04:00
|
|
|
|
|
|
|
raise UnknownCommand(cmd)
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
class SignalInterrupt(Exception):
|
|
|
|
"""Exception raised on SIGTERM and SIGHUP."""
|
2005-06-02 01:04:13 +04:00
|
|
|
|
|
|
|
def catchterm(*args):
|
|
|
|
raise SignalInterrupt
|
|
|
|
|
2005-06-05 02:16:32 +04:00
|
|
|
def run():
|
|
|
|
sys.exit(dispatch(sys.argv[1:]))
|
|
|
|
|
2005-07-14 13:42:28 +04:00
|
|
|
class ParseError(Exception):
|
|
|
|
"""Exception raised on errors in parsing the command line."""
|
2005-07-03 15:33:48 +04:00
|
|
|
|
2005-07-03 23:47:45 +04:00
|
|
|
def parse(args):
|
2005-06-01 12:25:42 +04:00
|
|
|
options = {}
|
2005-07-03 23:47:45 +04:00
|
|
|
cmdoptions = {}
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-03 15:33:48 +04:00
|
|
|
try:
|
2005-07-03 23:47:45 +04:00
|
|
|
args = fancyopts.fancyopts(args, globalopts, options)
|
2005-07-03 15:33:48 +04:00
|
|
|
except fancyopts.getopt.GetoptError, inst:
|
2005-07-05 00:39:35 +04:00
|
|
|
raise ParseError(None, inst)
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-03 23:47:45 +04:00
|
|
|
if options["version"]:
|
|
|
|
return ("version", show_version, [], options, cmdoptions)
|
|
|
|
elif not args:
|
2005-08-06 16:27:31 +04:00
|
|
|
return ("help", help_, ["shortlist"], options, cmdoptions)
|
2005-06-01 12:25:42 +04:00
|
|
|
else:
|
|
|
|
cmd, args = args[0], args[1:]
|
|
|
|
|
2005-08-06 18:43:12 +04:00
|
|
|
i = find(cmd)[1]
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-03 15:33:48 +04:00
|
|
|
# combine global options into local
|
|
|
|
c = list(i[1])
|
2005-07-03 23:47:45 +04:00
|
|
|
for o in globalopts:
|
2005-07-03 15:33:48 +04:00
|
|
|
c.append((o[0], o[1], options[o[1]], o[3]))
|
2005-06-02 01:04:13 +04:00
|
|
|
|
2005-06-09 08:11:57 +04:00
|
|
|
try:
|
2005-07-03 23:47:45 +04:00
|
|
|
args = fancyopts.fancyopts(args, c, cmdoptions)
|
2005-06-09 08:11:57 +04:00
|
|
|
except fancyopts.getopt.GetoptError, inst:
|
2005-07-03 23:47:45 +04:00
|
|
|
raise ParseError(cmd, inst)
|
2005-06-01 12:25:42 +04:00
|
|
|
|
2005-07-03 15:33:48 +04:00
|
|
|
# separate global options back out
|
2005-07-03 23:47:45 +04:00
|
|
|
for o in globalopts:
|
2005-07-03 15:33:48 +04:00
|
|
|
n = o[1]
|
|
|
|
options[n] = cmdoptions[n]
|
|
|
|
del cmdoptions[n]
|
|
|
|
|
2005-07-03 23:47:45 +04:00
|
|
|
return (cmd, i[0], args, options, cmdoptions)
|
|
|
|
|
|
|
|
def dispatch(args):
|
|
|
|
signal.signal(signal.SIGTERM, catchterm)
|
2005-07-14 13:42:28 +04:00
|
|
|
try:
|
|
|
|
signal.signal(signal.SIGHUP, catchterm)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
2005-07-03 23:47:45 +04:00
|
|
|
|
|
|
|
try:
|
|
|
|
cmd, func, args, options, cmdoptions = parse(args)
|
|
|
|
except ParseError, inst:
|
|
|
|
u = ui.ui()
|
|
|
|
if inst.args[0]:
|
|
|
|
u.warn("hg %s: %s\n" % (inst.args[0], inst.args[1]))
|
2005-07-14 13:42:28 +04:00
|
|
|
help_(u, inst.args[0])
|
2005-07-03 23:47:45 +04:00
|
|
|
else:
|
|
|
|
u.warn("hg: %s\n" % inst.args[1])
|
2005-08-06 17:04:59 +04:00
|
|
|
help_(u, 'shortlist')
|
2005-07-03 23:47:45 +04:00
|
|
|
sys.exit(-1)
|
|
|
|
except UnknownCommand, inst:
|
|
|
|
u = ui.ui()
|
|
|
|
u.warn("hg: unknown command '%s'\n" % inst.args[0])
|
2005-08-06 17:04:59 +04:00
|
|
|
help_(u, 'shortlist')
|
2005-07-03 23:47:45 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
2005-07-27 22:18:44 +04:00
|
|
|
if options["time"]:
|
|
|
|
def get_times():
|
|
|
|
t = os.times()
|
|
|
|
if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
|
|
|
|
t = (t[0], t[1], t[2], t[3], time.clock())
|
|
|
|
return t
|
|
|
|
s = get_times()
|
|
|
|
def print_time():
|
|
|
|
t = get_times()
|
|
|
|
u = ui.ui()
|
|
|
|
u.warn("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n" %
|
|
|
|
(t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
|
|
|
|
atexit.register(print_time)
|
|
|
|
|
2005-07-03 23:47:45 +04:00
|
|
|
u = ui.ui(options["verbose"], options["debug"], options["quiet"],
|
2005-07-14 13:42:28 +04:00
|
|
|
not options["noninteractive"])
|
2005-07-03 15:33:48 +04:00
|
|
|
|
2005-06-01 12:25:42 +04:00
|
|
|
try:
|
2005-06-30 02:20:54 +04:00
|
|
|
try:
|
|
|
|
if cmd not in norepo.split():
|
|
|
|
path = options["repository"] or ""
|
|
|
|
repo = hg.repository(ui=u, path=path)
|
2005-07-03 23:47:45 +04:00
|
|
|
d = lambda: func(u, repo, *args, **cmdoptions)
|
2005-06-30 02:20:54 +04:00
|
|
|
else:
|
2005-07-03 23:47:45 +04:00
|
|
|
d = lambda: func(u, *args, **cmdoptions)
|
2005-06-30 02:20:54 +04:00
|
|
|
|
|
|
|
if options['profile']:
|
|
|
|
import hotshot, hotshot.stats
|
|
|
|
prof = hotshot.Profile("hg.prof")
|
|
|
|
r = prof.runcall(d)
|
|
|
|
prof.close()
|
|
|
|
stats = hotshot.stats.load("hg.prof")
|
|
|
|
stats.strip_dirs()
|
|
|
|
stats.sort_stats('time', 'calls')
|
|
|
|
stats.print_stats(40)
|
|
|
|
return r
|
|
|
|
else:
|
|
|
|
return d()
|
|
|
|
except:
|
|
|
|
if options['traceback']:
|
|
|
|
traceback.print_exc()
|
|
|
|
raise
|
2005-06-28 12:55:59 +04:00
|
|
|
except hg.RepoError, inst:
|
|
|
|
u.warn("abort: ", inst, "!\n")
|
2005-06-02 01:04:13 +04:00
|
|
|
except SignalInterrupt:
|
|
|
|
u.warn("killed!\n")
|
2005-06-01 12:25:42 +04:00
|
|
|
except KeyboardInterrupt:
|
2005-08-04 21:06:49 +04:00
|
|
|
try:
|
|
|
|
u.warn("interrupted!\n")
|
|
|
|
except IOError, inst:
|
|
|
|
if inst.errno == errno.EPIPE:
|
|
|
|
if u.debugflag:
|
|
|
|
u.warn("\nbroken pipe\n")
|
|
|
|
else:
|
|
|
|
raise
|
2005-06-05 02:25:08 +04:00
|
|
|
except IOError, inst:
|
2005-06-17 23:03:44 +04:00
|
|
|
if hasattr(inst, "code"):
|
|
|
|
u.warn("abort: %s\n" % inst)
|
|
|
|
elif hasattr(inst, "reason"):
|
2005-07-27 06:52:40 +04:00
|
|
|
u.warn("abort: error: %s\n" % inst.reason[1])
|
2005-06-17 23:03:44 +04:00
|
|
|
elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
|
2005-07-15 06:41:36 +04:00
|
|
|
if u.debugflag: u.warn("broken pipe\n")
|
2005-06-05 02:25:08 +04:00
|
|
|
else:
|
|
|
|
raise
|
2005-07-01 11:45:43 +04:00
|
|
|
except OSError, inst:
|
|
|
|
if hasattr(inst, "filename"):
|
|
|
|
u.warn("abort: %s: %s\n" % (inst.strerror, inst.filename))
|
|
|
|
else:
|
|
|
|
u.warn("abort: %s\n" % inst.strerror)
|
2005-08-08 00:43:11 +04:00
|
|
|
except util.Abort, inst:
|
2005-07-19 19:42:36 +04:00
|
|
|
u.warn('abort: ', inst.args[0] % inst.args[1:], '\n')
|
|
|
|
sys.exit(1)
|
2005-06-01 23:11:19 +04:00
|
|
|
except TypeError, inst:
|
|
|
|
# was this an argument error?
|
|
|
|
tb = traceback.extract_tb(sys.exc_info()[2])
|
|
|
|
if len(tb) > 2: # no
|
|
|
|
raise
|
2005-06-09 08:11:57 +04:00
|
|
|
u.debug(inst, "\n")
|
2005-07-03 23:47:45 +04:00
|
|
|
u.warn("%s: invalid arguments\n" % cmd)
|
2005-07-14 13:42:28 +04:00
|
|
|
help_(u, cmd)
|
2005-08-06 17:04:59 +04:00
|
|
|
except UnknownCommand, inst:
|
|
|
|
u.warn("hg: unknown command '%s'\n" % inst.args[0])
|
|
|
|
help_(u, 'shortlist')
|
2005-06-28 14:08:14 +04:00
|
|
|
|
|
|
|
sys.exit(-1)
|