Skip to content

Commit 9cc0b7e

Browse files
aoeuicopybara-github
authored andcommitted
Move LongVersionGetter into third_party.
Rationalize getNonexistentPathVersion's return value and clarify its documentation. PiperOrigin-RevId: 707902859 Change-Id: Ibd61f2c296eb8564d2263f3469912b91fd59f775
1 parent 133ba98 commit 9cc0b7e

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

src/main/java/com/google/devtools/build/lib/versioning/BUILD

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ filegroup(
1313

1414
java_library(
1515
name = "versioning",
16-
srcs = glob(["*.java"]),
16+
srcs = glob(
17+
["*.java"],
18+
exclude = ["LongVersionGetter.java"],
19+
),
1720
deps = [
1821
"//src/main/java/com/google/devtools/build/lib/shell",
1922
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
2023
"//third_party:auto_value",
2124
"//third_party:guava",
2225
],
2326
)
27+
28+
java_library(
29+
name = "long_version_getter",
30+
srcs = ["LongVersionGetter.java"],
31+
deps = [
32+
"//src/main/java/com/google/devtools/build/lib/vfs",
33+
"//third_party:jsr305",
34+
],
35+
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2024 The Bazel Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package com.google.devtools.build.lib.versioning;
15+
16+
import com.google.devtools.build.lib.vfs.Path;
17+
import java.io.IOException;
18+
import javax.annotation.Nullable;
19+
20+
/** Strategy for retrieving the version number for paths. */
21+
public interface LongVersionGetter {
22+
23+
/**
24+
* Indicates the item was affected in currently evaluated versions. Outside of tests, it can only
25+
* be returned for changes in current client snapshot.
26+
*/
27+
// TODO(b/151473808): Do not request xattrs for paths without it outside of client snapshots in
28+
// tests. Rename the constant accordingly once we do so.
29+
long CURRENT_VERSION = Long.MAX_VALUE;
30+
31+
/**
32+
* Returns version number when the provided file/symlink was last modified (or added).
33+
*
34+
* <p>Special value of {@link #CURRENT_VERSION} is used to indicate a file/symlink modified in
35+
* current client snapshot.
36+
*/
37+
long getFilePathOrSymlinkVersion(Path path) throws IOException;
38+
39+
/**
40+
* Returns version number when the listing of given directory has last changed (or when the
41+
* directory was created if there were no changes since then).
42+
*
43+
* <p>Special value of {@link #CURRENT_VERSION} is used to indicate the listing has changed in
44+
* current client snapshot.
45+
*/
46+
long getDirectoryListingVersion(Path path) throws IOException;
47+
48+
/**
49+
* Returns a version number for a currently nonexistent item.
50+
*
51+
* <p>This can be the version at which it was most recently deleted or one of the special cases
52+
* below.
53+
*
54+
* <ul>
55+
* <li><b>Deleted in Current Snapshot</b>: returns {@link #CURRENT_VERSION}
56+
* <li><b>External, unversioned, paths</b>: returns {@link #CURRENT_VERSION}
57+
* <li><b>Never existed in the first place</b>: returns null
58+
* <li><b>Parent directory doesn't exist</b>: returns null
59+
* </ul>
60+
*/
61+
@Nullable
62+
Long getNonexistentPathVersion(Path path) throws IOException;
63+
}

0 commit comments

Comments
 (0)