| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 
 | static void
restrict_patch_set(patch_set & ps, work_set & restricted_work, app_state & app) 
{
  L(F("restricting changes between %s and %s\n") % ps.m_old % ps.m_new);
  // remove restricted adds from f_adds and remove entry from m_new
  set<patch_addition> included_adds;
  for (set<patch_addition>::iterator i = ps.f_adds.begin();
       i != ps.f_adds.end(); ++i)
    {
      if (app.in_restriction(i->path())) 
        {
          L(F("restriction includes add %s\n") % i->path());
          included_adds.insert(*i);
        }
      else
        {
          L(F("restriction excludes add %s\n") % i->path());
          ps.map_new.erase(i->path());
          restricted_work.adds.insert(i->path());
        }
    }
  ps.f_adds = included_adds;
  // remove restricted dels from f_dels and put entry in m_new with entry from m_old
  set<file_path> included_dels;
  for (set<file_path>::iterator i = ps.f_dels.begin();
       i != ps.f_dels.end(); ++i)
    {
      if (app.in_restriction((*i)())) 
        {
          L(F("restriction includes delete %s\n") % (*i)());
          included_dels.insert(*i);
        }
      else
        {
          N(ps.map_old.find(*i) != ps.map_old.end(),
            F("nothing known about %s") % *i);
          L(F("restriction excludes delete %s\n") % (*i)());
          path_id_pair old(ps.map_old.find(*i));
          ps.map_new.insert(entry(old.path(), old.ident()));
          restricted_work.dels.insert((*i)());
        }
    }
  ps.f_dels = included_dels;
  // remove restricted moves from f_moves and replace entry in m_new with entry from m_old
  set<patch_move> included_moves;
  for (set<patch_move>::iterator i = ps.f_moves.begin();
       i != ps.f_moves.end(); ++i)
    {
      // is excluding both sides of a rename the right thing to do?
      // or should we just fail if only one side of a move is restricted? (njs's idea)
      if (app.in_restriction(i->path_old()) || app.in_restriction(i->path_new())) 
        {
          L(F("restriction includes move %s to %s\n") % i->path_old() % i->path_new());
          included_moves.insert(*i);
        }
      else
        {
          N(ps.map_old.find(i->path_old()) != ps.map_old.end(),
            F("nothing known about %s") % i->path_old());
          L(F("restriction excludes move %s to %s\n") % i->path_old() % i->path_new());
          ps.map_new.erase(i->path_new());
          path_id_pair old(ps.map_old.find(i->path_old()));
          ps.map_new.insert(entry(old.path(), old.ident()));
          restricted_work.renames.insert(make_pair(i->path_old(), i->path_new()));
        }
    }
  ps.f_moves = included_moves;
  // remove restricted deltas from f_deltas and replace entry in m_new with entry from m_old
  set<patch_delta> included_deltas;
  for (set<patch_delta>::iterator i = ps.f_deltas.begin();
       i != ps.f_deltas.end(); ++i)
    {
      if (app.in_restriction(i->path()))
        {
          L(F("restriction includes delta %s\n") % i->path());
          included_deltas.insert(*i);
        }
      else
        {
          N(ps.map_old.find(i->path()) != ps.map_old.end(),
            F("nothing known about %s") % i->path());
          L(F("restriction excludes delta %s\n") % i->path());
          ps.map_new.erase(i->path());
          path_id_pair old(ps.map_old.find(i->path()));
          ps.map_new.insert(entry(old.path(), old.ident()));
        }
    }
  ps.f_deltas = included_deltas;
  calculate_ident(ps.map_new, ps.m_new);
  L(F("restricted changes between %s and %s\n") % ps.m_old % ps.m_new);
}
static void
restrict_patch_set(patch_set & ps, app_state & app) 
{
  work_set work;
  restrict_patch_set(ps, work, app);
}
 |