Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 7402:bffdab64dfbb
import: add similarity option (issue295)
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sat, 22 Nov 2008 00:21:57 -0800 |
parents | e17dbf140035 |
children | 040484030491 |
comparison
equal
deleted
inserted
replaced
7401:41e87b4d0c9d | 7402:bffdab64dfbb |
---|---|
1579 to the parent of each patch before applying it, and will abort | 1579 to the parent of each patch before applying it, and will abort |
1580 if the resulting changeset has a different ID than the one | 1580 if the resulting changeset has a different ID than the one |
1581 recorded in the patch. This may happen due to character set | 1581 recorded in the patch. This may happen due to character set |
1582 problems or other deficiencies in the text patch format. | 1582 problems or other deficiencies in the text patch format. |
1583 | 1583 |
1584 With --similarity, hg will attempt to discover renames and copies | |
1585 in the patch in the same way as 'addremove'. | |
1586 | |
1584 To read a patch from standard input, use patch name "-". | 1587 To read a patch from standard input, use patch name "-". |
1585 See 'hg help dates' for a list of formats valid for -d/--date. | 1588 See 'hg help dates' for a list of formats valid for -d/--date. |
1586 """ | 1589 """ |
1587 patches = (patch1,) + patches | 1590 patches = (patch1,) + patches |
1588 | 1591 |
1589 date = opts.get('date') | 1592 date = opts.get('date') |
1590 if date: | 1593 if date: |
1591 opts['date'] = util.parsedate(date) | 1594 opts['date'] = util.parsedate(date) |
1595 | |
1596 try: | |
1597 sim = float(opts.get('similarity') or 0) | |
1598 except ValueError: | |
1599 raise util.Abort(_('similarity must be a number')) | |
1600 if sim < 0 or sim > 100: | |
1601 raise util.Abort(_('similarity must be between 0 and 100')) | |
1592 | 1602 |
1593 if opts.get('exact') or not opts.get('force'): | 1603 if opts.get('exact') or not opts.get('force'): |
1594 cmdutil.bail_if_changed(repo) | 1604 cmdutil.bail_if_changed(repo) |
1595 | 1605 |
1596 d = opts["base"] | 1606 d = opts["base"] |
1651 files = {} | 1661 files = {} |
1652 try: | 1662 try: |
1653 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root, | 1663 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root, |
1654 files=files) | 1664 files=files) |
1655 finally: | 1665 finally: |
1656 files = patch.updatedir(ui, repo, files) | 1666 files = patch.updatedir(ui, repo, files, similarity=sim/100.) |
1657 if not opts.get('no_commit'): | 1667 if not opts.get('no_commit'): |
1658 n = repo.commit(files, message, opts.get('user') or user, | 1668 n = repo.commit(files, message, opts.get('user') or user, |
1659 opts.get('date') or date) | 1669 opts.get('date') or date) |
1660 if opts.get('exact'): | 1670 if opts.get('exact'): |
1661 if hex(n) != nodeid: | 1671 if hex(n) != nodeid: |
3001 ('B', 'ignore-blank-lines', None, | 3011 ('B', 'ignore-blank-lines', None, |
3002 _('ignore changes whose lines are all blank')), | 3012 _('ignore changes whose lines are all blank')), |
3003 ('U', 'unified', '', _('number of lines of context to show')) | 3013 ('U', 'unified', '', _('number of lines of context to show')) |
3004 ] | 3014 ] |
3005 | 3015 |
3016 similarityopts = [ | |
3017 ('s', 'similarity', '', | |
3018 _('guess renamed files by similarity (0<=s<=100)')) | |
3019 ] | |
3020 | |
3006 table = { | 3021 table = { |
3007 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')), | 3022 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')), |
3008 "addremove": | 3023 "addremove": |
3009 (addremove, | 3024 (addremove, similarityopts + walkopts + dryrunopts, |
3010 [('s', 'similarity', '', | |
3011 _('guess renamed files by similarity (0<=s<=100)')), | |
3012 ] + walkopts + dryrunopts, | |
3013 _('[OPTION]... [FILE]...')), | 3025 _('[OPTION]... [FILE]...')), |
3014 "^annotate|blame": | 3026 "^annotate|blame": |
3015 (annotate, | 3027 (annotate, |
3016 [('r', 'rev', '', _('annotate the specified revision')), | 3028 [('r', 'rev', '', _('annotate the specified revision')), |
3017 ('f', 'follow', None, _('follow file copies and renames')), | 3029 ('f', 'follow', None, _('follow file copies and renames')), |
3190 ('', 'no-commit', None, _("don't commit, just update the working directory")), | 3202 ('', 'no-commit', None, _("don't commit, just update the working directory")), |
3191 ('', 'exact', None, | 3203 ('', 'exact', None, |
3192 _('apply patch to the nodes from which it was generated')), | 3204 _('apply patch to the nodes from which it was generated')), |
3193 ('', 'import-branch', None, | 3205 ('', 'import-branch', None, |
3194 _('Use any branch information in patch (implied by --exact)'))] + | 3206 _('Use any branch information in patch (implied by --exact)'))] + |
3195 commitopts + commitopts2, | 3207 commitopts + commitopts2 + similarityopts, |
3196 _('[OPTION]... PATCH...')), | 3208 _('[OPTION]... PATCH...')), |
3197 "incoming|in": | 3209 "incoming|in": |
3198 (incoming, | 3210 (incoming, |
3199 [('f', 'force', None, | 3211 [('f', 'force', None, |
3200 _('run even when remote repository is unrelated')), | 3212 _('run even when remote repository is unrelated')), |