equal
deleted
inserted
replaced
|
1 # debugcommands.py - command processing for debug* commands |
|
2 # |
|
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com> |
|
4 # |
|
5 # This software may be used and distributed according to the terms of the |
|
6 # GNU General Public License version 2 or any later version. |
|
7 |
|
8 from __future__ import absolute_import |
|
9 |
|
10 import os |
|
11 |
|
12 from .i18n import _ |
|
13 from . import ( |
|
14 cmdutil, |
|
15 commands, |
|
16 error, |
|
17 revlog, |
|
18 scmutil, |
|
19 ) |
|
20 |
|
21 # We reuse the command table from commands because it is easier than |
|
22 # teaching dispatch about multiple tables. |
|
23 command = cmdutil.command(commands.table) |
|
24 |
|
25 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) |
|
26 def debugancestor(ui, repo, *args): |
|
27 """find the ancestor revision of two revisions in a given index""" |
|
28 if len(args) == 3: |
|
29 index, rev1, rev2 = args |
|
30 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index) |
|
31 lookup = r.lookup |
|
32 elif len(args) == 2: |
|
33 if not repo: |
|
34 raise error.Abort(_('there is no Mercurial repository here ' |
|
35 '(.hg not found)')) |
|
36 rev1, rev2 = args |
|
37 r = repo.changelog |
|
38 lookup = repo.lookup |
|
39 else: |
|
40 raise error.Abort(_('either two or three arguments required')) |
|
41 a = r.ancestor(lookup(rev1), lookup(rev2)) |
|
42 ui.write('%d:%s\n' % (r.rev(a), hex(a))) |