'arc diff' keeps creating new revision on Phabricator

Flow:

  1. arc diff -> created a new revision (say the revision id is X111)
  2. arc which -> clearly shows that there is an existing revision X111, and next arc diff will update it
  3. change code
  4. arc diff or arc diff --update X111 (I tried both) -> a new revision is created
  5. arc which -> shows that there are 2 existing revisions

Anyone has any idea on how did this happen?
Or, I guess my questions are:

  1. How does arc decide whether arc diff need to create or update a revision under the hood?(by reading and writing some local hidden file I guess?)
  2. What could possibly prevent arc diff from updating an existing revision (apparently arc knows there is an existing one from the output of arc which, and I even forced it to update by using arc diff --update REVISION_ID)?

All suggestions will be appreciated!

Thanks

Arc decides which revision to update based on the commit messages in the current branch. For example, arc which will show:

These Differential revisions match the changes in this working copy:

    D1234 My existing revision title
        Reason: Commit message for 'ba1da31968b6f076' has explicit 'Differential Revision'.
  • Could you elaborate some more on what you’re doing in step 3?
  • What does arc which show after step 3 and before step 4?

arc which after first commit:

REPOSITORY
To identify the repository associated with this working copy, arc followed this process:

    Configuration value "repository.callsign" is empty.

    This repository has no VCS UUID (this is normal for git/hg).

    The remote URI for this working copy is
    "git@git.x:x.git".

    No repositories matched the query. Check that your configuration is
    correct, or use "repository.callsign" to select a repository explicitly.

This working copy is not associated with any repository.

COMMIT RANGE
If you run 'arc diff', changes between the commit:

    97a7c2d44e9b1bae  xxxxx

...and the current working copy state will be sent to Differential, because
it is the merge-base of 'origin/develop' (the Git upstream of the current
branch) HEAD.

You can see the exact changes that will be sent by running this command:

    $ git diff 97a7c2d44e9b1bae..HEAD

These commits will be included in the diff:

    48864b5c129d2850  x
    18e97fbb2ccbb5b9  x


MATCHING REVISIONS
These Differential revisions match the changes in this working copy:

    D507 x
        Reason: A git commit or tree hash in the commit range is already attached to the Differential revision.

Since exactly one revision in Differential matches this working copy, it will
be updated if you run 'arc diff'.

Modify some code, then arc diff again

Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Unable to determine repository for this change.
Updating commit message...
Created a new Differential revision:
        Revision URI: http://phabricator.x/D508

Included changes:
  M       src/main/java/x.java
  M       src/main/java/x.java
  M       src/main/java/x.java
  A       src/test/java/com/x.java

arc which after second commit:

REPOSITORY
To identify the repository associated with this working copy, arc followed this process:

    Configuration value "repository.callsign" is empty.

    This repository has no VCS UUID (this is normal for git/hg).

    The remote URI for this working copy is
    "git@git.x.git".

    No repositories matched the query. Check that your configuration is
    correct, or use "repository.callsign" to select a repository explicitly.

This working copy is not associated with any repository.

COMMIT RANGE
If you run 'arc diff', changes between the commit:

    97a7c2d44e9b1bae  x

...and the current working copy state will be sent to Differential, because
it is the merge-base of 'origin/develop' (the Git upstream of the current
branch) HEAD.

You can see the exact changes that will be sent by running this command:

    $ git diff 97a7c2d44e9b1bae..HEAD

These commits will be included in the diff:

    a9f615560c37b570  x
    48864b5c129d2850  x
    18e97fbb2ccbb5b9  x


MATCHING REVISIONS
These Differential revisions match the changes in this working copy:

    D508 x
        Reason: A git commit or tree hash in the commit range is already attached to the Differential revision.

    D507 x
        Reason: A git commit or tree hash in the commit range is already attached to the Differential revision.

Since more than one revision in Differential matches this working copy, you
will be asked which revision you want to update if you run 'arc diff '.

And this is NOT happening on all engineers in our company, just few of them. I checked arc get-config from good ones and bad ones, there is no difference.

It’s difficult to known what exactly happened, because we don’t know what arc which said between doing your second commit and doing your second arc diff.

My guess is the affected engineers somehow change the commit message that arc wrote. Maybe they’re doing something like git commit --amend?

Thanks ivo,

I forked my own arc and printed out debug logs for every step, and finally found the problem.
The problem is that some of our colleagues are using Chinese version of arc, their commit message will be like:

代码 review 优化

评审者: weizhibo, zhangmin

Reviewed By: weizhibo

Differential 修订: http://phabricator.xxx/D472

But the regex in line https://github.com/phacility/arcanist/blob/9e82ef979e8148c43b9b8439025d505b1219e213/src/differential/ArcanistDifferentialCommitMessage.php#L104 only matches English commit message, which prevent us from getting the correct revision ID.

Not sure if there are any better solution to this but for now we have to use our own version of arc to make sure everything works perfect. Let me know if you guys can come up with a global solution to this.

1 Like

I had this problem too, so I have to change phabricator web language into English from Chinese.

1 Like

Thanks a lot, It works in our develop env.:upside_down_face: