mercurial/commands.py
changeset 6048 cfb4a51da7d5
parent 6042 2da5b19a6460
parent 6031 7383384793fb
child 6057 218d5b9aa466
child 6067 57c1a7052982
equal deleted inserted replaced
6047:a7178d4ed8ee 6048:cfb4a51da7d5
   223     hg.clean(repo, node, show_stats=False)
   223     hg.clean(repo, node, show_stats=False)
   224     revert_opts = opts.copy()
   224     revert_opts = opts.copy()
   225     revert_opts['date'] = None
   225     revert_opts['date'] = None
   226     revert_opts['all'] = True
   226     revert_opts['all'] = True
   227     revert_opts['rev'] = hex(parent)
   227     revert_opts['rev'] = hex(parent)
       
   228     revert_opts['no_backup'] = None
   228     revert(ui, repo, **revert_opts)
   229     revert(ui, repo, **revert_opts)
   229     commit_opts = opts.copy()
   230     commit_opts = opts.copy()
   230     commit_opts['addremove'] = False
   231     commit_opts['addremove'] = False
   231     if not commit_opts['message'] and not commit_opts['logfile']:
   232     if not commit_opts['message'] and not commit_opts['logfile']:
   232         commit_opts['message'] = _("Backed out changeset %s") % (short(node))
   233         commit_opts['message'] = _("Backed out changeset %s") % (short(node))
  2194     # need all matching names in dirstate and manifest of target rev,
  2195     # need all matching names in dirstate and manifest of target rev,
  2195     # so have to walk both. do not print errors if files exist in one
  2196     # so have to walk both. do not print errors if files exist in one
  2196     # but not other.
  2197     # but not other.
  2197 
  2198 
  2198     names = {}
  2199     names = {}
  2199     target_only = {}
       
  2200 
  2200 
  2201     wlock = repo.wlock()
  2201     wlock = repo.wlock()
  2202     try:
  2202     try:
  2203         # walk dirstate.
  2203         # walk dirstate.
  2204         for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
  2204         for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
  2205                                                  badmatch=mf.has_key):
  2205                                                  badmatch=mf.has_key):
  2206             names[abs] = (rel, exact)
  2206             names[abs] = (rel, exact)
  2207             if src == 'b':
       
  2208                 target_only[abs] = True
       
  2209 
  2207 
  2210         # walk target manifest.
  2208         # walk target manifest.
  2211 
  2209 
  2212         def badmatch(path):
  2210         def badmatch(path):
  2213             if path in names:
  2211             if path in names:
  2221         for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
  2219         for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
  2222                                                  badmatch=badmatch):
  2220                                                  badmatch=badmatch):
  2223             if abs in names or src == 'b':
  2221             if abs in names or src == 'b':
  2224                 continue
  2222                 continue
  2225             names[abs] = (rel, exact)
  2223             names[abs] = (rel, exact)
  2226             target_only[abs] = True
  2224 
  2227 
  2225         changes = repo.status(match=names.has_key)[:4]
  2228         changes = repo.status(match=names.has_key)[:5]
  2226         modified, added, removed, deleted = map(dict.fromkeys, changes)
  2229         modified, added, removed, deleted, unknown = map(dict.fromkeys, changes)
       
  2230 
  2227 
  2231         # if f is a rename, also revert the source
  2228         # if f is a rename, also revert the source
  2232         cwd = repo.getcwd()
  2229         cwd = repo.getcwd()
  2233         for f in added:
  2230         for f in added:
  2234             src = repo.dirstate.copied(f)
  2231             src = repo.dirstate.copied(f)
  2252             #   make backup if not in target manifest
  2249             #   make backup if not in target manifest
  2253             (modified, revert, remove, True, True),
  2250             (modified, revert, remove, True, True),
  2254             (added, revert, forget, True, False),
  2251             (added, revert, forget, True, False),
  2255             (removed, undelete, None, False, False),
  2252             (removed, undelete, None, False, False),
  2256             (deleted, revert, remove, False, False),
  2253             (deleted, revert, remove, False, False),
  2257             (unknown, add, None, True, False),
       
  2258             (target_only, add, None, False, False),
       
  2259             )
  2254             )
  2260 
  2255 
  2261         entries = names.items()
  2256         entries = names.items()
  2262         entries.sort()
  2257         entries.sort()
  2263 
  2258 
  2280                 # file has changed in dirstate
  2275                 # file has changed in dirstate
  2281                 if mfentry:
  2276                 if mfentry:
  2282                     handle(hitlist, backuphit)
  2277                     handle(hitlist, backuphit)
  2283                 elif misslist is not None:
  2278                 elif misslist is not None:
  2284                     handle(misslist, backupmiss)
  2279                     handle(misslist, backupmiss)
  2285                 else:
       
  2286                     if exact: ui.warn(_('file not managed: %s\n') % rel)
       
  2287                 break
  2280                 break
  2288             else:
  2281             else:
       
  2282                 if abs not in repo.dirstate:
       
  2283                     if mfentry:
       
  2284                         handle(add, True)
       
  2285                     elif exact:
       
  2286                         ui.warn(_('file not managed: %s\n') % rel)
       
  2287                     continue
  2289                 # file has not changed in dirstate
  2288                 # file has not changed in dirstate
  2290                 if node == parent:
  2289                 if node == parent:
  2291                     if exact: ui.warn(_('no changes needed to %s\n') % rel)
  2290                     if exact: ui.warn(_('no changes needed to %s\n') % rel)
  2292                     continue
  2291                     continue
  2293                 if pmf is None:
  2292                 if pmf is None:
  2296                     pmf = repo.changectx(parent).manifest()
  2295                     pmf = repo.changectx(parent).manifest()
  2297                 if abs in pmf:
  2296                 if abs in pmf:
  2298                     if mfentry:
  2297                     if mfentry:
  2299                         # if version of file is same in parent and target
  2298                         # if version of file is same in parent and target
  2300                         # manifests, do nothing
  2299                         # manifests, do nothing
  2301                         if pmf[abs] != mfentry:
  2300                         if (pmf[abs] != mfentry or
       
  2301                             pmf.flags(abs) != mf.flags(abs)):
  2302                             handle(revert, False)
  2302                             handle(revert, False)
  2303                     else:
  2303                     else:
  2304                         handle(remove, False)
  2304                         handle(remove, False)
  2305 
  2305 
  2306         if not opts.get('dry_run'):
  2306         if not opts.get('dry_run'):