# # patch "monotone.cc" # from [e0a071fb1e12612b463e109f4a2088a48f7412e2] # to [919b8cbcd5e06a3c0c33b8e1223bd7bdc2bbaa63] # # patch "rev_file_list.cc" # from [3597d948ae3119f68cc94adb5ae5511622887043] # to [3c1249cae4365c63d4560f13c0eefc5d7caac0b1] # # patch "rev_file_list.hh" # from [60ac0e9272451654cc00ae9d1c6e5b36d3d57964] # to [d053c9583bb5fddd8cdb0e78539f08d0067a4a2c] # ======================================================================== --- monotone.cc e0a071fb1e12612b463e109f4a2088a48f7412e2 +++ monotone.cc 919b8cbcd5e06a3c0c33b8e1223bd7bdc2bbaa63 @@ -505,6 +505,7 @@ { std::string ign1, ign2; std::vector args; + args.push_back("--execute"); args.push_back(oldname); args.push_back(newname); runcmd("rename", args, ign1, ign2); ======================================================================== --- rev_file_list.cc 3597d948ae3119f68cc94adb5ae5511622887043 +++ rev_file_list.cc 3c1249cae4365c63d4560f13c0eefc5d7caac0b1 @@ -19,6 +19,20 @@ return v; } +bool operator<(trr const & l, trr const & r) +{ + Glib::ustring ls = l.get_path().to_string(); + Glib::ustring rs = r.get_path().to_string(); + return ls < rs; +} + +bool operator==(trr const & l, trr const & r) +{ + Glib::ustring ls = l.get_path().to_string(); + Glib::ustring rs = r.get_path().to_string(); + return ls == rs; +} + namespace states { const std::string added("add"); @@ -115,6 +129,7 @@ void rev_file_list::menuadd() { + Gtk::TreeModel::Row menurow = *menuiter; menurow[col.included] = true; menurow[col.changed] = true; menurow[col.status] = states::added; @@ -128,6 +143,7 @@ void rev_file_list::menudrop() { + Gtk::TreeModel::Row menurow = *menuiter; if (menurow[col.status] == states::added) { menurow[col.included] = false; @@ -150,6 +166,7 @@ void rev_file_list::menurename() { + Gtk::TreeModel::Row menurow = *menuiter; Gtk::FileChooserDialog dialog("Please choose a new name", Gtk::FILE_CHOOSER_ACTION_SAVE, ""); dialog.set_transient_for(*rd->window); @@ -168,9 +185,10 @@ if (newname == n2 || (n2.empty() && newname == n1)) return; rd->mtn->rename(n2, newname); + menurow[col.postname] = newname; if (newname == n1) {// undo rename - menurow[col.name] = newname; + recalc_name(menuiter); if (menurow[col.status] == states::renamed) { menurow[col.included] = false; @@ -185,10 +203,7 @@ menurow[col.changed] = true; menurow[col.status] = states::renamed; } - if (menurow[col.status] == states::added) - menurow[col.name] = newname; - else - menurow[col.name] = n1 + "\n" + newname; + recalc_name(menuiter); needscan = true; } } @@ -196,6 +211,7 @@ void// not supported by monotone rev_file_list::menuundrop() { + Gtk::TreeModel::Row menurow = *menuiter; std::string name = Glib::ustring(menurow[col.postname]); if (name.empty()) name = Glib::ustring(menurow[col.prename]); @@ -223,6 +239,7 @@ void rev_file_list::menurevert() { + Gtk::TreeModel::Row menurow = *menuiter; if (menurow[col.status] == states::added) menurow[col.status] = states::unknown; else @@ -232,6 +249,7 @@ if (name.empty()) name = Glib::ustring(menurow[col.prename]); rd->mtn->revert(name); + recalc_name(menuiter); needscan = true; } @@ -250,7 +268,8 @@ return; bool add_(false), drop_(false), rename_(false); bool undrop_(false), unmove_(false), revert_(false); - menurow = *filelist->get_iter(path); + menuiter = filelist->get_iter(path); + Gtk::TreeModel::Row menurow = *menuiter; if (menurow[col.status] == states::added) drop_ = rename_ = revert_ = true; else if (menurow[col.status] == states::patched) @@ -424,6 +443,41 @@ } void +rev_file_list::recalc_name(Gtk::TreeModel::iterator & i) +{ + Glib::ustring pre = (*i)[col.prename]; + Glib::ustring post = (*i)[col.postname]; + Glib::ustring disp; + std::map::iterator j = rdirs.end(); + if (filelist->iter_depth(i)) + { + Gtk::TreeModel::iterator k = i->parent(); + Gtk::TreeModel::RowReference ref(filelist, filelist->get_path(k)); + j = rdirs.find(ref); + } + Glib::ustring parent; + if (j != rdirs.end()) + parent = j->second + "/"; + if (pre.find(parent) == 0) + pre = pre.substr(parent.size()); + else + pre = "/" + pre; + if (post.find(parent) == 0) + post = post.substr(parent.size()); + else + post = "/" + post; + if (pre.empty()) + disp = post; + else if (post.empty()) + disp = pre; + else if (pre == post) + disp = pre; + else + disp = pre + "\n" + post; + (*i)[col.name] = disp; +} + +void rev_file_list::rescan() { if (needscan) @@ -441,7 +495,8 @@ comments[current_file] = rd->rfi.get_comment(); rd->rfi.set_comment(std::vector(), ""); current_file = ""; - std::map dirs; + dirs.clear(); + rdirs.clear(); while (!filelist->children().empty()) filelist->erase(filelist->children().begin()); @@ -479,12 +534,16 @@ Glib::ustring workstr = i->postname; if (workstr.empty()) workstr = i->prename; + if (workstr.empty()) + { +// std::cout<<"Nameless item!\n"; + continue; + } std::vector stk; while (true) { Glib::ustring pdir = workstr.substr(0, workstr.rfind('/')); - std::map::iterator - j = dirs.find(pdir); + std::map::iterator j = dirs.find(pdir); if (j != dirs.end() || pdir.size() == workstr.size()) { if (j != dirs.end()) @@ -496,10 +555,15 @@ while (!stk.empty()) { Gtk::TreeModel::iterator row = filelist->append(parent_row); - (*row)[col.name] = workstr.substr(workstr.rfind('/')+1); - dirs.insert(std::make_pair(workstr, - Gtk::TreeModel::RowReference(filelist, - filelist->get_path(row)))); + Glib::ustring leaf = workstr.substr(workstr.rfind('/')+1); + (*row)[col.name] = leaf; + (*row)[col.prename] = workstr; + (*row)[col.postname] = workstr; + (*row)[col.status] = " "; + Gtk::TreeModel::RowReference + rr(filelist, filelist->get_path(row)); + dirs.insert(std::make_pair(workstr, rr)); + rdirs.insert(std::make_pair(rr, workstr)); parent_row = row->children(); workstr = stk.back(); stk.pop_back(); @@ -531,15 +595,7 @@ row[col.prename] = i->prename; row[col.postname] = i->postname; - Glib::ustring preleaf = i->prename.substr(i->prename.rfind('/')+1); - Glib::ustring postleaf = i->postname.substr(i->postname.rfind('/')+1); - if (i->prename.size() && i->postname.size() - && i->prename != i->postname) - row[col.name] = i->prename + "\n" + postleaf; - else if (i->prename.size()) - row[col.name] = preleaf; - else - row[col.name] = postleaf; + recalc_name(iter); } } ======================================================================== --- rev_file_list.hh 60ac0e9272451654cc00ae9d1c6e5b36d3d57964 +++ rev_file_list.hh d053c9583bb5fddd8cdb0e78539f08d0067a4a2c @@ -18,6 +18,10 @@ class revdat; +struct trr: public Gtk::TreeRowReference +{ + trr(Gtk::TreeRowReference const & r): Gtk::TreeRowReference(r) {} +}; class rev_file_list: public Gtk::VBox { @@ -102,8 +106,10 @@ std::string current_file; Gtk::Menu menu; - Gtk::TreeModel::Row menurow; + Gtk::TreeModel::iterator menuiter; bool needscan; + std::map dirs; + std::map rdirs; void menuadd(); void menudrop(); @@ -122,6 +128,7 @@ void selfile(Gtk::TreeModel::Path const & p, Gtk::TreeView::Column *c); void clicked(GdkEventButton *b); void set_menu(std::vector const & v); + void recalc_name(Gtk::TreeModel::iterator & i); public: rev_file_list(revdat *r); void set_wc(bool w);