Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 4271:94bb953b43e5
Merge with crew
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 23 Mar 2007 01:04:21 -0500 |
parents | b11a2fb59cf5 bda63383d529 |
children | f38f90a177dc |
comparison
equal
deleted
inserted
replaced
4270:cd7b36b7869c | 4271:94bb953b43e5 |
---|---|
1474 text/x-patch to be used). From and Subject headers of email | 1474 text/x-patch to be used). From and Subject headers of email |
1475 message are used as default committer and commit message. All | 1475 message are used as default committer and commit message. All |
1476 text/plain body parts before first diff are added to commit | 1476 text/plain body parts before first diff are added to commit |
1477 message. | 1477 message. |
1478 | 1478 |
1479 If imported patch was generated by hg export, user and description | 1479 If the imported patch was generated by hg export, user and description |
1480 from patch override values from message headers and body. Values | 1480 from patch override values from message headers and body. Values |
1481 given on command line with -m and -u override these. | 1481 given on command line with -m and -u override these. |
1482 | 1482 |
1483 If --exact is specified, import will set the working directory | |
1484 to the parent of each patch before applying it, and will abort | |
1485 if the resulting changeset has a different ID than the one | |
1486 recorded in the patch. This may happen due to character set | |
1487 problems or other deficiencies in the text patch format. | |
1488 | |
1483 To read a patch from standard input, use patch name "-". | 1489 To read a patch from standard input, use patch name "-". |
1484 """ | 1490 """ |
1485 patches = (patch1,) + patches | 1491 patches = (patch1,) + patches |
1486 | 1492 |
1487 if not opts['force']: | 1493 if opts.get('exact') or not opts['force']: |
1488 bail_if_changed(repo) | 1494 bail_if_changed(repo) |
1489 | 1495 |
1490 d = opts["base"] | 1496 d = opts["base"] |
1491 strip = opts["strip"] | 1497 strip = opts["strip"] |
1492 | 1498 |
1496 for p in patches: | 1502 for p in patches: |
1497 pf = os.path.join(d, p) | 1503 pf = os.path.join(d, p) |
1498 | 1504 |
1499 if pf == '-': | 1505 if pf == '-': |
1500 ui.status(_("applying patch from stdin\n")) | 1506 ui.status(_("applying patch from stdin\n")) |
1501 tmpname, message, user, date = patch.extract(ui, sys.stdin) | 1507 tmpname, message, user, date, nodeid, p1, p2 = patch.extract(ui, sys.stdin) |
1502 else: | 1508 else: |
1503 ui.status(_("applying %s\n") % p) | 1509 ui.status(_("applying %s\n") % p) |
1504 tmpname, message, user, date = patch.extract(ui, file(pf)) | 1510 tmpname, message, user, date, nodeid, p1, p2 = patch.extract(ui, file(pf)) |
1505 | 1511 |
1506 if tmpname is None: | 1512 if tmpname is None: |
1507 raise util.Abort(_('no diffs found')) | 1513 raise util.Abort(_('no diffs found')) |
1508 | 1514 |
1509 try: | 1515 try: |
1517 else: | 1523 else: |
1518 # launch the editor | 1524 # launch the editor |
1519 message = None | 1525 message = None |
1520 ui.debug(_('message:\n%s\n') % message) | 1526 ui.debug(_('message:\n%s\n') % message) |
1521 | 1527 |
1528 wp = repo.workingctx().parents() | |
1529 if opts.get('exact'): | |
1530 if not nodeid or not p1: | |
1531 raise util.Abort(_('not a mercurial patch')) | |
1532 p1 = repo.lookup(p1) | |
1533 p2 = repo.lookup(p2 or hex(nullid)) | |
1534 | |
1535 if p1 != wp[0].node(): | |
1536 hg.clean(repo, p1, wlock=wlock) | |
1537 repo.dirstate.setparents(p1, p2) | |
1538 elif p2: | |
1539 try: | |
1540 p1 = repo.lookup(p1) | |
1541 p2 = repo.lookup(p2) | |
1542 if p1 == wp[0].node(): | |
1543 repo.dirstate.setparents(p1, p2) | |
1544 except RepoError: | |
1545 pass | |
1546 | |
1522 files = {} | 1547 files = {} |
1523 try: | 1548 try: |
1524 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root, | 1549 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root, |
1525 files=files) | 1550 files=files) |
1526 finally: | 1551 finally: |
1527 files = patch.updatedir(ui, repo, files, wlock=wlock) | 1552 files = patch.updatedir(ui, repo, files, wlock=wlock) |
1528 repo.commit(files, message, user, date, wlock=wlock, lock=lock) | 1553 n = repo.commit(files, message, user, date, wlock=wlock, lock=lock) |
1554 if opts.get('exact'): | |
1555 if hex(n) != nodeid: | |
1556 repo.rollback() | |
1557 raise util.Abort(_('patch is damaged or loses information')) | |
1529 finally: | 1558 finally: |
1530 os.unlink(tmpname) | 1559 os.unlink(tmpname) |
1531 | 1560 |
1532 def incoming(ui, repo, source="default", **opts): | 1561 def incoming(ui, repo, source="default", **opts): |
1533 """show new changesets found in source | 1562 """show new changesets found in source |
2769 [('p', 'strip', 1, | 2798 [('p', 'strip', 1, |
2770 _('directory strip option for patch. This has the same\n' | 2799 _('directory strip option for patch. This has the same\n' |
2771 'meaning as the corresponding patch option')), | 2800 'meaning as the corresponding patch option')), |
2772 ('b', 'base', '', _('base path')), | 2801 ('b', 'base', '', _('base path')), |
2773 ('f', 'force', None, | 2802 ('f', 'force', None, |
2774 _('skip check for outstanding uncommitted changes'))] + commitopts, | 2803 _('skip check for outstanding uncommitted changes')), |
2804 ('', 'exact', None, | |
2805 _('apply patch to the nodes from which it was generated'))] + commitopts, | |
2775 _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')), | 2806 _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')), |
2776 "incoming|in": (incoming, | 2807 "incoming|in": (incoming, |
2777 [('M', 'no-merges', None, _('do not show merges')), | 2808 [('M', 'no-merges', None, _('do not show merges')), |
2778 ('f', 'force', None, | 2809 ('f', 'force', None, |
2779 _('run even when remote repository is unrelated')), | 2810 _('run even when remote repository is unrelated')), |