def subrepo(ctx, path): """return instance of the right subrepo class for subrepo in path""" # subrepo inherently violates our import layering rules # because it wants to make repo objects from deep inside the stack # so we manually delay the circular imports to not break # scripts that don't use our demand-loading global hg import hg as h hg = h scmutil.pathauditor(ctx._repo.root)(path) state = ctx.substate.get(path, nullstate) if state[2] not in types: raise util.Abort(_('unknown subrepo type %s') % state[2]) return types[state[2]](ctx, path, state[:2])
del results[s] del results['.hg'] # step 3: report unseen items in the dmap hash if not skipstep3 and not exact: if not results and matchalways: visit = dmap.keys() else: visit = [f for f in dmap if f not in results and matchfn(f)] visit.sort() if unknown: # unknown == True means we walked the full directory tree above. # So if a file is not seen it was either a) not matching matchfn # b) ignored, c) missing, or d) under a symlink directory. audit_path = scmutil.pathauditor(self._root) for nf in iter(visit): # Report ignored items in the dmap as long as they are not # under a symlink directory. if audit_path.check(nf): try: results[nf] = lstat(join(nf)) except OSError: # file doesn't exist results[nf] = None else: # It's either missing or under a symlink directory results[nf] = None else: # We may not have walked the full directory tree above,
def applyupdates(repo, action, wctx, mctx, actx, overwrite): """apply the merge action list to the working directory wctx is the working copy context mctx is the context to be merged into the working copy actx is the context of the common ancestor Return a tuple of counts (updated, merged, removed, unresolved) that describes how many files were affected by the update. """ updated, merged, removed, unresolved = 0, 0, 0, 0 ms = mergestate(repo) ms.reset(wctx.p1().node()) moves = [] action.sort(key=actionkey) # prescan for merges for a in action: f, m = a[:2] if m == 'm': # merge f2, fd, flags, move = a[2:] if f == '.hgsubstate': # merged internally continue repo.ui.debug("preserving %s for resolve of %s\n" % (f, fd)) fcl = wctx[f] fco = mctx[f2] if mctx == actx: # backwards, use working dir parent as ancestor if fcl.parents(): fca = fcl.p1() else: fca = repo.filectx(f, fileid=nullrev) else: fca = fcl.ancestor(fco, actx) if not fca: fca = repo.filectx(f, fileid=nullrev) ms.add(fcl, fco, fca, fd, flags) if f != fd and move: moves.append(f) audit = scmutil.pathauditor(repo.root) # remove renamed files after safely stored for f in moves: if os.path.lexists(repo.wjoin(f)): repo.ui.debug("removing %s\n" % f) audit(f) os.unlink(repo.wjoin(f)) numupdates = len(action) for i, a in enumerate(action): f, m = a[:2] repo.ui.progress(_('updating'), i + 1, item=f, total=numupdates, unit=_('files')) if f and f[0] == "/": continue if m == "r": # remove repo.ui.note(_("removing %s\n") % f) audit(f) if f == '.hgsubstate': # subrepo states need updating subrepo.submerge(repo, wctx, mctx, wctx, overwrite) try: util.unlinkpath(repo.wjoin(f)) except OSError, inst: if inst.errno != errno.ENOENT: repo.ui.warn( _("update failed to remove %s: %s!\n") % (f, inst.strerror)) removed += 1 elif m == "m": # merge if f == '.hgsubstate': # subrepo states need updating subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite) continue f2, fd, flags, move = a[2:] repo.wopener.audit(fd) r = ms.resolve(fd, wctx, mctx) if r is not None and r > 0: unresolved += 1 else: if r is None: updated += 1 else: merged += 1 if (move and repo.dirstate.normalize(fd) != f and os.path.lexists(repo.wjoin(f))): repo.ui.debug("removing %s\n" % f) audit(f) os.unlink(repo.wjoin(f))
def applyupdates(repo, action, wctx, mctx, actx, overwrite): """apply the merge action list to the working directory wctx is the working copy context mctx is the context to be merged into the working copy actx is the context of the common ancestor Return a tuple of counts (updated, merged, removed, unresolved) that describes how many files were affected by the update. """ updated, merged, removed, unresolved = 0, 0, 0, 0 ms = mergestate(repo) ms.reset(wctx.p1().node()) moves = [] action.sort(key=actionkey) # prescan for merges for a in action: f, m = a[:2] if m == "m": # merge f2, fd, flags, move = a[2:] if f == ".hgsubstate": # merged internally continue repo.ui.debug("preserving %s for resolve of %s\n" % (f, fd)) fcl = wctx[f] fco = mctx[f2] if mctx == actx: # backwards, use working dir parent as ancestor if fcl.parents(): fca = fcl.p1() else: fca = repo.filectx(f, fileid=nullrev) else: fca = fcl.ancestor(fco, actx) if not fca: fca = repo.filectx(f, fileid=nullrev) ms.add(fcl, fco, fca, fd, flags) if f != fd and move: moves.append(f) audit = scmutil.pathauditor(repo.root) # remove renamed files after safely stored for f in moves: if os.path.lexists(repo.wjoin(f)): repo.ui.debug("removing %s\n" % f) audit(f) os.unlink(repo.wjoin(f)) numupdates = len(action) for i, a in enumerate(action): f, m = a[:2] repo.ui.progress(_("updating"), i + 1, item=f, total=numupdates, unit=_("files")) if f and f[0] == "/": continue if m == "r": # remove repo.ui.note(_("removing %s\n") % f) audit(f) if f == ".hgsubstate": # subrepo states need updating subrepo.submerge(repo, wctx, mctx, wctx, overwrite) try: util.unlinkpath(repo.wjoin(f)) except OSError, inst: if inst.errno != errno.ENOENT: repo.ui.warn(_("update failed to remove %s: %s!\n") % (f, inst.strerror)) removed += 1 elif m == "m": # merge if f == ".hgsubstate": # subrepo states need updating subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite) continue f2, fd, flags, move = a[2:] repo.wopener.audit(fd) r = ms.resolve(fd, wctx, mctx) if r is not None and r > 0: unresolved += 1 else: if r is None: updated += 1 else: merged += 1 if move and repo.dirstate.normalize(fd) != f and os.path.lexists(repo.wjoin(f)): repo.ui.debug("removing %s\n" % f) audit(f) os.unlink(repo.wjoin(f))