3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
4 # |
4 # |
5 # This software may be used and distributed according to the terms of the |
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. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from node import hex, bin, nullid, nullrev, short |
8 from __future__ import absolute_import |
9 from i18n import _ |
9 |
10 import os, sys, errno, re, tempfile, cStringIO |
10 import cStringIO |
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies |
11 import errno |
12 import match as matchmod |
12 import os |
13 import repair, graphmod, revset, phases, obsolete, pathutil |
13 import re |
14 import changelog |
14 import sys |
15 import bookmarks |
15 import tempfile |
16 import encoding |
16 |
17 import formatter |
17 from .i18n import _ |
18 import crecord as crecordmod |
18 from .node import ( |
19 import lock as lockmod |
19 bin, |
|
20 hex, |
|
21 nullid, |
|
22 nullrev, |
|
23 short, |
|
24 ) |
|
25 |
|
26 from . import ( |
|
27 bookmarks, |
|
28 changelog, |
|
29 copies, |
|
30 crecord as crecordmod, |
|
31 encoding, |
|
32 error, |
|
33 formatter, |
|
34 graphmod, |
|
35 lock as lockmod, |
|
36 match as matchmod, |
|
37 obsolete, |
|
38 patch, |
|
39 pathutil, |
|
40 phases, |
|
41 repair, |
|
42 revlog, |
|
43 revset, |
|
44 scmutil, |
|
45 templatekw, |
|
46 templater, |
|
47 util, |
|
48 ) |
20 |
49 |
21 def ishunk(x): |
50 def ishunk(x): |
22 hunkclasses = (crecordmod.uihunk, patch.recordhunk) |
51 hunkclasses = (crecordmod.uihunk, patch.recordhunk) |
23 return isinstance(x, hunkclasses) |
52 return isinstance(x, hunkclasses) |
24 |
53 |
76 ui.write = oldwrite |
105 ui.write = oldwrite |
77 return newchunks, newopts |
106 return newchunks, newopts |
78 |
107 |
79 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, |
108 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, |
80 filterfn, *pats, **opts): |
109 filterfn, *pats, **opts): |
81 import merge as mergemod |
110 from . import merge as mergemod |
82 |
|
83 if not ui.interactive(): |
111 if not ui.interactive(): |
84 if cmdsuggest: |
112 if cmdsuggest: |
85 msg = _('running non-interactively, use %s instead') % cmdsuggest |
113 msg = _('running non-interactively, use %s instead') % cmdsuggest |
86 else: |
114 else: |
87 msg = _('running non-interactively') |
115 msg = _('running non-interactively') |
865 (used in case we need to save it when failing) |
893 (used in case we need to save it when failing) |
866 :updatefunc: a function that update a repo to a given node |
894 :updatefunc: a function that update a repo to a given node |
867 updatefunc(<repo>, <node>) |
895 updatefunc(<repo>, <node>) |
868 """ |
896 """ |
869 # avoid cycle context -> subrepo -> cmdutil |
897 # avoid cycle context -> subrepo -> cmdutil |
870 import context |
898 from . import context |
871 extractdata = patch.extract(ui, hunk) |
899 extractdata = patch.extract(ui, hunk) |
872 tmpname = extractdata.get('filename') |
900 tmpname = extractdata.get('filename') |
873 message = extractdata.get('message') |
901 message = extractdata.get('message') |
874 user = opts.get('user') or extractdata.get('user') |
902 user = opts.get('user') or extractdata.get('user') |
875 date = opts.get('date') or extractdata.get('date') |
903 date = opts.get('date') or extractdata.get('date') |
2505 |
2533 |
2506 return commitfunc(ui, repo, message, matcher, opts) |
2534 return commitfunc(ui, repo, message, matcher, opts) |
2507 |
2535 |
2508 def amend(ui, repo, commitfunc, old, extra, pats, opts): |
2536 def amend(ui, repo, commitfunc, old, extra, pats, opts): |
2509 # avoid cycle context -> subrepo -> cmdutil |
2537 # avoid cycle context -> subrepo -> cmdutil |
2510 import context |
2538 from . import context |
2511 |
2539 |
2512 # amend will reuse the existing user if not specified, but the obsolete |
2540 # amend will reuse the existing user if not specified, but the obsolete |
2513 # marker creation requires that the current user's name is specified. |
2541 # marker creation requires that the current user's name is specified. |
2514 if obsolete.isenabled(repo, obsolete.createmarkersopt): |
2542 if obsolete.isenabled(repo, obsolete.createmarkersopt): |
2515 ui.username() # raise exception if username not set |
2543 ui.username() # raise exception if username not set |