git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: James Farwell <jfarwell@vmware.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Bug: git-p4 can generate duplicate commits when syncing changes that span multiple depot paths
Date: Thu, 8 Sep 2016 21:41:25 +0000	[thread overview]
Message-ID: <BY1PR0501MB12719CA4CB88596EE88F1504A2FB0@BY1PR0501MB1271.namprd05.prod.outlook.com> (raw)

Reproduction Steps:

1. Have a git repo cloned from a perforce repo using multiple depot paths (e.g. //depot/foo and //depot/bar).
2. Submit a single change to the perforce repo that makes changes in both //depot/foo and //depot/bar.
3. Run "git p4 sync" to sync the change from #2.


Expected Behavior:

Change should be synced as a single commit to the git repo.


Actual Behavior:

Change is synced as multiple commits, one for each depot path that was affected.


Best Guess:

I believe this is happening because the command syntax "p4 changes //depot/foo/...@123,456 //depot/bar/...@123,456", which git-p4 uses to get the list of changes to sync, will return the same change number multiple times if the change was present in multiple depot paths. This is expected behavior as per the p4 changes documentation: "If p4 changes is called with multiple file arguments, the sets of changelists that affect each argument are evaluated individually. The final output is neither combined nor sorted; the effect is the same as calling p4 changes multiple times, once for each file argument." git-p4 is handling the sorting itself, but it is not handling the combining.

I would imagine this is fixable in the p4ChangesForPaths() method by dropping non-unique elements of the list before or after sorting. Rudimentary testing in the python interpreter would suggest that something like "changes = sorted(set(changes))" should do the trick, but I am no python expert so there may be a better way.


Thanks!
- James

                 reply	other threads:[~2016-09-08 21:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BY1PR0501MB12719CA4CB88596EE88F1504A2FB0@BY1PR0501MB1271.namprd05.prod.outlook.com \
    --to=jfarwell@vmware.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).