@@ -816,8 +816,11 @@ class ConduitAPI:
816816
817817 # Return revisions in the same order requested.
818818 if ids :
819+ # Skip revisions for which we do not have a query result.
819820 return [
820- revisions [phids_by_id [rev_id ]] for rev_id in ids if phids_by_id [rev_id ]
821+ revisions [phids_by_id [rev_id ]]
822+ for rev_id in ids
823+ if rev_id in phids_by_id
821824 ]
822825 else :
823826 return [revisions [phid ] for phid in phids ]
@@ -1542,6 +1545,21 @@ class Repository(object):
15421545 if has_arc_rejections (commit ["body" ]):
15431546 commit_errors .append ("contains arc fields" )
15441547
1548+ if commit ["rev-id" ]:
1549+ revisions = conduit .get_revisions (ids = [int (commit ["rev-id" ])])
1550+ if len (revisions ) == 0 :
1551+ commit_errors .append (
1552+ "Phabricator did not return a query result for revision D%s"
1553+ " (it might be inaccessible or not exist at all)"
1554+ % commit ["rev-id" ]
1555+ )
1556+
1557+ # commit_issues identified below this are commit_errors unless
1558+ # self.args.force is True, which makes them commit_warnings
1559+ commit_issues = (
1560+ commit_warnings if self .args and self .args .force else commit_errors
1561+ )
1562+
15451563 for reviewer in commit_invalid_reviewers [commit ["node" ]]:
15461564 if "disabled" in reviewer :
15471565 commit_errors .append ("User %s is disabled" % reviewer ["name" ])
@@ -1551,10 +1569,7 @@ class Repository(object):
15511569 reviewer ["name" ],
15521570 reviewer ["until" ],
15531571 )
1554- if self .args .force :
1555- commit_warnings .append (msg )
1556- else :
1557- commit_errors .append (msg )
1572+ commit_issues .append (msg )
15581573 else :
15591574 commit_errors .append (
15601575 "%s is not a valid reviewer's name" % reviewer ["name" ]
@@ -3225,16 +3240,21 @@ def show_commit_stack(
32253240 if commit .get ("rev-id" ):
32263241 action = action_template % ("D" + commit ["rev-id" ])
32273242 if validate :
3228- revision = conduit .get_revisions (ids = [int (commit ["rev-id" ])])[0 ]
3229- # Check if target bug ID is the same as in the Phabricator revision
3230- change_bug_id = revision ["fields" ]["bugzilla.bug-id" ] and (
3231- commit ["bug-id" ] != revision ["fields" ]["bugzilla.bug-id" ]
3232- )
3233- # Check if comandeering is required
3234- whoami = conduit .whoami ()
3235- if revision ["fields" ]["authorPHID" ] != whoami ["phid" ]:
3236- is_author = False
3243+ revisions = conduit .get_revisions (ids = [int (commit ["rev-id" ])])
3244+ if len (revisions ) > 0 :
3245+ revision = revisions [0 ]
3246+
3247+ # Check if target bug ID is the same as in the Phabricator revision
3248+ change_bug_id = revision ["fields" ]["bugzilla.bug-id" ] and (
3249+ commit ["bug-id" ] != revision ["fields" ]["bugzilla.bug-id" ]
3250+ )
32373251
3252+ # Check if comandeering is required
3253+ whoami = conduit .whoami ()
3254+ if "authorPHID" in revision ["fields" ] and (
3255+ revision ["fields" ]["authorPHID" ] != whoami ["phid" ]
3256+ ):
3257+ is_author = False
32383258 else :
32393259 action = action_template % "New"
32403260
0 commit comments