11 import os, re, sys, urllib |
11 import os, re, sys, urllib |
12 import hg, util, revlog, bundlerepo, extensions, copies |
12 import hg, util, revlog, bundlerepo, extensions, copies |
13 import difflib, patch, time, help, mdiff, tempfile |
13 import difflib, patch, time, help, mdiff, tempfile |
14 import version, socket |
14 import version, socket |
15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
|
16 import merge as merge_ |
16 |
17 |
17 # Commands start here, listed alphabetically |
18 # Commands start here, listed alphabetically |
18 |
19 |
19 def add(ui, repo, *pats, **opts): |
20 def add(ui, repo, *pats, **opts): |
20 """add the specified files on the next commit |
21 """add the specified files on the next commit |
2233 wlock = repo.wlock(False) |
2234 wlock = repo.wlock(False) |
2234 try: |
2235 try: |
2235 return cmdutil.copy(ui, repo, pats, opts, rename=True) |
2236 return cmdutil.copy(ui, repo, pats, opts, rename=True) |
2236 finally: |
2237 finally: |
2237 del wlock |
2238 del wlock |
|
2239 |
|
2240 def resolve(ui, repo, *pats, **opts): |
|
2241 """resolve file merges from a branch merge or update |
|
2242 |
|
2243 This command will attempt to resolve unresolved merges from the |
|
2244 last update or merge command. This will use the local file |
|
2245 revision preserved at the last update or merge to cleanly retry |
|
2246 the file merge attempt. With no file or options specified, this |
|
2247 command will attempt to resolve all unresolved files. |
|
2248 """ |
|
2249 |
|
2250 if len([x for x in opts if opts[x]]) > 1: |
|
2251 raise util.Abort(_("too many options specified")) |
|
2252 |
|
2253 ms = merge_.mergestate(repo) |
|
2254 mf = util.matcher(repo.root, "", pats, [], [])[1] |
|
2255 |
|
2256 for f in ms: |
|
2257 if mf(f): |
|
2258 if opts.get("list"): |
|
2259 ui.write("%s %s\n" % (ms[f].upper(), f)) |
|
2260 elif opts.get("mark"): |
|
2261 ms.mark(f, "r") |
|
2262 elif opts.get("unmark"): |
|
2263 ms.mark(f, "u") |
|
2264 else: |
|
2265 wctx = repo.workingctx() |
|
2266 mctx = wctx.parents()[-1] |
|
2267 ms.resolve(f, wctx, mctx) |
2238 |
2268 |
2239 def revert(ui, repo, *pats, **opts): |
2269 def revert(ui, repo, *pats, **opts): |
2240 """restore individual files or dirs to an earlier state |
2270 """restore individual files or dirs to an earlier state |
2241 |
2271 |
2242 (use update -r to check out earlier revisions, revert does not |
2272 (use update -r to check out earlier revisions, revert does not |
3194 [('A', 'after', None, _('record a rename that has already occurred')), |
3224 [('A', 'after', None, _('record a rename that has already occurred')), |
3195 ('f', 'force', None, |
3225 ('f', 'force', None, |
3196 _('forcibly copy over an existing managed file')), |
3226 _('forcibly copy over an existing managed file')), |
3197 ] + walkopts + dryrunopts, |
3227 ] + walkopts + dryrunopts, |
3198 _('hg rename [OPTION]... SOURCE... DEST')), |
3228 _('hg rename [OPTION]... SOURCE... DEST')), |
|
3229 "resolve": |
|
3230 (resolve, |
|
3231 [('l', 'list', None, _('list state of files needing merge')), |
|
3232 ('m', 'mark', None, _('mark files as resolved')), |
|
3233 ('u', 'unmark', None, _('unmark files as resolved'))], |
|
3234 ('hg resolve [OPTION] [FILES...]')), |
3199 "revert": |
3235 "revert": |
3200 (revert, |
3236 (revert, |
3201 [('a', 'all', None, _('revert all changes when no arguments given')), |
3237 [('a', 'all', None, _('revert all changes when no arguments given')), |
3202 ('d', 'date', '', _('tipmost revision matching date')), |
3238 ('d', 'date', '', _('tipmost revision matching date')), |
3203 ('r', 'rev', '', _('revision to revert to')), |
3239 ('r', 'rev', '', _('revision to revert to')), |