Skip to content

Commit

Permalink
option to override changesets from bookmark update log
Browse files Browse the repository at this point in the history
Summary:
The sync job is usually just reading the bookmark update log but sometimes we
need it to pretend the contents are actually different to prevent it from
replicating problematic changes.

Reviewed By: RajivTS

Differential Revision: D55064423

fbshipit-source-id: 42e4e1fbc10ad7ce3a2ee6da9097ccec26cb48b3
  • Loading branch information
mitrandir77 authored and facebook-github-bot committed Mar 20, 2024
1 parent bc73917 commit 8803124
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions eden/mononoke/mononoke_hg_sync_job/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,15 @@ impl HgSyncProcess {
.multiple(true)
.help("skip entries about particular bookmark from bookmark update log")
)
.arg(
Arg::with_name("replace-changeset")
.long("replace-changeset")
.takes_value(true)
.required(false)
.multiple(true)
.help("replace particular changeset mentioned in bookmark update log with a new commit hash, \
the arg should be formatted like bonsai_csid:replacement_bonsai_csid")
)
.arg(
Arg::with_name("combine-bundles")
.long("combine-bundles")
Expand Down Expand Up @@ -1384,6 +1393,18 @@ async fn run<'a>(
let skip_bookmarks = sub_m
.values_of("skip-bookmark")
.map_or(Vec::new(), |v| v.collect());
let replace_changesets: HashMap<Option<ChangesetId>, Option<ChangesetId>> = sub_m
.values_of("replace-changeset")
.map_or(HashMap::new(), |v| {
v.map(|cs_pair| {
let mut split = cs_pair.split(':');
(
Some(split.next().unwrap().parse().unwrap()),
Some(split.next().unwrap().parse().unwrap()),
)
})
.collect()
});
let loop_forever = sub_m.is_present("loop-forever");
let replayed_sync_counter = LatestReplayedSyncCounter::new(
&repo,
Expand Down Expand Up @@ -1452,6 +1473,21 @@ async fn run<'a>(
entries
.into_iter()
.filter(|entry| !skip_bookmarks.contains(&entry.bookmark_name.as_str()))
.map(|entry| {
let from_changeset_id = replace_changesets
.get(&entry.from_changeset_id)
.cloned()
.unwrap_or(entry.from_changeset_id);
let to_changeset_id = replace_changesets
.get(&entry.to_changeset_id)
.cloned()
.unwrap_or(entry.to_changeset_id);
BookmarkUpdateLogEntry {
from_changeset_id,
to_changeset_id,
..entry
}
})
.collect::<Vec<_>>()
})
.fuse()
Expand Down

0 comments on commit 8803124

Please sign in to comment.